[英]The connection to the server rancher.xxx.xxx was refused - did you specify the right host or port?
[英]Gitlab CI/CD - the connection to the server localhost:8080 was refused - did you specify the right host or port?
我構建了一個 spring 引導項目,我想使用 GitLab CI/CD 將其部署到 minikube。 我可以通過從本地機器直接訪問 deployment.yml 來部署應用程序。
但是當我嘗試從 GitLab 部署它時出現以下錯誤。
錯誤
$ kubectl apply -f deployment.yml
The connection to the server localhost:8080 was refused - did you specify the right host or port?
Cleaning up project directory and file based variables
ERROR: Job failed: exit code 1
部署.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: user-management
spec:
# the target number of Pods
replicas: 2
selector:
matchLabels:
app: user-management
template:
metadata:
labels:
app: user-management
spec:
containers:
- name: user-management7
image: registry.gitlab.com/PROFILE_NAME/user-management
imagePullPolicy: Always
ports:
- containerPort: 8082
imagePullSecrets:
- name: registry.gitlab.com
.gitlab-ci.yml
image: docker:latest
services:
- docker:dind
- mysql:8
variables:
DOCKER_DRIVER: overlay
SPRING_PROFILES_ACTIVE: gitlab-ci
stages:
- build
- package
- test
- deploy-tb
- deploy-prod
maven-build:
image: maven:3-jdk-8
stage: build
script: "mvn package -B"
artifacts:
paths:
- target/*.jar
docker-build:
stage: package
script:
- docker build -t registry.gitlab.com/PROFILE_NAME/user-management .
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN registry.gitlab.com
- docker push registry.gitlab.com/PROFILE_NAME/user-management
test:
image: maven:3-jdk-8
services:
- mysql:8
script:
- "mvn clean test"
artifacts:
when: always
reports:
junit:
- target/surefire-reports/TEST-*.xml
deploy-tb:
image:
name: bitnami/kubectl:latest
entrypoint: [ "" ]
stage: deploy-tb
script:
- kubectl apply -f deployment.yml
environment:
name: prod
url: registry.gitlab.com/PROFILE_NAME/user-management
我不知道我在這里錯過了什么。
根據 GitLab 文檔,您需要首先安裝 Kubernetes 的GitLab 代理。
這些是安裝過程的步驟:
在集群中安裝代理:
注意:在自管 GitLab 實例上,GitLab 管理員需要設置GitLab 代理服務器(KAS) 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.