Google Kubernetes Engine: Error on Health Check

3/12/2018

I'm receiving the following error when attempting to upload my health-check.yaml file:

error: error validating "health-check.yaml": error validating data: [ValidationError(Deployment.spec): unknown field "containers" in io.k8s.api.extensions.v1beta1.DeploymentSpec, ValidationError(Deployment.spec): missing required field "template" in io.k8s.api.extensions.v1beta1.DeploymentSpec]; if you choose to ignore these errors, turn validation off with --validate=false

health-check.yaml:

apiVersion: extensions/v1beta1 kind: Deployment metadata: name: nginx spec: containers: - name: nginx livenessProbe: httpGet: path: / port: 80

Please help! :)

-- Nick Parsons
google-cloud-platform
google-kubernetes-engine
kubernetes

1 Answer

3/12/2018

Containers should be specified under spec -> template -> spec. e.g.:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: ...
spec:
  selector:
    matchLabels:
      ...
  template:
    spec:
      containers:
      - command: ...
        image: ...
        name: ...
        livenessProbe:
          httpGet:
              path: /live

There are 2 specs here, one for the deployment (because you are using kind: Deployment) and the nested one for the contained pods.

-- fips
Source: StackOverflow