在 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 命令。
试过 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 文件是错误的还是我遗漏了什么?