adding a new port to an existing deployment kubernetes adding a new port to an existing deployment kubernetes kubernetes kubernetes

adding a new port to an existing deployment kubernetes


You can edit the deployment and make the changes or patch the deployment using kubectl patch command.

To edit the deployment use the below command

kubectl edit deployment <depoloyment-name> -oyaml

add the changes and save the file.


as you can see I added a new port definition 443 to the yaml file, but when saving it says

k8sadmin@k8s-master-34239724-0:~$ kubectl edit deployment wordpress -oyamlerror: deployments.extensions "wordpress" is invalidA copy of your changes has been stored to "/tmp/kubectl-edit-dtzxq.yaml"error: Edit cancelled, no valid changes were saved.

Here is the definition

creationTimestamp: 2019-11-18T12:27:57Z generation: 1 labels: app: wordpress name: wordpress namespace: default resourceVersion: "233695" selfLink: /apis/extensions/v1beta1/namespaces/default/deployments/wordpress uid: da5a75cf-09fe-11ea-bfe8-001dd8b70024spec: progressDeadlineSeconds: 600 replicas: 1 revisionHistoryLimit: 10 selector: matchLabels: app: wordpress tier: frontend strategy: type: Recreate template: metadata: creationTimestamp: null labels: app: wordpress tier: frontend spec: containers: - env: - name: WORDPRESS_DB_HOST value: wordpress-mysql - name: WORDPRESS_DB_PASSWORD valueFrom: secretKeyRef: key: password name: mysql-pass image: wordpress:4.8-apache imagePullPolicy: IfNotPresent name: wordpress ports: - containerPort: 80 name: wordpress protocol: TCP - containerPort: 443 name: wordpress443 protocol: TCP resources: {} terminationMessagePath: /dev/termination-log terminationMessagePolicy: File volumeMounts: