简体   繁体   English

使用deployment.yaml文件进行部署

[英]Deployment with deployment.yaml file

I have a deployment file that goes through CircleCI for kubernetes that just won't go through no matter what. 我有一个通过CircleCI的kubernetes部署文件,无论如何都不会通过。 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 这是我的deployment.yaml包含的内容: 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: CCI配置的“部署”部分:

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! 我肯定知道env是一个数组而不是一个字符串,所以我不确定为什么会这样,请帮助! Thanks! 谢谢!

The yaml looks valid when pasting it in http://www.yamllint.com/ . 将该Yaml粘贴到http://www.yamllint.com/时,它看起来是有效的。 Check if something is adding characters or breaking the indentations with the way are using kubectl in CircleCI. 使用kubectl中的kubectl检查是否有字符正在添加字符或打破缩进。

So I ended up figuring it out. 所以我最终弄清楚了。 For some reason CircleCI was checking my code against the master branch (Which was behind). 由于某种原因,CircleCI会对照master分支检查我的代码(哪个在后面)。 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. 当我通过另一个更新较新的分支进入CCI时,它仍然不喜欢我的master分支在env插槽中有一个字符串。 As soon as I updated that everything worked. 我更新后,一切正常。 Thanks guys! 多谢你们!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM