自托管的13.2.2-ee
我的管道出现故障,我不确定为什么。 我查看了/var/log/gitlab/gitlab-rails/kubernetes.log,但什么也没看到
我用于构建docker映像并将其发送到仓库的阶段正在运行,但是对于在我的kubernetes集群上测试部署应用程序的审查阶段来说,它失败了,没有日志解释原因。
我还认为安装弹性堆栈可能对日志有帮助(其他应用程序也可以安装),但这会发生:
我的gitlab-ci.yml文件:
services:
- docker:18-dind
stages:
- build
- review
variables:
DOCKER_HOST: tcp://localhost:2375
compile-php:
stage: build
image: docker:stable
before_script:
- docker login gitlab.mygitlabdomain.com:5050 -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD}
script:
- docker build -t "${CI_REGISTRY}/${CI_PROJECT_PATH}/php-fpm" ./php-fpm
- docker tag "${CI_REGISTRY}/${CI_PROJECT_PATH}/php-fpm:latest" "${CI_REGISTRY}/${CI_PROJECT_PATH}/php-fpm:${CI_COMMIT_REF_NAME}"
- docker push "${CI_REGISTRY}/${CI_PROJECT_PATH}/php-fpm:${CI_COMMIT_REF_NAME}"
compile-ngnix:
stage: build
image: docker:stable
before_script:
- docker login gitlab.mygitlabdomain.com:5050 -u ${CI_REGISTRY_USER} -p ${CI_REGISTRY_PASSWORD}
script:
- docker build -t "${CI_REGISTRY}/${CI_PROJECT_PATH}/nginx" ./nginx
- docker tag "${CI_REGISTRY}/${CI_PROJECT_PATH}/nginx:latest" "${CI_REGISTRY}/${CI_PROJECT_PATH}/nginx:${CI_COMMIT_REF_NAME}"
- docker push "${CI_REGISTRY}/${CI_PROJECT_PATH}/nginx:${CI_COMMIT_REF_NAME}"
deploy_review:
image:
name: lachlanevenson/k8s-kubectl:latest
entrypoint: ["/bin/sh", "-c"]
stage: review
only:
- branches
except:
- tags
environment:
name: staging
url: https://$CI_ENVIRONMENT_SLUG-projectdomain.com
on_stop: stop_review
kubernetes:
namespace: projectdomain
script:
- kubectl version
- cd deployments/
- sed -i "s~__CI_REGISTRY_IMAGE__~${CI_REGISTRY_IMAGE}~" deployment.yaml
- sed -i "s/__CI_ENVIRONMENT_SLUG__/${CI_ENVIRONMENT_SLUG}/" deployment.yaml ingress.yaml service.yaml
- sed -i "s/__VERSION__/${CI_COMMIT_REF_NAME}/" deployment.yaml ingress.yaml service.yaml
- |
if kubectl apply -f deployment.yaml | grep -q unchanged; then
echo "=> Patching deployment to force image update."
kubectl patch -f deployment.yaml -p "{\"spec\":{\"template\":{\"metadata\":{\"annotations\":{\"ci-last-updated\":\"$(date +'%s')\"}}}}}"
else
echo "=> Deployment apply has changed the object, no need to force image update."
fi
- kubectl apply -f service.yaml || true
- kubectl apply -f ingress.yaml
- kubectl rollout status -f deployment.yaml
- kubectl get deploy,svc,ing,pod -l app="$(echo ${CI_PROJECT_NAME} | tr "." "-")",ref="${CI_ENVIRONMENT_SLUG}"
stop_review:
image:
name: lachlanevenson/k8s-kubectl:latest
entrypoint: ["/bin/sh", "-c"]
stage: review
variables:
GIT_STRATEGY: none
when: manual
only:
- branches
except:
- master
- tags
environment:
name: staging
action: stop
kubernetes:
namespace: projectdomain
script:
- kubectl version
- kubectl delete ing -l ref=${CI_ENVIRONMENT_SLUG}
- kubectl delete all -l ref=${CI_ENVIRONMENT_SLUG}
deployment.yaml文件:
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: projectdomain-__CI_ENVIRONMENT_SLUG__
labels:
app: projectdomain
ref: __CI_ENVIRONMENT_SLUG__
track: stable
spec:
replicas: 2
selector:
matchLabels:
app: projectdomain
ref: __CI_ENVIRONMENT_SLUG__
template:
metadata:
labels:
app: projectdomain
ref: __CI_ENVIRONMENT_SLUG__
track: stable
spec:
containers:
- name: app
image: __CI_REGISTRY_IMAGE__:__VERSION__
imagePullPolicy: Always
ports:
- name: http-metrics
protocol: TCP
containerPort: 8000
livenessProbe:
httpGet:
path: /health
port: 8000
initialDelaySeconds: 3
timeoutSeconds: 2
readinessProbe:
httpGet:
path: /health
port: 8000
initialDelaySeconds: 3
timeoutSeconds: 2
答案 0 :(得分:0)
您可以在GitLab 13.3(2020年8月)上尝试相同的pod部署
其集成的仪表板可以提供其他线索。
Kubernetes Pod健康信息中心
在一处查看系统的所有指标(包括集群指标)对于了解系统的运行状况至关重要。在GitLab 13.3中,无论您使用的是managed Prometheus,还是集群中正在运行Prometheus的现有实例,您都可以在新的即用Pod健康指标仪表板中查看Kubernetes Pod的健康状况。 ,方法是将其连接到您的GitLab实例。在下拉列表中选择所需的Pod,然后查看关键指标,例如CPU,内存使用情况,网络等。
请参见Documentation和Issue。
您可以看到仪表板in action in this video。