K8 deployment is failing with "deploymentname" is invalid: spec.template.spec.containers[0].livenessProbe.tcpSocket: Forbidden: may not specify more than 1 handler type

This is very specific scenario and may occur if the livenessProbe is updated and rollback happen due to any failure.
For Example lets say you have configured livenessProbe as below:

            httpGet:
                path:  /healthz
                port: 80

And Later on you have updated the probe as below:

 livenessProbe:
   tcpSocket:
     port: 80

And this was successful Rollout Deployment but lets say some other step failed within workflow(verification etc) and that triggered rollback, later on you decided to re-run the deployment then it may happen that your deployment will start failing in rollout deployment step only giving The Deployment "deploymentname" is invalid: spec.template.spec.containers[0].livenessProbe.tcpSocket: Forbidden: may not specify more than 1 handler type

This is Kubernetes behaviour and if the same sequence is followed you will able to see the same error in k8 also outside Harness and the reason for this is:
The cause of this error is due to change in handler type from httpGet(already one successful execution with httpGet) to tcpSocket and when workflow fails after successful Rollout deployment step then it rollback the previous revision which was with different handler type (httpGet)

So solution for this issue is to change back the handler let the deployment go through and update the handler later on and run the deployment instead of trying to rerun the deployment with updated handler

2 Likes