Application using images from the internal registry
On this exercise1, we will deploy an application, tag and push a new version of the image to the Internal Registry, find where the image is hosted and patch the deployment to use the new image.
Steps
- Exposing the registry
- Application deployment
- Finding image inside the node
- Tagging and pushing an image to the internal registry
- Patching deployment image
1. Exposing the registry
-
Patch the Image Registry
-
Take note of the registry route:
2. Application deployment
- This example will use an image that assumes authentication to Red Hat registry, but any other image can be used.
oc apply -f - <<EOF apiVersion: apps/v1 kind: Deployment metadata: labels: app: new-default-deploy app.kubernetes.io/component: new-default-deploy app.kubernetes.io/instance: new-default-deploy app.kubernetes.io/part-of: new-default-deploy app.openshift.io/runtime: redhat name: new-default-deploy spec: replicas: 1 selector: matchLabels: app: new-default-deploy type: Recreate template: metadata: labels: app: new-default-deploy deploymentconfig: new-default-deploy spec: containers: - image: registry.access.redhat.com/ubi8/ubi:latest imagePullPolicy: Always name: new-default-deploy command: - /bin/sh - -c - | sleep infinity resources: {} EOF
3. Finding image inside the node
-
Inspect in which node the pod is hosted
-
Inspect the node where the image is hosted.
4. Tagging and pushing an image to the internal registry
-
Take note of your user token
-
Tagging and pushing image to the internal registry.
Use the exposed route to tag and push
sh-5.1# podman login -u myuser -p <token> Login Succeeded! sh-5.1# podman tag registry.access.redhat.com/ubi8/ubi:latest default-route-openshift-image-registry.apps.hhmkrp84.westeurope.aroapp.io/new-default-app/ubi8:latest sh-5.1# podman push default-route-openshift-image-registry.apps.hhmkrp84.westeurope.aroapp.io/new-default-app/ubi8:latest --remove-signatures
5. Patching the deployment to use a new image
-
Patch command to add the image recently pushed to the internal registry.
-
New pod running in the same node with the new image:
-
This exercise was particularly interesting because it was how I was able to test and reproduce a bug once. ↩