Skip to content
Tutorials Center
My learning

Topics

Lesson 37 of 37 ยท Projects and Practice

Practice: oc Command Drills and Scenarios for OpenShift

Test yourself with OpenShift scenarios on routes, SCCs, RBAC, storage, quotas, troubleshooting and updates, plus a runnable drill that checks your answers against model solutions.

Reading about oc is not the same as typing it under pressure. This lesson gives you drills in the style of an admin or developer exam: each scenario describes a situation, you write the command or object you would use, and then compare with a model answer. The practice engine below is a Python stand-in that normalizes your command and checks that the required parts are present, so you can try different valid spellings.

You need no cluster: the point is to recall the right tool. If you have a practice cluster, run the commands to confirm them.

How the drill works

Each task has a short scenario and a list of required fragments. An answer passes when it contains every fragment, ignoring extra spaces and order of flags. Try it with the sample answers, then replace them with your own.

Python Stand-in: command drill checker

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Scenario set 1: networking

  1. Users get "Application is not available" for shop.example.com. List the first three checks. Route admitted, service endpoints not empty, route targetPort equals a service port.
  2. A route must accept HTTPS only for clients holding certificates verified by the pod. Passthrough.
  3. Internal admin pages must be reachable only on an internal domain. A second IngressController with routeSelector, label the route.
  4. After a deny-all NetworkPolicy the route breaks. Allow ingress from namespaces labeled network.openshift.io/policy-group: ingress.

Review: routes, TLS, Ingress controllers, network policies.

Scenario set 2: security

  1. An image logs permission denied when writing /data as a random UID. Make the directory group 0 writable, keep restricted-v2.
  2. Find which SCC admitted a pod. oc get pod NAME -o jsonpath on the openshift.io/scc annotation.
  3. A CI pipeline deploys to one project only. Dedicated service account, edit role binding in that project, token from oc create token.
  4. Who can delete pods in project shop? oc adm policy who-can delete pods -n shop.
  5. Pods cannot pull from a private registry. oc create secret docker-registry, then oc secrets link default NAME --for=pull.

Review: SCCs, RBAC, service accounts and secrets.

Scenario set 3: storage, scaling and quotas

  1. A PVC stays Pending. Check storage class exists/default, access mode supported, oc describe pvc events.
  2. Database data must survive claim deletion. Reclaim policy Retain on the PV before deleting.
  3. HPA shows <unknown> targets. Set CPU requests; verify the metrics API with oc adm top pods.
  4. Pod creation fails: "must specify limits.memory". Add a LimitRange with defaults or set limits.
  5. Two teams share a budget of 40 CPUs across many projects. ClusterResourceQuota with a label selector.

Review: PVs and PVCs, storage classes, autoscaling, quotas.

Scenario set 4: operations

  1. A pod restarts every minute with exit code 137. OOMKilled: raise the memory limit or fix the leak.
  2. Many apps fail at once. oc get clusteroperators, oc get nodes, oc describe node, check for degraded operators and node pressure.
  3. An update has stalled with one worker SchedulingDisabled. A PodDisruptionBudget blocking drain, oc get pdb -A.
  4. An alert must fire only when more than 5% of requests fail for 10 minutes. PrometheusRule with for: 10m.
  5. You need to install a database operator but approve every upgrade by hand. Subscription with installPlanApproval: Manual.

Review: monitoring, troubleshooting, updates, operators.

Build your own cheat sheet

A good cheat sheet is organized by question, not by command. This helper prints a small lookup you can extend with every command you learn.

Python Stand-in: searchable cheat sheet

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

What next

You now have the full path: building and running apps, networking, security, storage, scaling and operating a cluster. To go deeper, practice on a free developer sandbox or OpenShift Local, rebuild the three-tier project from memory, and read the official documentation for the version you run, since menu names and defaults shift between releases.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which command shows the logs of the container that just crashed?

    --previous returns logs of the prior container instance.
  2. 2. How do you let a CI service account deploy to a single project?

    Least privilege means one account, one project, the edit role.
  3. 3. An update stalls on a worker that will not drain. What is a likely cause?

    A PDB with zero allowed disruptions blocks eviction.
  4. 4. What is the best way to prepare for an exam-style task?

    Typing the commands builds the recall you need under time pressure.

Summary

  • Practice by scenario: situation, command, check.
  • The same layers recur: route, service, pod, policy, SCC, RBAC, storage, quota.
  • Troubleshoot from the outside in and from events to logs.
  • Keep your own question-driven cheat sheet.
  • Rebuild the three-tier project from memory to cement everything.

Next: Back to the OpenShift track