Kubernetes Flashcards
container runtime
a k8s component, the underlying software that is used to run containers, e.g. docker
pod is what of k8s
k8s object
to see each pod’s node
kubectl get po -o wide
create yml of pod quickly
kubectl run redis –image=redis123 –dry-run=client -o yaml
edit pod
- use existing yml
- extract into yml and recreate pod
- k edit only for below properties
spec.containers[].image
spec.initContainers[].image
spec.activeDeadlineSeconds
spec.tolerations
spec.terminationGracePeriodSeconds
spec.replica
Replica Set (prev. replication controller)
difference of above two?
- high availability
- load balancer across nodes
selector: use to allow for managing pod that not created by replicaSet directly
edit replicaset
k replace -f xxx.yml
k scale –replicas=6 -f rs-definition.yml
k scale –replicas=6 replicaset my-rs
get version of a k object
k explain replicaset
quick delete multiple pods
in a line: k delete po po1 po2 po3 po4
deployment vs rs
deployment contains replicaset, rs contains pod
–all-namespaces
–label
short -A
-l=”tier=db”
Cert Tip: Imperative Command
Run an instance of the image webapp-color and publish port 8080 on the container to 8282 on the host.
docker run -p 8282:8080 webapp-color
light version docker image
python:3.6-alpine on alpine not debian
Practice test Docker images
answer is missing
docker ps vs docker ps -a
-a list all containers including the stopped ones
container automatically exit when its task/process is done, which is defined by “CMD”. The process has to be things like web server, db server but not “bash”
docker run ubuntu
will exit but
docker run ubuntu [cmd]
docker run ubuntu sleep 5 will lasts for 5 secs
or:
CMD sleep 5
CMD [“sleep”, “5”]
or:
ENTRYPOINT [“sleep”]
docker run ubuntu-sleeper 10
or:
ENTRYPOINT [“sleep”]
CMD [“5”] -> default value
or: modify during runtime
docker run –entrypoint sleep2.0 ubuntu-sleeper 10
k replace –force -f x.yml
replace pods
docker run –name ubuntu-container –entrypoint sleep2.0 ubuntu-sleeper 10 in pod definition
command:
args: [“10”]
imperative vs declarative
k create configmap
k create -f xxx.yml
convert base64
echo -n ‘paswrd’ | base64
echo -n ‘paswrd’ | base64 –decode
ubuntu install
apt-get install
list processes on docker host / inside container
security context
ps aux
PID for different containers on the host are different -> process isolation
by default process run as root, but root user inside container is not like it on the host
change root’s capability,
docker run –add-cap MAC_ADMIN
or –drop-cap
–privilege
get user inside pod
k exec po po-name – whoami