Skip to content

Instantly share code, notes, and snippets.

@ghulevishal
Last active March 15, 2019 06:03
Show Gist options
  • Save ghulevishal/d34d6e518347d8991b472872f606e756 to your computer and use it in GitHub Desktop.
Save ghulevishal/d34d6e518347d8991b472872f606e756 to your computer and use it in GitHub Desktop.

1.Core Concept

Q1. Create a Multi-container Pod with name multi-c-pod, which contains containers from following images :-

  • image1 : nginx:alpine
  • image2 : redis
  • image3 : memcached

You can have container names, as per your choice.

Q2. Create a Namespace with name mynamespace using YAML. Create a Pod with name mypod using nginx:alpine image, inside this mynamespace namespace.

Q3. Create a Replicaset using the YAML file.

  • image : nginx:alpine
  • name : nginx-rs
  • label : app=ckad
  • replicas : 3

Q4. Create 2 pods as follow and perform Set Based Requirement Label selector operations given below and save all the commands and the outputs to ~/label.txt.

  • A. Create a Pod with name prod-pod

    • image : nginx:alpine
    • name : prod-pod
    • label : environment=production,tier=frontend
  • B. Create a Pod with name dev-pod

    • image : nginx:alpine
    • name : dev-pod
    • label : environment=dev,tier=backend
  • C. List the Pods using Set Based Requirement Label selector for following conditions:

    • List the pods which exist in production environment.
    • List the Pods which does not exist in production environment.
    • List he Pods which does not exist in qa environment.

Q5.Create a Daemonset using the YAML file.

  • image : nginx:alpine
  • name : nginx-ds
  • label : app=ds-app
  • nodeselector: disk=ssd

2.Application Managements

Q1. Create a simple job which will write “Hello world” for 50 times with 5 parallelism.

Q2. Create a Deployment using the YAML file

  • image : nginx:alpine
  • name : nginx-deploy
  • label : app=web
  • replicas : 3

Q3. Scale the Deployment nginx-deploy to 5 replicas.

Q4. Update the image for Pods in Deployment nginx-deploy to nginx:stable . Save rollout history to ~/rollout.txt

Q5. Create Pod with name healthy-pod and configure the readiness and liveness probe for it. Use following configuration while creating the pods.

  • name: healthy-pod

  • image: nginx

  • Liveness Probe

    • initial delay for liveness probe: 5 seconds
    • timeout for liveness probe: 1 second
    • kubelet should perform a liveness probe every 3 seconds
    • maximum restarts: 5
  • Liveness Probe

    • initial delay for readiness probe: 5 seconds
    • timeout for readiness probe: 1 second
    • kubelet should perform a readiness probe every 3 seconds
    • maximum restarts: 7

3.Storage

Q1. Create Persistent Volume with name mypv Using YAML such that:

  • name: mypv
  • size: 5gb
  • volumedriver: Hostpath
  • Retain policy: recycle

Q2. Create Persistent Volume Claim with name mypvc which consume Persistent Volume mypv Using YAML such that:

  • name: mypvc
  • size: 2gb

Q3. Create a Pod with name mypvpod from ubuntu image, which will mount the Persistent Volume Claim mypvc at mount path /data such that:

  • name: mypvpod
  • image: ubuntu
  • PVC: mypvc
  • mountpath: /data

Q4. Create a Pod named non-persistent-redis from redis image that have a volume with name app-cache , and mountpath will be /data/redis. It should launch in the staging namespace and the volume MUST NOT be persistent.

4.Scheduling

Q1. Create Pod name init-demo which have one init container with name init-ctr which will write a file and another container with name app-ctr will check whether that file is exist or not. You can choose any container images of your choice for creating the init container and container.

Q2. Create a Secret with name mysecret using YAML, which consists the following data.

  • USERNAME: cloudyuga
  • PASSWORD: CloudyugaCKA

Q3. Create a Pod with name mysecretpod which will be consuming the secret mysecret as enviorment variable TOPSECRETUSERNAME will have value of USERNAME and enviorment variable TOPSECRETPASSWORD will have value of PASSWORD. You can use any image of your choice for creating pod.

Q4. Create a Namespace test-quota such that

  • Put memory limits of 256Mi on the namespace.
  • Limit pods to 2 persistent volumes in this namespace.
  • Run a pod with name test-pod in the test-quota namespace with resource request and limit which satisfy the resource quota. You can use image of your choice to create the pod.

5.Networking

Q1. Create an Deployment with name deploy-app and create service for that deployment svc-app. Deploy Ingress controller and create Ingress resource app-ing such that app.example.com resolve to service svc-app.

  • name of Deployment: deploy-app
  • image: nginx:alpine
  • labels: app=nginx-deploy
  • replicas: 3
  • name of Service: svc-app
  • name of ingress object: app-ing

Q2. Create a Deployment with name nginx-deploy-test using YAML.

  • name of Deployment: nginx-deploy
  • image: nginx:alpine
  • labels: app=nginx-deploy
  • replicas: 4

Q3. Create a Service for the Deployment nginx-deploy-test using YAML such that:

  • name of Service: nginx-svc
  • type of service: NodePort
  • NodePort: 31089

Q4. Create a Pod with name test and ClusterIP service with name test-svc for accessing this test pod using YAML:

  • Pod configuration:

    • Name of Pod: test
    • image: nginx
    • labels: app=test-app
  • Service Configuration:

    • Name of service: test-svc
    • service type: ClusterIP

Q5: Get the DNS records for test Pod and test-svc service. and store it at ~/testpod.txt and ~/testsvc.txt respectively.

6.Security

Q1. Create a Namespace with name demo in this namespace create Pod with namedemo. Create a Namespace with name test in this namespace create Pod with nametest. Create a Network Policy in such way that It should allow traffic to the demo pod only from test pod running in test namespace. You can use any image of your choice to create the pods.

Q2. Creare a namespace called secure, in that namespace create Pod with name sec-pod which is running with UID 2000 and GID 2000. You can use any image of your choice to create the pods.

Q3. Create a new Namespace called demo-sa. In that demo-sa Namespace create Service Account with name demo using YAML. Now in the Namespace demo-sa, create a Pod demo-pod using YAML as following configuration:

  • name: demo-pod
  • namespace: demo-ns
  • serviceaccount: demo
  • image: nginx:alpine
  • lable: app=demo-app

7-Logging-Monitoring

Q1. Create a Pod with name log-pod such that it continuously echo the current time after interval of 2 seconds. You can use any image of your choice to create the pod.

Q2.Get the logs of pod log-pod and write down in file called ~/logs.txt

8-Cluster-Maintenance

Q1. Create a static pod with name stat-pod and use image nginx:alpine by keeping manifest in /etc/kubernetes/manifests.

Q2. Take the back up of ETCD at /opt/baks/etcd0001/.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment