OpenShift Patching for adding PVC to a DeploymentConfig

4/22/2021

Hello I'm currently trying to add something to my DC so that it can look like below (Note: volumeMounts and volume elements does not exist yet -

apiVersion: apps/v1beta1
kind: DeploymentConfig
metadata:
  name: postgres
spec:
  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
      - name: postgres
        ...
        volumeMounts:
        - mountPath: /var/lib/postgresql/data
          name: postgres-pv-claim
      volumes:
      - name: postgres-pv-claim
        persistentVolumeClaim:
          claimName: postgres-pv-claim

Note that the postgres-pv-claim elements don't exist and I'm trying to add them via patch. I've tried using something like the following to patch it to no avail -

oc patch dc/postgres --type=json --patch '
[
  { 
    "op": "add",
    "path": "/spec/template/spec/containers/0/volumeMounts",
    "value": [
        {
            "name": "postgres-pv-claim",
            "- mountPath": "/var/lib/postgresql/data"
        }
     ]
  }
]

The error looks as follows -

The DeploymentConfig "postgres" is invalid: 
* spec.template.spec.containers[0].volumeMounts[0].name: Not found: "postgres-pv-claim"
* spec.template.spec.containers[0].volumeMounts[0].mountPath: Required value

Is my path wrong?

-- animusdx
kubernetes
kubernetes-pvc
openshift
yaml

0 Answers