I have a deployment running one pod consisting of an unique container. The deployment is currently up & running, and I want to modify its pod template to add a port to the container.
Here are the currently defined ports:
$ kubectl get deployment -o yaml spark-master | yq -r -y '.spec.template.spec.containers[] | select(.name=="spark-master").ports'
- containerPort: 7077
protocol: TCP
- containerPort: 8080
protocol: TCP
Here is the patch I tried to add port 6066
:
$ kubectl patch deployment spark-master -p '{"op": "add", "path": "/spec/template/spec/containers/0/ports/-", "value": {"containerPort": 6066}}'
deployment "spark-master" not patched
$ kubectl get deployment -o yaml spark-master | yq -r -y '.spec.template.spec.containers[] | select(.name=="spark-master").ports'
- containerPort: 7077
protocol: TCP
- containerPort: 8080
protocol: TCP
...no success.
Another attempt, this time specifying the port protocol:
$ kubectl patch deployment spark-master -p '{"op": "add", "path": "/spec/template/spec/containers/0/ports/-", "value": {"containerPort": 6066, "protocol": "TCP"}}'
deployment "spark-master" not patched
$ kubectl get deployment -o yaml spark-master | yq -r -y '.spec.template.spec.containers[] | select(.name=="spark-master").ports'
- containerPort: 7077
protocol: TCP
- containerPort: 8080
protocol: TCP
...still no success.
$ kubectl version
Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.4", GitCommit:"bee2d1505c4fe820744d26d41ecd3fdd4a3d6546", GitTreeState:"clean", BuildDate:"2018-03-12T16:29:47Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"9+", GitVersion:"v1.9.7-gke.3", GitCommit:"9b5b719c5f295c99de68ffb5b63101b0e0175376", GitTreeState:"clean", BuildDate:"2018-05-31T18:32:23Z", GoVersion:"go1.9.3b4", Compiler:"gc", Platform:"linux/amd64"}