kubernetes云平台管理实战:deployment通过标签管理pod(十)

一、kubectl run命令拓展

1、RC创建

[root@k8s-master ~]# kubectl run web --generator=run/v1 --image=10.0.128.0:5000/nginx:1.13 --replicas=3
replicationcontroller "web" created

2、deployment创建

[root@k8s-master ~]# kubectl run web  --image=10.0.128.0:5000/nginx:1.13 --replicas=3
deployment "web" created

不指定默认创建deployment

3、删除RC

[root@k8s-master ~]# kubectl delete deployment web
deployment "web" deleted

二、deployment通过标签管理pod

1、为什么nginx-deployment里一个pod都没有?

[root@k8s-master ~]# kubectl describe svc nginx
Name: nginx
Namespace: default
Labels: <none>
Selector: app=myweb
Type: NodePort
IP: 10.254.145.15
Port: <unset> 80/TCP
NodePort: <unset> 30027/TCP
Endpoints: <none>
Session Affinity: None
No events.

因为POD标签不一致

2、修改pod标签为nginx

[root@k8s-master ~]# kubectl describe po/nginx-deployment-3113009173-4xrq4
Name: nginx-deployment-3113009173-4xrq4
Namespace: default
Node: k8s-node2/8.8.8.8
Start Time: Mon, 21 Jan 2019 19:52:06 +0800
Labels: app=nginx
pod-template-hash=3113009173
Status: Running
IP: 172.16.19.2
Controllers: ReplicaSet/nginx-deployment-3113009173 [root@k8s-master ~]# kubectl edit svc nginx
修改app: nginx
service "nginx" edited
[root@k8s-master ~]# kubectl describe svc nginx
Name: nginx
Namespace: default
Labels: <none>
Selector: app=nginx
Type: NodePort
IP: 10.254.145.15
Port: <unset> 80/TCP
NodePort: <unset> 30027/TCP
Endpoints: 172.16.19.2:80,172.16.19.3:80,172.16.50.2:80
Session Affinity: None
No events.

deployment通过标签管理pod,如果把标签删了就没人管了

三、更改集群端口

1、更改svc文件

[root@k8s-master ~]# kubectl edit svc nginx
- nodePort: 32000
service "nginx" edited

2、查询

[root@k8s-master ~]# kubectl get all
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
deploy/nginx-deployment 1 1 1 1 13h NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
svc/kubernetes 10.254.0.1 <none> 443/TCP 2d
svc/nginx 10.254.145.15 <nodes> 80:32000/TCP 1d NAME DESIRED CURRENT READY AGE
rs/nginx-deployment-2950479891 0 0 0 13h
rs/nginx-deployment-3113009173 1 1 1 13h NAME READY STATUS RESTARTS AGE
po/nginx-deployment-3113009173-vckhg 1/1 Running 1 13h

3、测试截图

kubernetes云平台管理实战:deployment通过标签管理pod(十)

kubernetes云平台管理实战:deployment通过标签管理pod(十)

上一篇:SWT的TableVierer的使用一


下一篇:Maven 学习总结 (四)之 测试