Can we create a POD from two existing Yamls each having their own container?

1/21/2020

My project have 2 Yamls to create which create 2 PODS each. Can we create a single POD with these yamls, without merging the yamls, with 2 containers ?

Thanks

-- Chandu
containers
kubernetes
pod

2 Answers

1/21/2020

If you don't want to merge the containers definition in the same file and in the same containers block, then no you can't.

-- Marc ABOUCHACRA
Source: StackOverflow

1/21/2020

Yes, you run multiple containers inside the single pod. In single YAML manifest, you can add your both containers spec and run it.

however, you cannot without merging YAML you can not run multiple containers inside one pod.

for single file example :

apiVersion: v1
kind: Pod
metadata:
  name: mc1
  spec:
    volumes:
    - name: html
      emptyDir: {}
    containers:
    - name: 1st
      image: nginx
      volumeMounts:
      - name: html
        mountPath: /usr/share/nginx/html
    - name: 2nd
      image: debian
      volumeMounts:
      - name: html
        mountPath: /html
      command: ["/bin/sh", "-c"]
      args:
        - while true; do
            date >> /html/index.html;
            sleep 1;
          done

more details you can also refer official document : https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/

-- Harsh Manvar
Source: StackOverflow