在kubernetes集群中部署yaml文件时遇到错误的请求错误。
Error from server (BadRequest): error when creating "deployment.yaml": service in version "v1" cannot be handled as a Service: no kind "service" is registered for version "v1" in scheme "k8s.io/kubernetes/pkg/api/legacyscheme/scheme.go:29"
Error from server (BadRequest): error when creating "deployment.yaml": deployment in version "v1" cannot be handled as a Deployment: no kind "deployment" is registered for version "apps/v1" in scheme "k8s.io/kubernetes/pkg/api/legacyscheme/scheme.go:29"
kubernetes集群是带有2个节点池的1.14.7版。一个是带有linux节点的默认节点池,另一个是Windows容器的Windows节点池(节点计数1)。我要在门户网站本身中登录Azure CLI,然后运行kubectl命令。
尝试了apiVersion:apps / v1beta1,但效果不佳。
kubectl version
Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.0", GitCommit:"2bd9643cee5b3b3a5ecbd3af49d09018f0773c77", GitTreeState:"clean", BuildDate:"2019-09-18T14:36:53Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.6", GitCommit:"96fac5cd13a5dc064f7d9f4f23030a6aeface6cc", GitTreeState:"clean", BuildDate:"2019-08-19T11:05:16Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}
这是deployment.yaml文件
apiVersion: v1
kind: Service
metadata:
name: sampleapp
labels:
app: sampleapp
spec:
type: LoadBalancer
ports:
- name: proxy
protocol: TCP
port: 9163
targetPort: 9163
- name: banyan
protocol: TCP
port: 23010
targetPort: 23010
selector:
app: sampleapp
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: sampleapp
labels:
app: sampleapp
spec:
replicas: 1
template:
metadata:
labels:
app: sampleapp
spec:
nodeSelector:
"beta.kubernetes.io/os": windows
imagePullSecrets:
- name: docker-secret
containers:
- name: proxyservice
image: docker.azurecr.io/proxyservice:326
ports:
- containerPort: 9163
env:
- name: sup_hostname
value: "xac-dev-docker4.eastus.cloudapp.azure.com"
- name: syncservice
image: docker.azurecr.io/syncservice:326
ports:
- containerPort: 23010
env:
- name: broker_hostname
value: ""
selector:
matchLabels:
app: sampleapp
预期结果应该是部署了yaml文件。
不确定这是否与文件缩进有关。 yaml文件是否错误或我缺少什么?
答案 0 :(得分:1)
如错误描述中所述,问题与部署YAML的版本兼容性有关。
no kind "service" is registered for version "v1"
这意味着部署类型yaml的 apiVersion:v1 中提到的版本 v1 的Kubernetes API无法识别资源类型 service >
尝试
此问题的解决方案是在部署YAML中使用适当的apiVersion。 enter link description here
这里有一些参考。
客户端-服务器版本不匹配
还值得一提的是客户端和服务器kubernetes版本之间的版本不匹配。 Kubernetes通过1个次要版本支持master落后于客户端的兼容性,但实际上不建议这样做。由于您的版本相距2个次要版本,因此我建议使服务器至少与客户端的版本匹配。