Pods & Deployments Flashcards

1
Q

What’s a POD in kubernetes ?

A

The smallest deployable unit in the Kubernetes object model.

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

Can we run container in kubernetes directly or outside the POD ?

A

No, containers always deployed within the POD.

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

Which object in Kubernetes act as “environment” for containers ?

A

PODS

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

Which properties of a POD are shared by containers within the POD?

A

Each container in a POD can share:
1. IP address
2. CPU
3. Memory
4. Storage

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

Which object in Kubernetes is required to scale PODS horizontally ?

A

POD replica sets

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

Does Kubernetes modifies/change a POD if it goes unhealthy ?

A

No, PODs are immutable. Kubernetes always replaces an un-healthy POD with healthy one, but never revives it.

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

What are replicas ?

A

Replicas are copies or clones of a pod. It is the way to horizontally scale a POD.

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

Does a sidecar container and main container within a POD can have same PORT ?

A

NO.
If there are more than one container inside a POD, then they must have different PORTS.

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

What is one-container-per-pod approach ?

A

This says, each POD can contain only one container. This is the standard approach in any production environment.

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

Can we span a single POD across nodes ?

A

NO.
A POD can only lie within a NODE due to limitation of IP address allocation.

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

What is imperative vs declarative way of creating any resource in Kubernetes?

A

In “imperative” way, a programmer calls all the APIs exposed by the kubernetes to create and manage the resource.
In “declarative” way, a programmer just declare the state of the resource in an YAML and the rest is being done by Kubernetes.

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

How to created a POD using imperative command?

A

> > > kubectl run [podName] –image=nginx:alpine

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

What’s the command to show all pods running in cluster?

A

> > > kubectl get pods

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

How to retrieve all resources running in a cluster?

A

> > > kubectl get all

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

Can we access POD IP address outside the cluster ?

A

NO.
It is accessible within the cluster.

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

How to access a POD’s port outside the cluster ?

A

> > > kubectl port-forward [podName] [external-port]:[internal-port]

17
Q

What is a YAML ?

A

YAML is just a text file with only Maps and Lists. It always uses “spaces” and No TABS.

18
Q

Can we create a key in YAML inside double quote ?

A

No, Key cannot be inside double quote

19
Q

What is the “casing” convention for “kind” values in Kubernetes manifests ?

A

The object Name must be started with “capital character”.

20
Q

Create a POD manifest.

A

> > > apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
spec:
containers:
- name: nginx-pod
image: nginx:alpine

21
Q

What is the command to delete a pod ?

A

kubectl delete pod [pod-name]

22
Q

How to delete the pod, if we have created same via manifest file ?

A

kubectl delete -f file.pod.yml

23
Q

How to get inside a pod already running in the cluster ?

A

> > > kubectl exec [pod-name] -it sh

24
Q

What are Probes in kubernetes?

A

A Probe is nothing but the “diagnostic” performed periodically by “Kubelet”.

25
Q

What are the different types of Probes used by Kubernetes to determine the health of a container ?

A
  1. Liveness Probe
  2. Readiness Probe
26
Q

What’s a Liveness Probe ?

A

The Liveness Probe determines when should a container “restarts”

27
Q

What’s a Readiness Probe ?

A

The Readiness Prod determines when should a container starts receiving the traffic.

28
Q

How Kubernetes determines the health of a POD ?

A

By performing some actions on the POD. These actions can be:
1. ExecAction
2. TCPSocketAction
3. HTTPGetAction

29
Q

How kubernetes determines the health of a POD which is running only CLI based services ?

A

It runs a “ExecAction” on the POD.
If POD returns a “0” status, it means it is healthy.

30
Q

How kubernetes determines the health of a POD which is NOT running any service?

A

It can run a “TCPSocketAction” on the POD.
It checks against the container’s IP address against a PORT.

31
Q

How kubernetes determines the health of a POD which is running a REST service ?

A

It can run a “HTTPGetAction” on the POD.
If POD returns “200 ok”, it means it is healthy.

32
Q

What are the different status a PROBE can have ?

A
  1. success
  2. failure
  3. unknown
33
Q

Where should we put the “liveness” or “readiness” probes configs in our Manifest file?

A

The Probes are part of “containers”. It should be provided in containers specification.

34
Q

Write manifest file with Readiness Probe.

A

apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
spec:
containers:
- name: nginx-pod
image: nginx:alpine
readinessProbe:
httpGet:
path: /index.html
port: 80
initialDealySeconds: 2
periodSeconds: 5

35
Q

What does a POD do, if a underlying container fails?

A

It removes the container and create a new one. (restarts the container)

36
Q
A