【问题标题】:Gitlab-agent with Helm: Error: Kubernetes cluster unreachable: Get "http://localhost:8080/version": dial tcp [::1]:8080: connect: connection refused带有 Helm 的 Gitlab 代理:错误:Kubernetes 集群无法访问:获取 \"http://localhost:8080/version\": dial tcp [::1]:8080: connect: connection refused
【发布时间】:2022-12-17 00:00:11
【问题描述】:

我为 kubernetes 集群安装了新的 gitlab 代理。这在我使用 KUBECTL 时有效,当我尝试使用 Helm 图表在 Azure Cloud 中部署时出现此错误。

我的 .gitlab-ci.yml

  variables:
  #registry variable
  REGISTRY: registry.gitlab.com
  #docker-image tag
  DOCKER_IMAGE_TAG: ${CI_COMMIT_SHA}
  #target variable
  TARGET: metrix9/wysiwys-ic

stages:
- build
- package
- deploy


#job to build gradle application and save the jar file in artifacts
build docker image:
  image: gradle
  stage: build
  before_script:
  - chmod +x ./gradlew
  script:
  - ./gradlew jib -Djib.to.auth.username=$CI_REGISTRY_USER -Djib.to.auth.password=$CI_REGISTRY_PASSWORD -Djib.from.auth.username=$CI_REGISTRY_USER -Djib.from.auth.password=$CI_REGISTRY_PASSWORD


# job to push file-server docker-imagedocker 
package wysiwys image:
  stage: package
  image: docker.io/library/docker
  #dependencies: 
  #  - build
  services:
  - name: docker:dind
  before_script:
  - IMAGE=${CI_REGISTRY}/${TARGET}
  - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
  - docker pull "${IMAGE}:latest" || true
  script:
  #- docker build --tag "${IMAGE}:latest" .
  - docker push "${IMAGE}:latest"
#job to package and push the file-server helm chart
package wysiwys-ic helm:
  stage: package
  image: 
    name: alpine/helm
    entrypoint: [""]
  before_script:
  - helm repo add --username $CI_REGISTRY_USER --password $CI_REGISTRY_PASSWORD  wysiwys-ci-repo https://gitlab.com/api/v4/projects/$CI_PROJECT_ID/packages/helm/stable
  - helm plugin install https://github.com/chartmuseum/helm-push
  script:
  - helm package wysiwys-helm
  - helm cm-push ./wysiwys-helm-0.1.0.tgz  wysiwys-ci-repo

#job to install convert2pdf with helm chart
install wysiwys-ic:
  stage: deploy
  image: 
    name: alpine/helm
    entrypoint: [""]
  before_script:
  - helm repo add bitnami https://charts.bitnami.com/bitnami -n Convert2pdf-repo
  script:
  - helm upgrade --install wysiwys-ci ./wysiwys-helm 

gitlab agent:

我尝试导出 KUBECONFIG 并在管道中运行 helm repo update .. 但是出现了同样的错误......

【问题讨论】:

    标签: kubernetes gitlab continuous-integration helm3


    【解决方案1】:

    我正在为同样的问题而苦苦挣扎。首先使用带有 helm 和 kubectl 的图像(f.e. registry.gitlab.com/gitlab-org/cluster-integration/cluster-applications)并尝试在部署部分添加以下更改:

    deploy app:
     stage: deploy-app
     variables:
      KUBE_CONTEXT: -->gitlabproject<--:-->name of the installed agent<--
     before_script:
      - if [ -n "$KUBE_CONTEXT" ]; then kubectl config use-context "$KUBE_CONTEXT"; fi
    

    【讨论】:

      猜你喜欢
      • 2020-11-13
      • 2016-04-18
      • 2022-12-30
      • 1970-01-01
      • 2023-01-10
      • 1970-01-01
      • 2015-09-06
      • 2017-10-08
      • 2011-02-20
      相关资源
      最近更新 更多