For instance can I have following yaml to produce a pod with multiple containers:
apiVersion: v1
kind: Pod
metadata:
name: lampapp
labels:
app: app
spec:
containers:
- name: lampdb
image: mysql_test
- name: app
image: php-app-db-url-env
env:
- name: DB_URL
value: 127.0.0.1:3306
- name: app2
image: php-app-db-url-env
env:
- name: DB_URL
value: 127.0.0.1:3306
Yes, you can add multiple container with same image.
The containers object must contain:
unique
within the pod. Cannot be updated.You have to make container name unique
You can do following:
- name: app
image: php-app-db-url-env ---
- name: app2 |> same image
image: php-app-db-url-env ---
But not this one:
- name: app
image: php-app-db-url-env
- name: app
image: <any image>
Also the containers spec should include a unique port number within the Pod
Same of kind of containers can be there but then their port would be different.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With