Deployment with deployment.yaml file

7/18/2018

I have a deployment file that goes through CircleCI for kubernetes that just won't go through no matter what. This is what my deployment.yaml contains: kind: Deployment apiVersion: extensions/v1beta1 metadata: name: usage-metrics namespace: foo labels: foo-app: usage-metrics spec: replicas: 1 selector: matchLabels: foo-app: usage-metrics template: metadata: labels: foo-app: usage-metrics name: usage-metrics spec: terminationGracePeriodSeconds: 60 imagePullSecrets: - name: regsecret containers: - image: foo/usage-metrics name: app env: - name: TEMP_ENV_VAR value: "temp" ports: - containerPort: 8080

For some reason, I keep getting this error when I push it through:

"STDIN": error validating data: [ValidationError(Deployment.spec.template.spec.containers[0].env): invalid type for io.k8s.api.core.v1.Container.env: got "string", expected "array", ValidationError(Deployment.spec.template.spec): unknown field "ports" in io.k8s.api.core.v1.PodSpec]

Deploy section of CCI config:

echo ":: deploying to $CONTEXT" export CLUSTER_ID=$CONTEXT cd $SOURCE_PATH kd \ --context $CONTEXT \ --namespace foo \ --ssh-host deploy@bastion.$CTL_CONTEXT \ --timeout 8m \ --images "app=$(cat new-tag)" \ --file deployment.yaml

I know for sure that env is an array and not a string so I'm not sure why this is happening, Please help! Thanks!

-- Ahmad Al-Bassyiouni
continuous-deployment
kubernetes
yaml

2 Answers

7/18/2018

So I ended up figuring it out. For some reason CircleCI was checking my code against the master branch (Which was behind). While I was pushing into CCI through another branch that was more updated, it still didn't like that my master branch had a string in the env slot. As soon as I updated that everything worked. Thanks guys!

-- Ahmad Al-Bassyiouni
Source: StackOverflow

7/18/2018

The yaml looks valid when pasting it in http://www.yamllint.com/ . Check if something is adding characters or breaking the indentations with the way are using kubectl in CircleCI.

-- Cryptophobia
Source: StackOverflow