(extensions/v1beta1) does not match the expected API version (apps/v1).

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版本不一致致使,解決方案以下nginx

  • upgrade apiVersion of the deployment to apps/v1 升級Deployment的apiVersion至apps/v1api

  • spec.selector must match .spec.template.metadata.labels in apps/v1  spec.selector必須與容器模板的labels匹配的上

參考官方:app

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
相關文章
相關標籤/搜索