Dependencies specified in the first #kubernetes post – link at the bottom of this page. Onward!

Logs and self-healing properties

See the logs of a running pod:

kubectl logs db --follow

Kill the pod:

kubectl exec -it db pkill mongod

But it automatically restarts!

kubectl get pods

Multiple containers in a pod

A pod is a collection of containers that share the same resources. Not much more. Everything else should be accomplished with higher-level constructs.

Most of the scenarios where you might think that multi-container Pod is a good solution will probably be solved through other resources.

We can spin up pods with multiple containers:

kubectl create -f pod/go-demo-2.yml

We can get very specific information about a pod, for example the name of all of its containers (jsonpath docs)

kubectl get -f pod/go-demo-2.yml --output jsonpath="{.spec.containers[*].name}"

We can still see the logs, but, with multiple containers in a pod, should be specific:

kubectl logs go-demo-2 --container api

Same goes for one-off commands:

kubectl exec -it go-demo-2 -c api <command>

Healthchecks

We can specify livenessProbe (using a command or HTTP request) and readynessProbe for pods.

livenessProbes check whether the service is alive, and readynessProbes check whether a service is ready to serve requests; to avoid cascading failures, Colin Breck recommends we check a pod’s dependencies’ health in readynessProbes, but not in livenessProbes.