kubernetes - 无法正确创建部署

sli*_*wp2 5 kubernetes

我创建了一个deployment.yaml来创建 kubernetes 的部署。

这是我的尝试:

apiVersion: apps/v1

得到 error: unable to recognize "./slate-master/deployment.yaml": no matches for kind "Deployment" in version "apps/v1"

apiVersion: extensions/v1beta1apiVersion: apps/v1beta1

他们两个,得到 Error from server (BadRequest): error when creating "./slate-master/deployment.yaml": Deployment in version "v1beta1" cannot be handled as a Deployment: v1beta1.Deployment: ...

这是我的 kubernetes 版本:

Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.2", GitCommit:"81753b10df112992bf51bbc2c2f85208aad78335", GitTreeState:"clean", BuildDate:"2018-05-12T04:12:12Z", GoVersion:"go1.9.6", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"8", GitVersion:"v1.8.7", GitCommit:"b30876a5539f09684ff9fde266fda10b37738c9c", GitTreeState:"clean", BuildDate:"2018-01-16T21:52:38Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}
Run Code Online (Sandbox Code Playgroud)

那么,为什么 kubernetes create 部署失败呢?

小智 7

检查“env”部分,对于 apiVersion:

apps/v1
apps/v1beta1
apps/v1beta2
Run Code Online (Sandbox Code Playgroud)

所有的环境变量都应该是一个字符串,添加quote:例如

- name: POSTGRES_PORT
  value: {{ .Values.db.env.POSTGRES_PORT | quote }}
Run Code Online (Sandbox Code Playgroud)


sur*_*ren 6

更改apiVersion: apps/v1方式:

apiVersion: extensions/v1beta1
Run Code Online (Sandbox Code Playgroud)

  • 我发现我的 `deployment.yaml` 文件中存在语法错误。`env` 值必须是字符串,不能是数字 (2认同)