generated from kyma-project/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Use Docker Registry | ||
|
||
This tutorial shows how you can push image to Docker Registry and use it | ||
|
||
## Steps | ||
|
||
1. Prepare simple image: | ||
|
||
Save it as `simple.py`: | ||
```python | ||
import time | ||
import datetime | ||
|
||
while True: | ||
print("Current time:", datetime.datetime.now(), flush=True) | ||
time.sleep(10) | ||
``` | ||
|
||
Save it as `Dockerfile` and build it: | ||
```dockerfile | ||
FROM python:3-alpine | ||
|
||
WORKDIR /usr/src/app | ||
|
||
COPY simple.py . | ||
|
||
CMD [ "python", "./simple.py" ] | ||
``` | ||
|
||
Build and push the image to Docker Registry: | ||
```bash | ||
docker build -t simple-image . | ||
``` | ||
|
||
2. Import image to Docker Registry: | ||
|
||
<!-- TODO: presiquites: kyma cli (new version) --> | ||
```bash | ||
kyma image-import simple-image:latest | ||
``` | ||
|
||
3. Create pod using image from Docker Registry: | ||
|
||
```bash | ||
kubectl run simple-pod --image=localhost:32137/simple-image:latest --overrides='{ "spec": { "imagePullSecrets": [ { "name": "dockerregistry-config" } ] } }' | ||
``` | ||
|
||
4. Check if the pod is running: | ||
|
||
Pod should be in `Running` state: | ||
```bash | ||
kubectl get pods simple-pod | ||
``` | ||
Expected output: | ||
``` | ||
NAME READY STATUS RESTARTS AGE | ||
simple-pod 1/1 Running 0 60s | ||
``` | ||
|
||
Python script (inside pod) should print current time every 10 seconds: | ||
```bash | ||
kubectl logs simple-pod | ||
``` | ||
Expected output: | ||
``` | ||
Current time: 2024-05-17 11:23:34.957406 | ||
Current time: 2024-05-17 11:23:44.954583 | ||
Current time: 2024-05-17 11:23:54.956107 | ||
Current time: 2024-05-17 11:24:04.966306 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Tutorials | ||
|
||
This section will help you understand how to use Docker Registry. |