【问题标题】:Kubernetes jenkins deployment api version no matchesKubernetes jenkins 部署 api 版本不匹配
【发布时间】:2019-02-03 23:27:33
【问题描述】:

如果我从本地计算机上传以下部署文件,则它可以正常工作。

kind: Deployment
apiVersion: apps/v1
metadata:
  name: api
  namespace: app
spec:
  replicas: 2
  selector:
    matchLabels:
      run: api
  template:
    metadata:
      labels:
        run: api
    spec:
      containers:
      - name: api
        image: gcr.io/myproject/api:1535462260754
        ports:
        - containerPort: 8080
        readinessProbe:
          httpGet:
            path: /_ah/health
            port: 8080
          initialDelaySeconds: 10
          periodSeconds: 5

在运行 Jenkins 的远程 Compute Engine 机器上也是如此。在这台机器上,通过 ssh 我也可以应用这个配置。在 Jenkins shell 下执行它总是抛出

error: unable to recognize "./dist/cluster/api.deployment.yaml": no matches for kind "Deployment" in version "apps/v1"

我尝试将apiVersion 更改为apps/v1beta1extensions/v1beta1。 不知道还能尝试什么。

更新 1

Compute Engine 上的 kubectl 版本:

Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.2", GitCommit:"bb9ffb1654d4a729bb4cec18ff0 88eacc153c239", GitTreeState:"clean", BuildDate:"2018-08-07T23:17:28Z", GoVersion:"go1.10.3", Compiler:"gc", Pla tform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"9+", GitVersion:"v1.9.7-gke.5", GitCommit:"9b635efce81582e1da13b3 5a7aa539c0ccb32987", GitTreeState:"clean", BuildDate:"2018-08-02T23:42:40Z", GoVersion:"go1.9.3b4", Compiler:"gc ", Platform:"linux/amd64"}

更新 2

在 Jenkins 内运行显示此作业。

Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.2", GitCommit:"bb9ffb1654d4a729bb4cec18ff088eacc153c239", GitTreeState:"clean", BuildDate:"2018-08-07T23:17:28Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}
Error from server (Forbidden): <html><head><meta http-equiv='refresh' content='1;url=/securityRealm/commenceLogin?from=%2Fversion%3Ftimeout%3D32s'/><script>window.location.replace('/securityRealm/commenceLogin?from=%2Fversion%3Ftimeout%3D32s');</script></head><body style='background-color:white; color:white;'>


Authentication required
<!--
You are authenticated as: anonymous
Groups that you are in:

Permission you need to have (but didn't): hudson.model.Hudson.Read
... which is implied by: hudson.security.Permission.GenericRead
... which is implied by: hudson.model.Hudson.Administer
-->

</body></html>

【问题讨论】:

  • 你的 kubernetes 版本是多少?
  • @NitishKumar,我更新了问题。

标签: jenkins deployment kubernetes google-cloud-platform google-compute-engine


【解决方案1】:

您的 Jenkins 服务器或代理中的 kubectl 版本可能是旧的。尝试从 Jenkins 作业中运行 kubectl version 以检查不匹配。

【讨论】:

  • 其实你已经很接近了。我已经用更新 2 更新了问题。
【解决方案2】:

感谢 @csanchez 我发现我需要在 jenkins 用户下获取凭据。为此,我只运行了这个命令:

gcloud container clusters get-credentials cluster-1 --zone=my-cluster-zone --project myproject

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-01-18
    • 2020-03-01
    • 1970-01-01
    • 2021-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多