Controlling Pod Scheduling Flashcards

1
Q

As the admin user, label two nodes with the tier label. Give the master01 node the label of tier=gold and the master02 node the label of tier=silver.

A
  1. Log in to your OpenShift cluster as the admin user.
    $ oc login -u admin -p redhat \
    > https://api.ocp4.example.com:6443
  2. Identify if any nodes already use the tier label.
    $ oc get nodes -L tier
  3. Label the master01 node with the label tier=gold.
    $ oc label node master01 tier=gold
  4. Label the master02 node with the label tier=silver.
    $ oc label node master02 tier=silver
  5. Confirm that the labels have been added correctly.
    $ oc get nodes -L tier
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Switch to the developer user and create a new project named schedule-review.

A
  1. Log in to your OpenShift cluster as the developer user.
    $ oc login -u developer -p developer
  2. Create the schedule-review project.
    $ oc new-project schedule-review
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Create a new application named loadtest using the container image located at quay.io/redhattraining/loadtest:v1.0. The loadtest application should be deployed to nodes labeled with tier=silver. Ensure that each container requests 100m of CPU and 20Mi of memory.

A
  1. In order to make the upcoming adjustments easier, create a deployment resource file without actually creating the application.
    $ oc create deployment loadtest –dry-run=client \
    > –image quay.io/redhattraining/loadtest:v1.0 \
    > -o yaml > ~/DO280/labs/schedule-review/loadtest.yaml
  2. Edit ~/DO280/labs/schedule-review/loadtest.yaml to specify a node selector. Add the highlighted lines listed below and ensure that you have proper indentation.
    $ vim ~/DO280/labs/schedule-review/loadtest.yaml
...output omitted...
    spec:
      nodeSelector:
        tier: silver
      containers:
      - image: quay.io/redhattraining/loadtest:v1.0
        name: loadtest
        resources: {}
status: {}
3. Continue editing ~/DO280/labs/schedule-review/loadtest.yaml. Replace the resources: {} line with the highlighted lines listed below. Ensure that you have proper indentation before saving the file. 
...output omitted...
    spec:
      nodeSelector:
        tier: silver
      containers:
      - image: quay.io/redhattraining/loadtest:v1.0
        name: loadtest
        resources:
          requests:
            cpu: "100m"
            memory: 20Mi
status: {}
4.  Create the loadtest application. 
$ oc create --save-config \
>    -f ~/DO280/labs/schedule-review/loadtest.yaml
5.  Verify that your application pod is running. You might need to run the oc get pods command multiple times. 
$ oc get pods
6.  Verify that your application pod specifies resource requests. 
$ oc describe pod/loadtest-85f7669897-z4mq7 \
>    | grep -A2 Requests
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Create a route to your application named loadtest using the default (automatically generated) host name. Depending on how you created your application, you might need to create a service before creating the route. Your application works as expected if running curl http://loadtest-schedule-review.apps.ocp4.example.com/api/loadtest/v1/healthz returns {“health”:”ok”}.

A
  1. Create a service by exposing the deployment for the loadtest application.
    $ oc expose deployment/loadtest \
    > –port 80 –target-port 8080
  2. Create a route named loadtest by exposing the loadtest service.
    $ oc expose service/loadtest –name loadtest
  3. Identify the host name created by the loadtest route.
    $ oc get route/loadtest
  4. Verify access to the loadtest application using the host name identified in the previous step.
    $ curl http://loadtest-schedule-review.\
    > apps.ocp4.example.com/api/loadtest/v1/healthz
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Create a horizontal pod autoscaler named loadtest for the loadtest application that will scale from 2 pods to a maximum of 40 pods if CPU load exceeds 70%. You can test the horizontal pod autoscaler with the following command: curl -X GET http://loadtest-schedule-review.apps.ocp4.example.com/api/loadtest/v1/cpu/3

A
  1. Create the horizontal pod autoscaler for the loadtest application.
    $ oc autoscale deployment/loadtest –name loadtest \
    > –min 2 –max 40 –cpu-percent 70
    2a. Wait until the loadtest horizontal pod autoscaler reports default usage in the TARGETS column.
    $ watch oc get hpa/loadtest
    2b. Press Ctrl+C to exit the watch command after changes to 0%.
    oc get hpa/loadtest
  2. Test the horizontal pod autoscaler by applying CPU load. Use the previously identified host name for the loadtest route. Wait for the curl command to complete.
    $ curl -X GET http://loadtest-schedule-review.\
    > apps.ocp4.example.com/api/loadtest/v1/cpu/3
  3. Verify that additional pods have been added. You might need to run the oc get hpa/loadtest command multiple times. Your output will likely differ, but check that the replica count is greater than 2.
    $ oc get hpa/loadtest
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

As the admin user, implement a quota named review-quota on the schedule-review project. Limit the schedule-review project to a maximum of 1 full CPU, 2G of memory, and 20 pods.

A
  1. Log in to your OpenShift cluster as the admin user.
    $ oc login -u admin -p redhat
  2. Create the resource quota.
    $ oc create quota review-quota \
    > –hard cpu=”1”,memory=”2G”,pods=”20”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly