在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群集的版本为1.14.7,具有2个节点池。一个是具有Linux节点的默认节点池,另一个是用于Windows容器的Windows节点池(节点计数为1)。我正在登录到门户本身内的Azure CLI,并运行kubectl命令。
尝试api版本:apps/v1 beta1但不好。
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"}
下面是部署.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文件错了还是我遗漏了什么?
1条答案
按热度按时间qij5mzcb1#
如错误描述中所述,问题与部署YAML的版本兼容性有关。
第一个月
这意味着版本为v1的Kubernetes API无法识别资源类型service,如部署yaml的apiVersion:第1版
试试看
此问题的解决方案是在部署YAML. enter link description here中使用适当的apiVersion
以下是一些参考资料。
另外值得一提的是客户端和服务器kubernetes版本之间的版本不匹配。kubernetes支持主版本比客户端低一个次要版本的兼容性,但不推荐这样做。由于你们的版本相差2个次要版本,我建议最后让服务器与客户端的版本匹配。
Reference - https://github.com/kubernetes/community/blob/master/contributors/design-proposals/release/versioning.md#supported-releases-and-component-skew