Question 31

SIMULATION
Given an existing Pod named nginx-pod running in the namespace test-system, fetch the service-account-name used and put the content in /candidate/KSC00124.txt Create a new Role named dev-test-role in the namespace test-system, which can perform update operations, on resources of type namespaces.
Create a new RoleBinding named dev-test-role-binding, which binds the newly created Role to the Pod's ServiceAccount ( found in the Nginx pod running in namespace test-system).
  • Question 32

    SIMULATION
    Before Making any changes build the Dockerfile with tag base:v1
    Now Analyze and edit the given Dockerfile(based on ubuntu 16:04)
    Fixing two instructions present in the file, Check from Security Aspect and Reduce Size point of view.
    Dockerfile:
    FROM ubuntu:latest
    RUN apt-get update -y
    RUN apt install nginx -y
    COPY entrypoint.sh /
    RUN useradd ubuntu
    ENTRYPOINT ["/entrypoint.sh"]
    USER ubuntu
    entrypoint.sh
    #!/bin/bash
    echo "Hello from CKS"
    After fixing the Dockerfile, build the docker-image with the tag base:v2 To Verify: Check the size of the image before and after the build.
  • Question 33

    You can switch the cluster/configuration context using the following command: [desk@cli] $ kubectl config use-context stage Context: A PodSecurityPolicy shall prevent the creation of privileged Pods in a specific namespace. Task: 1. Create a new PodSecurityPolcy named deny-policy, which prevents the creation of privileged Pods. 2. Create a new ClusterRole name deny-access-role, which uses the newly created PodSecurityPolicy deny-policy. 3. Create a new ServiceAccount named psd-denial-sa in the existing namespace development. Finally, create a new ClusterRoleBindind named restrict-access-bind, which binds the newly created ClusterRole deny-access-role to the newly created ServiceAccount psp-denial-sa

    Question 34

    Context
    A default-deny NetworkPolicy avoids to accidentally expose a Pod in a namespace that doesn't have any other NetworkPolicy defined.
    Task
    Create a new default-deny NetworkPolicy named defaultdeny in the namespace testing for all traffic of type Egress.
    The new NetworkPolicy must deny all Egress traffic in the namespace testing.
    Apply the newly created default-deny NetworkPolicy to all Pods running in namespace testing.

    Question 35

    Context: Cluster: gvisor Master node: master1 Worker node: worker1
    You can switch the cluster/configuration context using the following command:
    [desk@cli] $ kubectl config use-context gvisor
    Context: This cluster has been prepared to support runtime handler, runsc as well as traditional one.
    Task: Create a RuntimeClass named not-trusted using the prepared runtime handler names runsc. Update all Pods in the namespace server to run on newruntime.