EX280-mob+web

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/22

encourage image

There's no tags or description

Looks like no tags are added yet.

23 Terms

1
New cards

Configure an HTPasswd identity provider named htpass-ex280 with secret htpass-idp-ex280 and the required users.

Create the password file:

htpasswd -cB htpasswd_file jobs

htpasswd -B htpasswd_file wozniak

htpasswd -B htpasswd_file collins

htpasswd -B htpasswd_file adlerin

htpasswd -B htpasswd_file armstrong

Enter each requested password interactively, or use -b only if exposing passwords in shell history is acceptable.

Create the secret:

oc create secret generic htpass-idp-ex280 \

  --from-file=htpasswd=htpasswd_file \

  -n openshift-config

Configure OAuth:

oc edit oauth cluster

Add an identity provider entry with:

name: htpass-ex280

mappingMethod: claim

type: HTPasswd

htpasswd.fileData.name: htpass-idp-ex280

Verify:

oc get oauth cluster -o yaml

Log in once with each created account.

2
New cards

Configure cluster permissions: jobs is cluster-admin, only wozniak may self-provision projects, wozniak is not a cluster administrator, and remove kubeadmin access.

Grant cluster administration:

oc adm policy add-cluster-role-to-user cluster-admin jobs

Disable project self-provisioning for all authenticated OAuth users:

oc adm policy remove-cluster-role-from-group self-provisioner system:authenticated:oauth

Allow only wozniak to self-provision:

oc adm policy add-cluster-role-to-user self-provisioner wozniak

Confirm wozniak does not have cluster-admin:

oc auth can-i '' '' --as=wozniak --all-namespaces

Remove kubeadmin after verifying another cluster-admin login:

oc delete secret kubeadmin -n kube-system

Verify:

oc auth can-i create project.project.openshift.io --as=wozniak

oc auth can-i create project.project.openshift.io --as=armstrong

3
New cards

Create the apollo, titan, gemini, bluebook, and apache projects, then configure project-level user permissions.

Create the projects:

for p in apollo titan gemini bluebook apache; do

  oc new-project "$p"

done

Make armstrong administrator of apollo and titan:

oc adm policy add-role-to-user admin armstrong -n apollo

oc adm policy add-role-to-user admin armstrong -n titan

Allow collins to view apollo:

oc adm policy add-role-to-user view collins -n apollo

Verify:

oc auth can-i '' '' -n apollo --as=armstrong

oc auth can-i get pods -n apollo --as=collins

oc auth can-i create deployments -n apollo --as=collins

4
New cards

Create commander and pilot groups, assign users, and grant project permissions.

Create groups and membership:

oc adm groups new commander wozniak

oc adm groups new pilot adlerin

Alternatively, create empty groups and add users:

oc adm groups new commander

oc adm groups add-users commander wozniak

oc adm groups new pilot

oc adm groups add-users pilot adlerin

Grant commander edit access:

oc adm policy add-role-to-group edit commander -n apollo

oc adm policy add-role-to-group edit commander -n titan

Grant pilot view-only access to apollo:

oc adm policy add-role-to-group view pilot -n apollo

Verify:

oc get groups

oc auth can-i create deployments -n apollo --as=wozniak

oc auth can-i get pods -n apollo --as=adlerin

oc auth can-i create deployments -n apollo --as=adlerin

5
New cards

Create ResourceQuota ex280-quota in project manhattan with CPU, memory, pod, service, and replication controller limits.

oc create quota ex280-quota \

  --hard=cpu=2,memory=1Gi,pods=3,services=6,replicationcontrollers=3 \

  -n manhattan

Verify:

oc describe resourcequota ex280-quota -n manhattan

oc get resourcequota ex280-quota -n manhattan -o yaml

6
New cards

Create LimitRange ex280-limits in bluebook for Pod and Container CPU and memory constraints.

Create ex280-limits.yaml:

apiVersion: v1

kind: LimitRange

metadata:

  name: ex280-limits

  namespace: bluebook

spec:

  limits:

  • type: Container

  defaultRequest:

    memory: 100Mi

    cpu: 100m

  min:

    memory: 100Mi

    cpu: 10m

  max:

    memory: 300Mi

    cpu: 500m

  • type: Pod

  min:

    memory: 100Mi

    cpu: 10m

  max:

    memory: 300Mi

    cpu: 500m

Apply and verify:

oc apply -f ex280-limits.yaml

oc describe limitrange ex280-limits -n bluebook

7
New cards

Troubleshoot the rocky application in bluewills so it runs with the magic service account and is reachable by route.

oc project bluewills

oc get pods

oc logs pod/

Create the service account and grant anyuid:

oc create serviceaccount magic

oc adm policy add-scc-to-user anyuid -z magic

Assign it to the workload:

oc set serviceaccount deployment/ magic

If a service does not exist:

oc expose deployment/ --port=

Expose the service as a route:

oc expose service/ --hostname=rocky.apps.ocp4.example.com

Verify:

oc get pods,svc,route

curl http://rocky.apps.ocp4.example.com

8
New cards

Create a secure edge route for oxcart in area51 using the supplied certificate and private key.

oc project area51

oc get deployment,service,route

Remove an incorrect existing route if necessary:

oc delete route

Create the edge-terminated route:

oc create route edge \

  --service= \

  --hostname=oxcart.apps.ocp4.example.com \

  --cert= \

  --key=

Verify:

oc get route

curl -k https://oxcart.apps.ocp4.example.com

The certificate subject or SAN must match oxcart.apps.ocp4.example.com.

9
New cards

Scale the hydra application in lerna to five replicas.

oc project lerna

oc scale deployment/hydra --replicas=5

Verify:

oc get deployment hydra

oc get pods

10
New cards

Configure horizontal autoscaling for scala in gru with 6-40 replicas, 60% CPU utilization, 25m CPU request, and 100m CPU limit.

oc project gru

Set resources first, because CPU-based HPA requires a CPU request:

oc set resources deployment/scala \

  --requests=cpu=25m \

  --limits=cpu=100m

Create the HPA:

oc autoscale deployment/scala \

  --min=6 \

  --max=40 \

  --cpu-percent=60

Verify:

oc get hpa

oc describe hpa scala

oc get deployment scala -o jsonpath='{.spec.template.spec.containers[*].resources}'

11
New cards

Create secret magic in the math project with the required Decoder_Ring key and value.

oc create secret generic magic \

  --from-literal=Decoder_Ring='ASDA142hfh-gfrhhueo-erfdk345v' \

  -n math

Verify without printing the decoded secret value:

oc describe secret magic -n math

oc get secret magic -n math -o jsonpath='{.data.Decoder_Ring}' | wc -c

12
New cards

Inject all keys from secret magic as environment variables into the qed application in math.

oc project math

oc set env deployment/qed --from=secret/magic

If the workload is a DeploymentConfig instead:

oc set env dc/qed --from=secret/magic

Verify:

oc set env deployment/qed --list

oc rollout status deployment/qed

oc logs deployment/qed

Confirm that the application no longer reports: App is not configured properly.

13
New cards

Create service account ex-280-sa in apples and allow workloads using it to run with any user ID.

oc project apples

oc create serviceaccount ex-280-sa

oc adm policy add-scc-to-user anyuid -z ex-280-sa

Assign it to the required workload:

oc set serviceaccount deployment/ ex-280-sa

For a DeploymentConfig:

oc set serviceaccount dc/ ex-280-sa

Verify:

oc adm policy who-can use scc anyuid

oc get deployment/ -o jsonpath='{.spec.template.spec.serviceAccountName}'

14
New cards

Repair the oranges application in apples and run it with service account ex-280-sa.

oc project apples

oc get deployment,dc,service,pods

Inspect selector and labels:

oc describe service oranges

oc get deployment oranges -o jsonpath='{.spec.selector}'

If the Service selector is incorrect, edit it so it matches the workload pod labels:

oc edit service/oranges

Assign the service account:

oc set serviceaccount deployment/oranges ex-280-sa

For a DeploymentConfig:

oc set serviceaccount dc/oranges ex-280-sa

Verify:

oc rollout status deployment/oranges

oc get pods,service,endpoints

15
New cards

Troubleshoot an application that cannot schedule because its memory request is unrealistically high.

Select the project and inspect the workload:

oc project

oc get pods

oc describe pod/

oc get events --sort-by=.lastTimestamp

Inspect configured resources:

oc get deployment/ -o yaml

Correct the memory request or limit, for example from 80Gi to 1Gi:

oc set resources deployment/ --requests=memory=1Gi

If it is a DeploymentConfig:

oc set resources dc/ --requests=memory=1Gi

Verify:

oc rollout status deployment/

oc get pods

16
New cards

Troubleshoot an application that cannot schedule because its CPU request is unrealistically high.

Inspect the pod and recent scheduling events:

oc describe pod/

oc get events --sort-by=.lastTimestamp

Inspect resources:

oc get deployment/ -o yaml

Correct the CPU request, for example from 100 cores to 10m:

oc set resources deployment/ --requests=cpu=10m

If it is a DeploymentConfig:

oc set resources dc/ --requests=cpu=10m

Verify:

oc rollout status deployment/

oc get pods

17
New cards

Create a NetworkPolicy in database that permits ingress on TCP 8080 only from checker pods matching namespace label team=devsecops and pod label deployment=web-mysql.

First verify labels:

oc get namespace checker --show-labels

oc get pods -n checker --show-labels

oc get pods -n database --show-labels

Create allow-checker.yaml and set the target podSelector to the actual database pod label:

apiVersion: networking.k8s.io/v1

kind: NetworkPolicy

metadata:

  name: allow-checker

  namespace: database

spec:

  podSelector:

    matchLabels:

      :

  policyTypes:

  • Ingress

ingress:

  • from:

    • namespaceSelector:

      matchLabels:

        team: devsecops

    podSelector:

      matchLabels:

        deployment: web-mysql

  ports:

  • protocol: TCP

    port: 8080

Apply:

oc apply -f allow-checker.yaml

Verify from a matching checker pod:

oc exec -n checker -- curl -sS http://:8080

18
New cards

Deploy a movie-site application from a supplied Helm repository into the target project.

Add and refresh the repository:

helm repo add redhat-movie-repo http://charts.ocp4.example.com/charts/

helm repo update

Find the chart:

helm search repo redhat-movie-repo

Install it:

helm install movie-site redhat-movie-repo/ \

  --namespace \

  --create-namespace

Verify:

helm list -n

helm status movie-site -n

oc get all -n

19
New cards

Configure a TCP liveness probe on port 8080 with initial delay 10 seconds and timeout 30 seconds.

For a Deployment:

oc set probe deployment/atlas \

  --liveness \

  --open-tcp=8080 \

  --initial-delay-seconds=10 \

  --timeout-seconds=30 \

  -n mercury

For a DeploymentConfig:

oc set probe dc/atlas \

  --liveness \

  --open-tcp=8080 \

  --initial-delay-seconds=10 \

  --timeout-seconds=30 \

  -n mercury

Verify:

oc get deployment atlas -n mercury -o yaml

oc describe pod -n mercury -l deployment=atlas

20
New cards

Collect an OpenShift must-gather, archive it with the cluster ID in the filename, and upload it with the supplied script.

Get the cluster ID:

CLUSTER_ID=$(oc get clusterversion version -o jsonpath='{.spec.clusterID}')

Collect diagnostics:

oc adm must-gather

Identify the generated directory:

MG_DIR=$(find . -maxdepth 1 -type d -name 'must-gather.local.*' | head -1)

Create a compressed archive:

tar -cvaf "must-gather.CLUSTERID.tar.gz""{CLUSTER_ID}.tar.gz" "MG_DIR"

Upload with the exam-provided script:

/path/to/uploadscript.sh "must-gather.${CLUSTER_ID}.tar.gz"

Verify:

ls -lh "must-gather.${CLUSTER_ID}.tar.gz"

21
New cards

Create a CronJob from the CLI with a supplied image and schedule, then configure its service account and job history.

Create a service account if required:

oc create serviceaccount -n

Grant only the SCC required by the task. Example for privileged:

oc adm policy add-scc-to-user privileged \

  -z \

  -n

Generate the CronJob manifest:

oc create cronjob \

  --image= \

  --schedule='5 4 2 * *' \

  --dry-run=client \

  -o yaml > cronjob.yaml

Edit cronjob.yaml and set under spec.jobTemplate.spec.template.spec:

serviceAccountName:

Set the requested history field under spec, for example:

successfulJobsHistoryLimit:

Apply and verify:

oc apply -f cronjob.yaml -n

oc get cronjob -n

oc create job --from=cronjob/ test-run -n

22
New cards

Create and configure a custom OpenShift project request template containing a LimitRange.

Generate the default project template:

oc adm create-bootstrap-project-template -o yaml > mytemplate.yaml

Create the required LimitRange separately, then copy its object into the template's objects list. Parameterize it:

metadata:

  name: ${PROJECT_NAME}-limit

  namespace: ${PROJECT_NAME}

Create the template in openshift-config:

oc create -f mytemplate.yaml -n openshift-config

Configure the cluster to use it:

oc patch projects.config.openshift.io cluster \

  --type=merge \

  -p '{"spec":{"projectRequestTemplate":{"name":""}}}'

Verify configuration:

oc get projects.config.openshift.io cluster \

  -o jsonpath='{.spec.projectRequestTemplate.name}{"\n"}'

Test with a non-admin user by requesting a new project, then check that its LimitRange exists:

oc get limitrange -n

23
New cards

Troubleshoot Pending, CrashLoopBackOff, and route-without-endpoints application failures.

  1. Pending pod:

oc describe pod/

oc get events --sort-by=.lastTimestamp

oc get nodes --show-labels

If nodeSelector cannot match any node, correct the workload selector or label the intended node:

oc label node = --overwrite

If resources are insufficient, reduce unrealistic requests/limits:

oc set resources deployment/ --requests=cpu=,memory=

  1. CrashLoopBackOff:

oc logs pod/

oc logs pod/ --previous

If the image requires a non-default UID, create a service account, grant the narrowly required SCC, and assign it:

oc create serviceaccount

oc adm policy add-scc-to-user anyuid -z

oc set serviceaccount deployment/

  1. Route exists but does not work:

oc describe service/

oc get endpoints

oc get deployment/ --show-labels

If endpoints are empty, make the Service selector match the pod labels:

oc edit service/

Final verification:

oc get pods,service,endpoints,route

curl -k https:// #