我的图片托管在GCR上。 我想在我的本地系统(mac)上创建Kubernetes Cluster。
我遵循的步骤:
apiVersion: apps/v1 kind: Deployment metadata: name: sv-premier spec: selector: matchLabels: app: sv-premier template: metadata: labels: app: sv-premier spec: volumes: - name: google-cloud-key secret: secretName: gcp-key containers: - name: sv-premier image: gcr.io/proto/premiercore1:latest imagePullPolicy: Always command: ["echo", "Done deploying sv-premier"] volumeMounts: - name: google-cloud-key mountPath: /var/secrets/google env: - name: GOOGLE_APPLICATION_CREDENTIALS value: /var/secrets/google/key.json ports: - containerPort: 8080 imagePullSecrets: - name: imagepullsecretkey
当我执行命令-kubectl apply -f deployment.yaml时,出现 CrashLoopBackOff 错误
日志-
kubectl描述豆荚podname
=====================
名称:sv-premier-6b77ddd747-cvdr5
命名空间:默认
优先级:0
节点:docker-desktop / 192.168.65.3
开始时间:星期二,2020年2月4日14:18:47 +0530
标签:app = sv-premier
pod-template-hash = 6b77ddd747
注释:
状态:正在运行
IP:10.1.0.43
IP:
控制者:ReplicaSet / sv-premier-6b77ddd747
容器:
sv-premierleague:
Container ID: docker://141126d732409427fe39b405865f88856ac4e1d8586112797fc5bf4fdfbe317c Image: gcr.io/proto/premiercore1:latest Image ID: docker-pullable://gcr.io/proto/premiercore1@sha256:b3800ccca3f30725d5c9235dd349548f0fcfe309f51883d8af16397aef2c3953 Port: 8080/TCP Host Port: 0/TCP Command: echo Done deploying sv-premier State: Waiting Reason: CrashLoopBackOff Last State: Terminated Reason: Completed Exit Code: 0 Started: Tue, 04 Feb 2020 15:00:51 +0530 Finished: Tue, 04 Feb 2020 15:00:51 +0530 Ready: False Restart Count: 13 Environment: GOOGLE_APPLICATION_CREDENTIALS: /var/secrets/google/key.json Mounts: /var/run/secrets/kubernetes.io/serviceaccount from default-token-s4jgd (ro) /var/secrets/google from google-cloud-key (rw)
条件:
类型状态
初始化为True
准备就绪
ContainersReady False
PodScheduled True
音量:
google-cloud-key:
Type: Secret (a volume populated by a Secret) SecretName: gcp-key Optional: false
default-token-s4jgd:
Type: Secret (a volume populated by a Secret) SecretName: default-token-s4jgd Optional: false
QoS类别:尽力而为
节点选择器:
公差:node.kubernetes.io/not-ready:NoExecute持续300s
node.kubernetes.io/unreachable:NoExecute for 300s
事件:
键入原因年龄自
消息---- ------ ---- ----
常规计划的46m默认计划程序
已成功将default / sv-premier-6b77ddd747-cvdr5分配给 docker-desktop正常拉动45m(x4超过46m)kubelet,docker-desktop 成功提取图像 “ gcr.io/proto/premiercore1:latest”
正常创建的45m(x4超过46m)kubelet,docker-desktop 创建了容器sv-premier
正常启动45m(x4超过46m)kubelet,docker-desktop 启动容器sv-premier
正常拉动45m(x5超过46m)kubelet,docker-desktop 拉图像“ gcr.io/proto/premiercore1:latest”
警告后退92s(x207超过46m)kubelet,docker-desktop 后退重启失败的容器
=====================
并输出-
kubectl记录podname-> 完成sv-premier部署
我很困惑为什么我的集装箱要退出。无法启动。
请指导。
答案 0 :(得分:2)
使用长期运行的任务示例更新您的deployment.yaml。
command: ["/bin/sh"]
args: ["-c", "while true; do echo Done Deploying sv-premier; sleep 3600;done"]
这将使您的容器在部署后进入睡眠状态,并且每小时都会记录一次消息。
详细了解pod lifecycle容器状态here