博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Centos7部署kubernetes测试k8s应用(九)
阅读量:5057 次
发布时间:2019-06-12

本文共 2631 字,大约阅读时间需要 8 分钟。

1、创建一个deployment
[root@linux-node1 ~]# kubectl run net-test --image=alpine --replicas=2 sleep 360000
deployment.apps "net-test" created
2、查看获取IP情况
[root@linux-node1 ~]# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE
net-test-5767cb94df-5h8b6 1/1 Running 0 3m 10.2.79.2 192.168.43.23
net-test-5767cb94df-n5mcr 1/1 Running 0 3m 10.2.74.2 192.168.43.22
3、测试连通性
ping 10.2.79.2
 4、测试nginx
[root@linux-node1 ~]# vim nginx-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.10.3
ports:
- containerPort: 80
 
5、创建nginx-deploymen
[root@linux-node1 ~]# kubectl create -f nginx-deployment.yaml
deployment.apps "nginx-deployment" created
6、查看deploymen
[root@linux-node1 ~]# kubectl get deployment
7、查看deploymen详细信息
[root@linux-node1 ~]# kubectl describe deployment
8、查看单个副本的详细信息
[root@linux-node1 ~]# kubectl describe pod nginx-deployment-75d56bb955-4vsns
9、查看pod
[root@linux-node1 ~]# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE
net-test-5767cb94df-5h8b6 1/1 Running 0 11m 10.2.79.2 192.168.43.23
net-test-5767cb94df-n5mcr 1/1 Running 0 11m 10.2.74.2 192.168.43.22
nginx-deployment-75d56bb955-4vsns 1/1 Running 0 4m 10.2.74.3 192.168.43.22
nginx-deployment-75d56bb955-l97zv 1/1 Running 0 4m 10.2.79.3 192.168.43.23
nginx-deployment-75d56bb955-wlfp2 1/1 Running 0 4m 10.2.79.4 192.168.43.23
10、测试pod访问
[root@linux-node1 ~]# curl --head
11、更新deployment
[root@linux-node1 ~]# kubectl set image deployment/nginx-deployment nginx=nginx:1.12.2 --record
deployment.apps "nginx-deployment" image updated
12、查看更新后的deployment
[root@linux-node1 ~]# kubectl get deployment -o wide
13、回滚到上一个版本
[root@linux-node1 ~]# kubectl rollout undo deployment/nginx-deployment
14、创建service
[root@linux-node1 ~]# vim nginx-service.yaml
kind: Service
apiVersion: v1
metadata:
name: nginx-service
spec:
selector:
app: nginx
ports:
- protocol: TCP
port: 80
targetPort: 80
[root@linux-node1 ~]# kubectl create -f nginx-service.yaml
service "nginx-service" created
15、可以看到已经实现了负载均衡
[root@linux-node2 ssl]# ipvsadm -LN
-LN: unknown option
[root@linux-node2 ssl]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 10.1.0.1:443 rr persistent 10800
-> 192.168.43.21:6443 Masq 1 0 0
TCP 10.1.185.150:80 rr
-> 10.2.74.3:80 Masq 1 0 0
-> 10.2.74.5:80 Masq 1 0 0
-> 10.2.79.3:80 Masq 1 0 0

转载于:https://www.cnblogs.com/xiaoliangxianshen/p/9165558.html

你可能感兴趣的文章
浅谈C++底层机制
查看>>
STL——配接器、常用算法使用
查看>>
第9课 uart
查看>>
Range和xrange的区别
查看>>
BZOJ 1010 [HNOI2008]玩具装箱 (斜率优化DP)
查看>>
java-动态规划算法学习笔记
查看>>
STL容器之vector
查看>>
Linux 内核中断内幕
查看>>
DNS负载均衡
查看>>
无法向会话状态服务器发出会话状态请求
查看>>
数据中心虚拟化技术
查看>>
Oracle OEM 配置报错: No value was set for the parameter DBCONTROL_HTTP_PORT 解决方法
查看>>
01入门
查看>>
python正则表达式
查看>>
嵌套循环连接(nested loops join)原理
查看>>
shell统计特征数量
查看>>
复习文件操作
查看>>
C#Hashtable与Dictionary性能
查看>>
10个让你忘记 Flash 的 HTML5 应用演示
查看>>
8个Python面试必考的题目,小编也被坑过 ToT
查看>>