Skip to main content

Launch Your First OpenShift Operator

Hands-On Lab

 

Photo of

Training Architect

Length

01:30:00

Difficulty

Intermediate

You have been tasked with creating a Prometheus operator using only CLI in a three-node OpenShift cluster running OKD v3.11.0. Using the templates provided in the examples, launch a two-node Prometheus operator.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Launch Your First OpenShift Operator

Introduction

You have been tasked with creating a Prometheus operator using only CLI in a three-node OpenShift cluster running OKD v3.11.0. Using the templates provided in the examples, launch a two-node Prometheus operator.

Solution

Log in to the lab server using the credentials provided:

ssh cloud_user@<PUBLIC IP ADDRESS>

If you'd like to see the templates we'll use in the lab, they're in the lab's GitHub repo.

Create a New Namespace

  1. To make sure the environment is ready, run:

    oc get pods -n 
      operator-lifecycle-manager

    If you see a status of Running, it's ready.

  2. Create a new namespace named operation:

    oc new-project operation
  3. Make sure the GitHub repo has been cloned:

    ls

    We should see content-deploy-an-operator.

Subscribe to the Prometheus Operator

  1. Open the operator-sub.yml file:

    vim content-deploy-an-operator/prometheus-operator/operator-sub.yml
  2. Change the namespace to operation, and then save and quit the file.

  3. Using the operator-sub.yml object definition, subscribe the operation namespace to the Prometheus Operator:

    oc create -f content-deploy-an-operator/prometheus-operator/operator-sub.yml
  4. Verify it was created:

    oc get subscription

Create a Two-Node Prometheus Operator

  1. Open the prometheus-example.yml file:

    vim content-deploy-an-operator/prometheus-operator/prometheus-example.yml
  2. Update the namespace for prometheus-example to operation, and save and quit the file.

  3. Create the operator using prometheus-example.yml:

    oc create -f content-deploy-an-operator/prometheus-operator/prometheus-example.yml
  4. Watch the build:

    watch oc get pods

Conclusion

Congratulations on successfully completing this hands-on lab!