Keep a container running on Kubernetes

March 22, 2019

This is just an example about how to keep running a pod without exit, this helps to do troubleshooting or test, this approach is not good to use in other cases.

The bellow deployment descriptor keeps running a container with an image from alpine.

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: keep-running
  labels:
    app: keep-running
spec:
  replicas: 1
  selector:
    matchLabels:
      app: keep-running
  template:
    metadata:
      labels:
        app: keep-running
    spec:
      containers:
        - name: keep-running
          image: alpine:3.7
          command: ["sh", "-c", "tail -f /dev/null"]