Part 1 Flashcards

1
Q

Question 1: Creating Single Container Pods Create a pod with the name of kplabs-nginx. The pod should be launched from an image of mykplabs/kubernetes:nginx . The name of the container should be mycontainer

A

apiVersion: v1

kind: Pod

metadata:

name: kplabs-nginx
namespace: default

labels:

env: test

spec:

containers:

  • name: mycontainer
    image: mykplabs/kubernetes:nginx
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Create a Multi-Container POD with the name of kplabs-multi-container

There should be 3 containers as part of the pod. Name the first container as first-container, 2nd container as second-containerand 3rd container as third-container

1st container should be launched from nginx image, second container should be launched from mykplabs/kubernetes:nginx image and third container from busybox image.

Connect to the first-container and run the following command: apt-get update && apt-get install net-tools

Connect to the third-container and identify the ports in which processes are listening. Perform wget command on those ports and check if you can download the HTML page.

A

apiVersion: v1

kind: Pod

metadata:

name: kplabs-multi-container
namespace: default

labels:

env: test

spec:

containers:

  • name: first-container
    image: nginx
  • name: second-container
    image: mykplabs/kubernetes:nginx
  • name: third-container
    image: busybox

command:

  • sleep
  • “3600”

kubectl exec -it kplabs-multi-container bash

netstat -ntlp kubectl exec -it kplabs-multi-container -c third-container sh

wget http://localhost:80

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Create a pod with the name of kplabs-cmdargs. The pod should be launched from an image of busybox . The name of the container should be cmdcontainer. Both the container image’s CMD and ENTRYPOINT instruction should be overridden.

The container should start with sleep command and argument of 3600

A

apiVersion: v1

kind: Pod

metadata:

name: kplabs-cmdargs
namespace: default

labels:

env: test

spec:

containers:

  • name: cmdcontainer
    image: busybox
    command: [“sleep”]
    args: [“3600”]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Create a pod with the name of kplabs-ports. The pod should be launched from an image of nginx. The name of the container should be nginx. Expose Port 80 for the POD.

A

apiVersion: v1

kind: Pod

metadata:

name: kplabs-ports
namespace: default

labels:

env: test

spec:

containers:

  • name: nginx
    image: nginx

apiVersion: v1

kind: Service

metadata:

name: nginx

labels:

run: nginx

spec:

ports:

  • port: 80
    protocol: TCP

selector:

run: nginx

kubectl exec -it kplabs-ports -c nginx sh

apt-get update && apt-get install net-tools

kubectl port-forward pods/kplabs-ports 8888:80

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

CLI Documentation

  1. List down all the available fields and it’s associated description that we can include in a POD Manifest. Store data to pod.txt
  2. List down all the fields & it’s description that we can add under the metadata section under POD manifest. Store data to pod-manifest.txt
  3. Matthew has realized that there is an option for tolerationSeconds under POD -> Spec -> Tolerations. Store the associated documentation for tolerationSeconds and store it under a file named tolerationSeconds.txt
A

kubectl explain pod >pod.txt

kubectl explain pod.spec > pod-manifest.txt

kubectl explain pod.spec.tolerations > tolerationSeconds.txt

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Arguments

Create a pod named kplabs-logging

The Pod should have a container running from the nginx image with the following arguments:


    • /bin/sh
    • -c
    • >
  1. i=0;
  2. while true;
  3. do
  4. echo “$i: $(date)” >> /var/log/1.log;
  5. echo “$(date) INFO $i” >> /var/log/2.log;
  6. i=$((i+1));
  7. sleep 1;
  8. done

Once POD is created, connect to the POD and verify the contents of /var/log/1.log and /var/log/2.log

A

apiVersion: v1

kind: Pod

metadata:

name: kplabs-logging
namespace: default

labels:

env: test

spec:

containers:

  • name: nginx
    image: nginx

args :

  • /bin/sh
  • -c
  • >

i=0;

while true;

do

echo “$i: $(date)” >> /var/log/1.log;

echo “$(date) INFO $i” >> /var/log/2.log;

i=$((i+1));

sleep 1;

done

kubectl exec -it kplabs-logging -c nginx sh

cat /var/log/1.log

kubectl delete pod kplabs-logging

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

POD Troubleshooting

  1. Create a POD with the name kplabs-troubleshoot. Launch it from busybox image.
  2. Once launch, verify if you can see pod in “Ready” state.
  3. If it’s not in ready state, find out what can be the reason.
  4. Edit the POD manifest to make sure busybox pod is available for at-least next 10 minutes.
A

apiVersion: v1

kind: Pod

metadata:

name: kplabs-cmdargs
namespace: default

labels:

env: test

spec:

containers:

  • name: cmdcontainer
    image: busybox
    command: [“sleep”]
    args: [“3600”]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

API Primitives

  1. Create a proxy connection via kubectl proxy --port 8080
  2. Verify from browser if you are able to see the list all the Kubernetes API’s.
  3. Find the list of resources under the /api/v1
  4. Find the list of all the PODS running within your Kubernetes environment,
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

kubectrl describe

A

kubectrl describe pods

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

kubectrl explain

A

kubectrl explain pod

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

kubectl run –help

A

kubectl run –help ( scroll up to see examples)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly