This tutorial shows how you can push an image to the Docker Registry and use it.
-
Create a
simple.py
file, and paste the following content:import time import datetime while True: print("Current time:", datetime.datetime.now(), flush=True) time.sleep(10)
-
Create
Dockerfile
with the following content:FROM python:3-alpine WORKDIR /usr/src/app COPY simple.py . CMD [ "python", "./simple.py" ]
-
Build and push the image to Docker Registry:
docker build -t simple-image .
-
Import the image to Docker Registry:
kyma image-import simple-image:latest
-
Create a Pod using the image from Docker Registry:
kubectl run simple-pod --image=localhost:32137/simple-image:latest --overrides='{ "spec": { "imagePullSecrets": [ { "name": "dockerregistry-config" } ] } }'
-
Check if the Pod is running:
kubectl get pods simple-pod
Expected output:
NAME READY STATUS RESTARTS AGE simple-pod 1/1 Running 0 60s
-
Use the following command to print the current time every 10 seconds:
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