kubernetes雲平臺管理實戰:deployment經過標籤管理pod(十)

1、kubectl run命令拓展

一、RC建立node

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

二、deployment建立nginx

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

不指定默認建立deploymentweb

三、刪除RCbash

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

2、deployment經過標籤管理pod

一、爲何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標籤不一致app

二、修改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,若是把標籤刪了就沒人管了測試

3、更改集羣端口

一、更改svc文件

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

二、查詢

[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

三、測試截圖

 

 

相關文章
相關標籤/搜索