Kubernetes Pod how to specify two images for a pod

11/12/2020

Create a pod name kucc4 with a single app container for each of the following images running inside ( there may be between 1 and 4 images specified ) : nginx+redis

-- mahesh singh
kubernetes

1 Answer

11/12/2020

I think you might want to run multiple containers in a pod with one container using nginx and the other one using redis.

follow the below sample and replace debian with redis

apiVersion: v1
kind: Pod
metadata:
  name: two-containers
spec:

  restartPolicy: Never

  volumes:
  - name: shared-data
    emptyDir: {}

  containers:

  - name: nginx-container
    image: nginx
    volumeMounts:
    - name: shared-data
      mountPath: /usr/share/nginx/html

  - name: debian-container
    image: debian
    volumeMounts:
    - name: shared-data
      mountPath: /pod-data
    command: ["/bin/sh"]
    args: ["-c", "echo Hello from the debian container > /pod-data/index.html"]
-- P Ekambaram
Source: StackOverflow