πŸš€ DevOps & SRE Certification Program πŸ“… Starting: 1st of Every Month 🀝 +91 8409492687 πŸ” Contact@DevOpsSchool.com

Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.


Get Started Now!

What is ImageStreams & Step by Step Tutorials

πŸ‘‰ What ImageStream really gives you
πŸ‘‰ Why OpenShift uses it
πŸ‘‰ How it’s better (in some cases) than just pulling a normal image


🧠 First, imagine two situations:

πŸ”΅ Situation 1: Without ImageStream (Normal Kubernetes)

  • You deploy an app with a direct Docker image URL: image: nginx:latest
  • Kubernetes will never track changes in nginx:latest.
  • If someone updates the latest image, your running pods stay the same unless you manually trigger an update (like delete the pod, rollout new version).
  • There’s no history, no auto-notifications, and no internal record of what β€œlatest” pointed to when you deployed it.
  • No control, no tracking, no automatic trigger.

βœ… Simple but very dumb way.
βœ… Works when you fully control your CI/CD pipeline.


🟠 Situation 2: With OpenShift ImageStream

  • Instead of pulling images directly, OpenShift tracks them through an ImageStream.
  • When nginx:latest is updated on DockerHub, OpenShift automatically imports the new image metadata into ImageStream.
  • You can:
    • Automatically redeploy apps when the image changes (without touching anything).
    • View history of all previous images that ever existed for that tag.
    • Tag images manually between environments (example: promote dev image β†’ staging β†’ prod by just changing a tag).
    • Control access to images inside OpenShift’s internal registry.
    • Pin exact images by digest to avoid accidental breakage.

βœ… Smart, controlled, observable, CI/CD friendly.


✨ So, in simple words:

Normal Images (Kubernetes)ImageStream (OpenShift)
Pull and forget. No update tracking.Tracks external and internal images in OpenShift.
No automatic redeploy when images change.Can auto-trigger deployment when new image arrives.
No history of what version you pulled.Maintains history of images for every tag.
Cannot promote images safely between environments.Can tag/promote images easily between dev β†’ staging β†’ prod.
No OpenShift access control for images.Full OpenShift permission control for pull, tag, promote.
You manage everything outside cluster.OpenShift manages image lifecycle inside cluster.

πŸ“Έ Example to make it even more practical

βœ… Without ImageStream:

  • You push a new app build to DockerHub (myapp:latest updated).
  • Your Kubernetes app still uses old container unless you manually trigger a deployment.

βœ… With ImageStream:

  • You push a new app build to DockerHub (myapp:latest updated).
  • OpenShift automatically imports the new version into ImageStream.
  • If a Deployment (with image trigger) is linked to that ImageStream:
    • βž” OpenShift triggers redeployment automatically!
    • βž” Zero manual work.
    • βž” New app version is live safely.

Final Summary (Easy Language)

Normal images are like pulling files from the internet manually every time.
ImageStreams are like having a smart librarian inside your OpenShift cluster who:

  • Tracks when your images change.
  • Keeps history of all versions.
  • Alerts your applications and triggers updates.
  • Controls who can pull what.

Practical Advantages of ImageStreams

BenefitWhy it matters
Auto-updatesNo need to manually redeploy when a new version is available.
History trackingRollback to any old image version easily.
Environment promotionPromote builds from Dev β†’ QA β†’ Prod by tagging.
Pull secrets and controlManage access securely for private registries.
Cluster registry integrationOpenShift can manage images internally without external dependency.

Real Example

If you’re running CI/CD pipelines in OpenShift (Jenkins, Tekton, GitOps ArgoCD):

  • Build finishes βž” ImageStream updated βž” New Deployment triggered βž” App upgraded automatically.

βœ… No downtime.
βœ… No manual intervention.
βœ… Full visibility on which image you are using.


Very Short Answer

If you wantUse
Simple β€œset and forget” deploysNormal Kubernetes image reference.
Smart, auto-tracked, secure, history-managed image lifecycleOpenShift ImageStreams.

🧠 What Are We Building?

You have three projects (namespaces):

EnvironmentOpenShift Project
Development (Dev)app-dev
Stagingapp-staging
Productionapp-prod

We will:

  • Build or Import an Image into app-dev
  • Promote (copy) the image to app-staging
  • Finally promote it to app-prod
  • All using ImageStreams without rebuilding the app again

βœ… No re-building needed!
βœ… Full traceability!
βœ… Full security control!


πŸ›  Prerequisites:

  • OpenShift CLI (oc) installed
  • Access to an OpenShift 4.x+ cluster
  • admin or sufficient permissions on projects

πŸš€ Step-by-Step Tutorial


1️⃣ Create Three OpenShift Projects

oc new-project app-dev
oc new-project app-staging
oc new-project app-prod

2️⃣ Create ImageStreams in Each Project

Create an ImageStream named myapp in each project.

# myapp-imagestream.yaml
apiVersion: image.openshift.io/v1
kind: ImageStream
metadata:
  name: myapp

Apply in all three projects:

oc project app-dev
oc apply -f myapp-imagestream.yaml

oc project app-staging
oc apply -f myapp-imagestream.yaml

oc project app-prod
oc apply -f myapp-imagestream.yaml

βœ… Now, each project has an empty myapp ImageStream.


3️⃣ Import or Build Image into Dev (First Deployment)

For simplicity, let’s just import a public image (you could also BuildConfig if needed).

oc project app-dev

oc import-image myapp:latest --from=nginx:latest --confirm

βœ… Now, the app-dev project myapp:latest points to the latest nginx image!

You can check:

oc describe is myapp

4️⃣ Create Deployment that Uses ImageStream (optional but recommended)

In Dev, create a Deployment that uses the ImageStream:

# myapp-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
      - name: myapp
        image: image-registry.openshift-image-registry.svc:5000/app-dev/myapp:latest
        ports:
        - containerPort: 80

Apply:

oc apply -f myapp-deployment.yaml

βœ… Dev environment is now running your image!


5️⃣ Promote Image from Dev βž” Staging

Now the magic: Tagging from one project’s ImageStream to another project’s ImageStream.

oc tag app-dev/myapp:latest app-staging/myapp:latest

βœ… This command copies the image reference into app-stagingβ€˜s ImageStream.

Important:

  • No rebuild.
  • No re-pulling from DockerHub.
  • Full OpenShift internal secured movement.

You can verify:

oc project app-staging
oc describe is myapp

You will see that it points to the image from Dev.


6️⃣ Deploy in Staging

Create a Deployment in app-staging, pointing to:

image: image-registry.openshift-image-registry.svc:5000/app-staging/myapp:latest

Now staging runs the exact same image!


7️⃣ Promote Image from Staging βž” Production

Same simple command:

oc tag app-staging/myapp:latest app-prod/myapp:latest

βœ… Now your Production ImageStream is updated with the exact tested image.

Create a Deployment in app-prod using:

image: image-registry.openshift-image-registry.svc:5000/app-prod/myapp:latest

βœ… Production environment runs only after successful promotion from staging!


πŸ”₯ Auto-Promotion Pipeline Idea (Optional)

You can fully automate this using Tekton Pipelines, Jenkins, GitHub Actions, or GitOps (ArgoCD):

  • After tests pass in Dev βž” automatically tag to Staging.
  • After staging approval βž” automatically tag to Production.

βœ… Fully secure.
βœ… CI/CD friendly.
βœ… Traceable images across all stages.


πŸ† Final Architecture Diagram

DockerHub or Build --> app-dev/myapp:latest
                              |
                       oc tag
                              ↓
                     app-staging/myapp:latest
                              |
                       oc tag
                              ↓
                      app-prod/myapp:latest

Each environment runs exactly the promoted image, NOT a rebuilt one. πŸš€


πŸ“‹ Quick Commands Cheat Sheet

CommandPurpose
oc import-image myapp:latest --from=<external-image> --confirmImport image from external registry
oc tag app-dev/myapp:latest app-staging/myapp:latestPromote image from Dev to Staging
oc tag app-staging/myapp:latest app-prod/myapp:latestPromote image from Staging to Prod
oc describe is myappView ImageStream details
oc get istagList image tags

🎯 Real-World Benefits of This Method

BenefitWhy It Matters
No RebuildingPromotes the same built image β€” ensures consistency
Fast and SecureNo need to pull externally again β€” internal registry handles it
Full TraceabilityYou can always check where an image came from
Automation FriendlyEasily integrate with pipelines and GitOps
Safe RollbacksPrevious tags/history available if you want to revert

πŸš€ Conclusion

βœ… ImageStreams make Dev βž” Staging βž” Prod promotions super clean and safe!
βœ… Tagging avoids risks of β€œit works on my machine but fails on prod” issues.
βœ… Production-ready method in OpenShift CI/CD workflows!


Subscribe
Notify of
guest


0 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments

Certification Courses

DevOpsSchool has introduced a series of professional certification courses designed to enhance your skills and expertise in cutting-edge technologies and methodologies. Whether you are aiming to excel in development, security, or operations, these certifications provide a comprehensive learning experience. Explore the following programs:

DevOps Certification, SRE Certification, and DevSecOps Certification by DevOpsSchool

Explore our DevOps Certification, SRE Certification, and DevSecOps Certification programs at DevOpsSchool. Gain the expertise needed to excel in your career with hands-on training and globally recognized certifications.

0
Would love your thoughts, please comment.x
()
x