使用kubectl create -f tomcat-deployment.yml部署tomcat到k8s中。
tomcat-deployment.yml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: tomcat-deploy
spec:
replicas: 2
template:
metadata:
labels:
app: tomcat-cluster
spec:
containers:
- name: tomcat-cluster
image: tomcat:latest
ports:
- containerPort: 8080
查看节点信息
kubectl get node -o wide
NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME
master Ready master 34h v1.14.1 192.168.121.150 <none> CentOS Linux 7 (Core) 3.10.0-862.el7.x86_64 docker://18.9.5
node1 Ready <none> 24h v1.14.1 192.168.121.151 <none> CentOS Linux 7 (Core) 3.10.0-862.el7.x86_64 docker://18.9.5
node2 Ready <none> 24h v1.14.1 192.168.121.152 <none> CentOS Linux 7 (Core) 3.10.0-862.el7.x86_64 docker://18.9.5
查看pod信息
kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
tomcat-deploy-5fd4fc7ddb-8pdlc 1/1 Running 0 6m17s 10.244.1.5 node1 <none> <none>
tomcat-deploy-5fd4fc7ddb-nrs5v 1/1 Running 0 6m17s 10.244.2.4 node2 <none> <none>
查看特定pod信息
kubectl describe pod tomcat-deploy-5fd4fc7ddb-8pdlc
查看特定pod日志
kubectl logs tomcat-deploy-5fd4fc7ddb-8pdlc