I have created a Kubernetes deployment with pods defined by a template. I need to update the pod definition to include readiness and liveliness probes because the template doesn't allow the creation of these probes as far as I can tell. Any ideas?
The problem with the deployment is that it won't let me add in probe definitions. If I use a probe definition like the following:
apiVersion: apps/v1
kind: Deployment
metadata:
name: <appdeployment>
labels:
app: <appname>
spec:
replicas: 3
selector:
matchLabels:
app: <appname>
template:
metadata:
labels:
app: <appname>
spec:
containers:
- image: "registry.hub.docker.com/imagename"
name: <appname>-image
readinessProbe:
httpGet:
path: /healthz
port: 80
initialDelaySeconds: 90
periodSeconds: 5
failureThreshold: 20
ports:
- containerPort: 80
protocol: TCP
resources:
requests:
cpu: 1000m
limits:
cpu: 4000m
It fails with error: error parsing .yaml: error converting YAML to JSON: yaml: line 22: found character that cannot start any token
That line is the definition of the readiness probe.
Thanks to all that offered. You can't save me from myself. It was an illegal character that was introduced from my cut and paste from Textpad and was in the whitespace. I should have checked that first. Sorry for the bother.
you can use:
kubectl edit deploy <deployment name> --namespace <namespace name>
and do that inline
You can use the command kubectl edit deployment deploymentname -n namespacename
which will open up an editor where you can edit the yaml to add readiness probe and liveness probe and saving it will directly apply the changes to the cluster.
Alternatively you can use kubectl get deployment deploymentname -n namespacename -o yaml > deployment.yaml
to save the deployment in yaml file and edit it to add readiness probe and liveness probe and then kubectl apply -f deployment.yaml
to deploy the changes to the cluster.