docker pull registry.cn-hangzhou.aliyuncs.com/google-containers/pause-amd64:3.0
docker tag registry.cn-hangzhou.aliyuncs.com/google-containers/pause-amd64:3.0 gcr.io/google_containers/pause-amd64:3.0
# sudo tee /etc/docker/daemon.json <<-'EOF'
> {
> "registry-mirrors": ["https://xxx.mirror.aliyuncs.com"]
> }
> EOF
# sudo systemctl daemon-reload
# sudo systemctl restart docker
示例:
# 创建并运行Nginx镜像
kubectl run nginx --image=nginx --replicas=3
# 查看pods
[root@node1 ~]# kubectl get all NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE deploy/nginx 3 3 3 0 17h NAME DESIRED CURRENT READY AGE rs/nginx-7c87f569d 3 3 0 17h NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE deploy/nginx 3 3 3 0 17h NAME DESIRED CURRENT READY AGE rs/nginx-7c87f569d 3 3 0 17h NAME READY STATUS RESTARTS AGE po/nginx-7c87f569d-crss2 0/1 ContainerCreating 0 17h po/nginx-7c87f569d-pjhfd 0/1 ContainerCreating 0 17h po/nginx-7c87f569d-qdxd9 0/1 ContainerCreating 0 17h NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE svc/kubernetes ClusterIP 10.10.10.1 <none> 443/TCP 17h
# 查看pods及运行节点
[root@node1 ~]# kubectl describe pod nginx-7c87f569d-crss2
Name: nginx-7c87f569d-crss2
Namespace: default
Node: 192.168.3.246/192.168.3.246
Start Time: Sat, 19 May 2018 22:02:11 +0800
Labels: pod-template-hash=374391258
run=nginx
Annotations: kubernetes.io/created-by={"kind":"SerializedReference","apiVersion":"v1","reference":{"kind":"ReplicaSet","namespace":"default","name":"nginx-7c87f569d","uid":"38f94eb7-5b6d-11e8-8406-00163e004a41","a...
Status: Pending
IP:
Created By: ReplicaSet/nginx-7c87f569d
Controlled By: ReplicaSet/nginx-7c87f569d
Containers:
nginx:
Container ID:
Image: nginx
Image ID:
Port: <none>
State: Waiting
Reason: ContainerCreating
Ready: False
Restart Count: 0
Environment: <none>
Mounts: <none>
Conditions:
Type Status
Initialized True
Ready False
PodScheduled True
Volumes: <none>
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: <none>
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Warning FailedSync 2m (x2233 over 17h) kubelet, 192.168.3.246 Error syncing pod
[root@node1 ~]# kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE nginx-7c87f569d-crss2 1/1 Running 1 5d 172.17.0.3 192.168.3.246 nginx-7c87f569d-pjhfd 1/1 Running 1 5d 172.17.0.2 192.168.3.246 nginx-7c87f569d-qdxd9 1/1 Running 1 5d 172.17.0.2 192.168.3.244
# 为deployment资源暴露一个新Service
[root@node1 ~]# kubectl expose deployment nginx --port=88 --target-port=80 service "nginx" exposed [root@node1 ~]# kubectl get all NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE deploy/nginx 3 3 3 3 5d NAME DESIRED CURRENT READY AGE rs/nginx-7c87f569d 3 3 3 5d NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE deploy/nginx 3 3 3 3 5d NAME DESIRED CURRENT READY AGE rs/nginx-7c87f569d 3 3 3 5d NAME READY STATUS RESTARTS AGE po/nginx-7c87f569d-crss2 1/1 Running 1 5d po/nginx-7c87f569d-pjhfd 1/1 Running 1 5d po/nginx-7c87f569d-qdxd9 1/1 Running 1 5d NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE svc/kubernetes ClusterIP 10.10.10.1 <none> 443/TCP 5d svc/nginx ClusterIP 10.10.10.165 <none> 88/TCP 27s

# 查看Service
# 查看Service的endpoints
[root@node1 ~]# kubectl get ep nginx NAME ENDPOINTS AGE nginx 172.17.0.2:80,172.17.0.2:80,172.17.0.3:80 4m [root@node1 ~]# kubectl get services nginx NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE nginx ClusterIP 10.10.10.165 <none> 88/TCP 4m
浙公网安备 33010602011771号