Docker

Write an awesome doc for Docker, Docker Compose, and everything else in this domain. You can find invaluable examples and explanations here. I am trying to keep it up to date and relevant too. BTW if you also have a cool idea, or example open a PR/issue/discussion.

View on GitHub

Kubernetes

Services

So the name you gave them are similar to the service name we have in a docker compose file where containers can see each other by their service name. So let’s imagine in your code you have something like this in your NodeJS app:

const redis = new Redis("redis://redis:6379")

Then when you are writing your compose file you write:

services:
  backend:
    # ...
  redis: # πŸ‘ˆ This is what I am talking about
    image: redis:7-alpine
    # ...

But in Kubernetes you need to have a service to expose your replicated apps and even internal services cannot see each other unless exposed through a service:

apiVersion: v1
kind: Service
metadata:
  name: redis # πŸ‘ˆ This is what you can then use in your app.
  labels:
    app: redis
spec:
  selector:
    app: redis
  ports:
    - port: 6379
      targetPort: 6379
  type: ClusterIP
And for completeness sake here is how its ```yaml apiVersion: v1 kind: Pod metadata: name: redis-pod labels: app: redis annotations: description: 'Redis instance used by voting app' spec: containers: - name: redis image: redis:7-alpine ports: - containerPort: 6379 name: redis ```

Labels

Kubernetes labels must be short, max 63 chars, just letter and no whitespaces. So in case you wonder then how can you write a description you can always use annotations.

Networking

Kubernetes only manages container orchestration, not connectivity. By default:

You must install a Container Network Interface (CNI) plugin (e.g., Calico, Flannel, Cilium) to enable:

Useful Commands

Delete a group of pods by their label:

kubectl get pods --show-labels
kubectl delete pods -l name=busybox-pod