【问题标题】:Connect kubernetes with Jenkins pipeline将 Kubernetes 与 Jenkins 管道连接起来
【发布时间】:2020-12-25 19:52:00
【问题描述】:

我正在尝试使用 Jenkins 管道中的 helm 部署容器。我已经为 jenkins 安装了 Kubernetes 插件,并为其提供了本地运行的 kubernetes URL 和凭据中的配置文件。当我在做'Test connection' 时,它显示'Connected to Kubernetes 1.16+'

但是当我从管道运行 helm install 命令时,它给出了错误

Error: Kubernetes cluster unreachable: the server could not find the requested resource

注意:我可以使用 CLI 和 Jenkins 管道执行所有操作,方法是使用 withCredentials 并传递 cred 文件变量名(在 jenkins 凭据中创建)。我只想这样做而不将其包装在 'withCredentials' 中。

Jenkins 和 kubernetes 都在 Windows 10 上单独运行。请帮助

【问题讨论】:

  • 您使用的是哪个版本的helm?您可以分享您尝试过的完整 helm 命令吗?
  • @Bimal helm install app-name charts-dir -n nsname --set image=imagename --set nodePort=31200

标签: jenkins kubernetes kubernetes-helm multibranch-pipeline


【解决方案1】:

Helm 使用 kubectl 配置文件。我正在使用这样的步骤。

steps {
        container('helm') {
          withCredentials([file(credentialsId: 'project-credentials', variable: 'PULL_KEYFILE')]) {
            sh """
            gcloud auth activate-service-account --key-file=${PULL_KEYFILE} --project project-name
            gcloud container clusters get-credentials cluster-name --zone us-east1
            kubectl create namespace ${NAMESPACE} --dry-run -o yaml | kubectl apply -f -
            """
            helm upgrade --install release-name .
          }
        }
      }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-09-03
    • 2017-05-23
    • 1970-01-01
    • 2018-01-29
    • 2019-01-17
    • 2021-12-09
    • 2021-09-20
    • 2021-04-20
    相关资源
    最近更新 更多