我正在使用kubernet和circleci来部署docker。当我运行"./bin/kubectl rollout status deployments/prj5-deploy --timeout=2700s"
命令时,它运行了大约20分钟,并给出一个错误:
#!/bin/sh -eo pipefail
cd .circleci/ansible
cat inventory.txt
ansible-playbook -i inventory.txt deploy-application.yml
[web]
54.237.82.69
54.226.214.135
PLAY [Deploy application] ******************************************************
TASK [build] *******************************************************************
changed: [54.237.82.69]
TASK [if successful] ***********************************************************
Too long with no output (exceeded 40m0s): context deadline exceeded
字符串
有时候是这样的:
TASK [if successful] ***********************************************************
fatal: [54.210.76.165]: FAILED! => {"changed": true, "cmd": "./bin/kubectl rollout status deployments/****-deploy --timeout=3600s", "delta": "0:21:34.424507", "end": "2023-07-13 12:55:14.013552", "msg": "non-zero return code", "rc": 1, "start": "2023-07-13 12:33:39.589045", "stderr": "error: deployment \"****-deploy\" exceeded its progress deadline", "stderr_lines": ["error: deployment \"****-deploy\" exceeded its progress deadline"], "stdout": "Waiting for deployment \"****-deploy\" rollout to finish: 1 out of 4 new replicas have been updated...\nWaiting for deployment \"****-deploy\" rollout to finish: 1 out of 4 new replicas have been updated...\nWaiting for deployment \"****-deploy\" rollout to finish: 1 out of 4 new replicas have been updated...\nWaiting for deployment \"****-deploy\" rollout to finish: 2 out of 4 new replicas have been updated...
型
下面是部署脚本:deploy-application.yml:
- name: "Deploy application"
hosts: web[0]
user: ubuntu
gather_facts: false
become: yes
tasks:
- name: build
shell: "./bin/kubectl set image deployments/prj5-deploy prj5-app=shalltearbloodfallen01/prj5-deploy:master"
args:
chdir: $HOME
- name: if successful
shell: "./bin/kubectl rollout status deployments/prj5-deploy --timeout=2700s"
args:
chdir: $HOME
型
prj5-deploy:
apiVersion: apps/v1
kind: Deployment
metadata:
name: prj5-deploy
labels:
app: prj5-app
spec:
paused: false
replicas: 4
selector:
matchLabels:
app: prj5-app
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 0
maxUnavailable: 1
template:
metadata:
labels:
app: prj5-app
spec:
containers:
- name: prj5-app
image: shalltearbloodfallen01/prj5-deploy
ports:
- containerPort: 80
型
config.yml
deploy-docker:
docker:
- image: python:3.7-alpine3.11
steps:
- checkout
- add_ssh_keys:
fingerprints: ["xxxxxxxxxxxxxxxxxxxxxxxxxx"]
- attach_workspace:
at: ~/
- run:
name: Install dependencies
command: |
apk add --update ansible
- run:
name: deploy image docker
no_output_timeout: 40m
command: |
cd .circleci/ansible
cat inventory.txt
ansible-playbook -i inventory.txt deploy-application.yml
型
我该怎么解决?
1条答案
按热度按时间n3h0vuf21#
尝试向容器添加就绪探测器。如果没有这些,Kubernetes就不知道Pod何时“就绪”,以便它可以开始将流量路由到它,然后转移到下一个。
在架构方面,您可以考虑将CI进程(Circle CI)与CD进程分离(在您的情况下,直接调用kubectl)。考虑使用ArgoCD这样的工具来处理CI/CD管道的CD方面。