名称空间:
kubectl get namespace //获取命名空间
kubectl get all -n default //获取命名空间里的资源
kubectl create ns koutouyuan //创建命名空间koutouyuan
kubectl delete ns koutouyuan //删除命名空间
管理deployment资源:
kubectl create deployment nginx-dp --image=harbor.od.com/public/nginx:v1.7.9 -n kube-public //创建,放在命名空间kube-public下,取名为nginx-dp
kubectl get deploy -n kube-public // 查看部署
NAME READY UP-TO-DATE AVAILABLE AGE
nginx-dp 0/1 1 0 31s
kubectl get pods -n kube-public // 查看pods情况
NAME READY STATUS RESTARTS AGE
nginx-dp-7f74c75ff9-ck5wg 0/1 ImagePullBackOff 0 117s
kubectl describe pod nginx-dp -n kube-public // 查看失败原因,是镜像拉取失败!
Events:
Type Reason Age From Message
----------------------------------------------------------------------------------------------------------------------------------------
Normal Scheduled 6m57s default-scheduler Successfully assigned kube-public/nginx-dp-7f74c75ff9-ck5wg to minikube
Normal Pulling 5m33s (x4 over 6m56s) kubelet, minikube Pulling image "harbor.od.com/public/nginx:v1.7.9"
Warning Failed 5m32s (x4 over 6m55s) kubelet, minikube Failed to pull image "harbor.od.com/public/nginx:v1.7.9": rpc error: code = Unknown desc = Error response from daemon:
Get https://harbor.od.com/v2/: dial tcp 69.172.201.153:443: connect: connection refused
Warning Failed 5m32s (x4 over 6m55s) kubelet, minikube Error: ErrImagePull
Warning Failed 5m21s (x6 over 6m55s) kubelet, minikube Error: ImagePullBackOff
Normal BackOff 107s (x22 over 6m55s) kubelet, minikube Back-off pulling image "harbor.od.com/public/nginx:v1.7.9"
声明式资源管理方法: yaml/json 资源配置清单