Kubernetes 与版本 "extensions/v1beta1" 中的种类"Deployment"不匹配



我正在尝试使用 Jenkins 在 Kubernetes 中部署下一个 frontend-deployment.yaml,但我遇到了下一个错误:

[frontend] Running shell script
+ kubectl apply -f IKonnekt/frontend-deployment.yaml
error: unable to recognize "IKonnekt/frontend-deployment.yaml": no matches for kind "Deployment" in version "extensions/v1beta1"

如果我从 Kubernetes 集群内的机器上运行kubectl apply -f IKonnekt/frontend-deployment.yaml,它可以正常工作。

Kubernetes Client Version: 1.12.1
Kubernetes Server Version: 1.11.0

这是我的前端部署.yaml:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: ikonnekt-frontend-deployment
spec:
replicas: 1
template:
metadata:
labels:
app: ikonnekt-frontend
spec:
containers:
- name: ikonnekt-frontend
image: ikonnektfrontend
imagePullPolicy: Always
env:
- name: REACT_APP_API
value: "http://IP:Port"
- name: REACT_APP_AUTH_ENDPOINT
value: "http://IP:Port/auth"
ports:
- containerPort: 80
imagePullSecrets:
- name: regcred

只需将apiVersion更改为以下内容:apiVersion: apps/v1

我的问题是因为在 Jenkinsfile 中我使用的是 Kubernetes 仪表板 URL 而不是 Kubernetes API URL,所以 Jenkins 的 kubectl 无法识别 kubernetes 服务器。

所以最后,使用 API URL 并更新 apiVersion 它对我有用。

最新更新