Using “oc patch” command in multi-container Pods

apiVersion: v1
kind: DeploymentConfig
metadata:
name: test-deploy
labels:
app: test-deploy
spec:
replicas: 1
strategy:
type: Rolling
template:
metadata:
labels:
app: test-deploy
name: test-deploy
spec:
containers:
- name: my-first-image
image: image1
ports:
- containerPort: 8080
protocol: TCP
- name: my-second-image
image: image2
env:
- name: JAVA_TOOL_OPTIONS
value: "-Xms768m -Xmx1g"
{ “apiVersion”: “v1”, “kind”: “DeploymentConfig”, “metadata”: { “name”: “test-deploy”, “labels”: { “app”: “test-deploy” } }, “spec”: {“replicas”: 1,“strategy”: {"type": “rolling”},“template”: {“metadata”: {“labels”: {“app”: “test-deploy”}, “name”: “test-deploy”}, “spec”: {“containers”: [{ “name”: “my-first-image”, “image”: “image1”, “ports”: [{ “containerPort”: “8080”, “protocol”: “TCP”}] }, { “name”: “my-second-image”, “image”: “image2”, “env”: [{ “name”: “JAVA_TOOL_OPTIONS”, “value”: “\"-Xms768m -Xmx1g\"” }] }] } }
    oc create -f my-dc.yml
      - name: my-second-image
image: image2
env:
- name: JAVA_TOOL_OPTIONS
value: "-Xms768m -Xmx1g"
ports:
- containerPort: 9090
protocol: TCP
oc patch dc test-deploy -p '{"spec": {"template": {"spec": {"containers": [{"name": "my-second-image","ports": [{"containerPort": 9090,"protocol": "TCP"}]}]}}}}'
oc patch dc test-deploy -p '{"spec": {"template": {"spec": {"containers": [{"name": "my-second-image","env": [{"name": "JAVA_TOOL_OPTIONS","value": “\"-Xms821m -Xmx1g\"”}]}]}}}}'

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Sachin Kadam

Sachin Kadam

2 Followers

DevOps Engineer, Working at Mahindra Comviva. Docker-Kubernetes enthusiast.