Pods & Deployments Flashcards
What’s a POD in kubernetes ?
The smallest deployable unit in the Kubernetes object model.
Can we run container in kubernetes directly or outside the POD ?
No, containers always deployed within the POD.
Which object in Kubernetes act as “environment” for containers ?
PODS
Which properties of a POD are shared by containers within the POD?
Each container in a POD can share:
1. IP address
2. CPU
3. Memory
4. Storage
Which object in Kubernetes is required to scale PODS horizontally ?
POD replica sets
Does Kubernetes modifies/change a POD if it goes unhealthy ?
No, PODs are immutable. Kubernetes always replaces an un-healthy POD with healthy one, but never revives it.
What are replicas ?
Replicas are copies or clones of a pod. It is the way to horizontally scale a POD.
Does a sidecar container and main container within a POD can have same PORT ?
NO.
If there are more than one container inside a POD, then they must have different PORTS.
What is one-container-per-pod approach ?
This says, each POD can contain only one container. This is the standard approach in any production environment.
Can we span a single POD across nodes ?
NO.
A POD can only lie within a NODE due to limitation of IP address allocation.
What is imperative vs declarative way of creating any resource in Kubernetes?
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 to created a POD using imperative command?
> > > kubectl run [podName] –image=nginx:alpine
What’s the command to show all pods running in cluster?
> > > kubectl get pods
How to retrieve all resources running in a cluster?
> > > kubectl get all
Can we access POD IP address outside the cluster ?
NO.
It is accessible within the cluster.
How to access a POD’s port outside the cluster ?
> > > kubectl port-forward [podName] [external-port]:[internal-port]
What is a YAML ?
YAML is just a text file with only Maps and Lists. It always uses “spaces” and No TABS.
Can we create a key in YAML inside double quote ?
No, Key cannot be inside double quote
What is the “casing” convention for “kind” values in Kubernetes manifests ?
The object Name must be started with “capital character”.
Create a POD manifest.
> > > apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
spec:
containers:
- name: nginx-pod
image: nginx:alpine
What is the command to delete a pod ?
kubectl delete pod [pod-name]
How to delete the pod, if we have created same via manifest file ?
kubectl delete -f file.pod.yml
How to get inside a pod already running in the cluster ?
> > > kubectl exec [pod-name] -it sh
What are Probes in kubernetes?
A Probe is nothing but the “diagnostic” performed periodically by “Kubelet”.