ERROR: ERROR: io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: POST at: https://192.168.16.129:6443/apis/apps/v1/namespaces/jx/deployments. Message: the API version in the data (extensions/v1beta1) does not match the expected API version (apps/v1). Received status: Status(apiVersion=v1, code=400, details=null, kind=Status, message=the API version in the data (extensions/v1beta1) does not match the expected API version (apps/v1), metadata=ListMeta(_continue=null, resourceVersion=null, selfLink=null, additionalProperties={}), reason=BadRequest, status=Failure, additionalProperties={}). hudson.remoting.ProxyException: io.fabric8.kubernetes.client.KubernetesClientException: Failure executing: POST at: https://192.168.16.129:6443/apis/apps/v1/namespaces/jx/deployments. Message: the API version in the data (extensions/v1beta1) does not match the expected API version (apps/v1). Received status: Status(apiVersion=v1, code=400, details=null, kind=Status, message=the API version in the data (extensions/v1beta1) does not match the expected API version (apps/v1), metadata=ListMeta(_continue=null, resourceVersion=null, selfLink=null, additionalProperties={}), reason=BadRequest, status=Failure, additionalProperties={}).
Jenkins构建项目,报这个错是因为api接口版本与deploy的yaml版本不一致导致,解决方案如下
-
upgrade apiVersion of the deployment to
apps/v1 升级Deployment的apiVersion至apps/v1
spec.selector
must match.spec.template.metadata.labels
inapps/v1 spec.selector必须与容器模板的labels匹配的上
参考官方:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
所有评论(0)