带 Helm 的Gitlab代理:错误:无法访问Kubernetes群集:获取“http://localhost:8080/版本”:拨号tcp [::1]:8080:连接:连接被拒绝

5tmbdcev  于 2022-12-17  发布在  Kubernetes
关注(0)|答案(1)|浏览(511)

我为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更新..但出现了相同的错误...

ymdaylpp

ymdaylpp1#

我也遇到过同样的问题,首先在helm和kubectl中使用image(例如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

相关问题