Skip to content

Commit

Permalink
add docs/user/tutorials
Browse files Browse the repository at this point in the history
  • Loading branch information
anoipm committed May 17, 2024
1 parent 6d2e7f1 commit 6d11fd8
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
70 changes: 70 additions & 0 deletions docs/user/tutorials/01-10-simple-use.md
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
```
3 changes: 3 additions & 0 deletions docs/user/tutorials/README.md
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.

0 comments on commit 6d11fd8

Please sign in to comment.