环境准备(本机):CPU: CORE i5 内存:8G
相关的基础知识,请自行百度一下。
1. 准备3台虚拟机
192.168.180.100 k8s-master
192.168.180.101 k8s-node1
192.168.180.102 k8s-node2
2. 安装K8S和docker
请自行百度一下,有很多相关教程。当然有很多坑也需要自行解决,这里就不一一讲解了。安装版本K8S: 1.14.2 docker:18.09.6。
[root@k8s-master ~]# kubectl get nodes
NAME STATUS ROLES AGE VERSION
k8s-master Ready master 354d v1.14.2
k8s-node-1 Ready 354d v1.14.2
k8s-node-2 Ready 354d v1.14.2
[root@k8s-master ~]# docker version
Client:
Version: 18.09.6
API version: 1.39
Go version: go1.10.8
Git commit: 481bc77156
Built: Sat May 4 02:34:58 2019
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.6
API version: 1.39 (minimum version 1.12)
Go version: go1.10.8
Git commit: 481bc77
Built: Sat May 4 02:02:43 2019
OS/Arch: linux/amd64
Experimental: false
3. 查看可视化界面
4. 部署tomcat
5. 容器扩容、缩容
实验证明最好是在master上面用命令来操作更可靠点。
[root@k8s-master nginx-tomcat]# kubectl scale deployment tomcathost --replicas=3
deployment.extensions/tomcathost scaled
[root@k8s-master nginx-tomcat]#
[root@k8s-master nginx-tomcat]# kubectl scale deployment tomcathost --replicas=2
deployment.extensions/tomcathost scaled
[root@k8s-master nginx-tomcat]#
6. 查看容器日志
花粉社群VIP加油站
猜你喜欢