hanshileiai
5/7/2020 - 1:30 AM

k8s - 资源清单 pod.yml

创建 pod.yml ,编写资源清单内容

apiVersion: v1
kind: Pod
metadata:
  name: myapp-pod
  labels: 
    app: myapp
    version: v1
spec:
  containers: 
  - name: app
    image: hub.hsl.com/library/myapp:v1
  - name: test
    image: hub.hsl.com/library/myapp:v1

应用 pod.yml

kubectl apply -f pod.yml

查看 pod 状态

kubectl get pods
# NAME                                READY   STATUS    RESTARTS   AGE
# myapp-pod                           1/2     Error     1          18s
kubectl get pods
# NAME                                READY   STATUS             RESTARTS   AGE
# myapp-pod                           1/2     CrashLoopBackOff   3          83s

查看出错 pod,显示 test容器 error

kubectl describe pod myapp-pod

查看 pod 下的 test 容器日志,报错信息

kubectl log myapp-pod -c test
# log is DEPRECATED and will be removed in a future version. Use logs instead.
# 2020/05/06 15:55:41 [emerg] 1#1: bind() to 0.0.0.0:80 failed (98: Address in use)

# 由于开了两个nginx 80 端口的容器所以导致第二个容器端口占用不能启动。