其他分享
首页 > 其他分享> > 一个pod带两个容器

一个pod带两个容器

作者:互联网

[root@dock01 ~]# cat tomcat.yaml 
apiVersion: v1
kind: Pod
metadata:
  name: javaweb-20210118
spec:
  containers:
  - name: tomcat1-20210118
    image: 192.168.137.102:5000/centos_tomcat_v7
    command: ["/bin/sh","-c","sleep 3600"]
    volumeMounts:
    - mountPath: /usr/local/apache-tomcat-8.5.11/webapps
      name: app-volume
    ports:
    - containerPort: 8001
      hostPort: 9090
  - name: tomcat2-20210118
    image: 192.168.137.102:5000/centos_tomcat_v7
    command: ["sh","-c","/usr/local/apache-tomcat-8.5.11/bin/catalina.sh  run"]
    volumeMounts:
    - mountPath: /usr/local/apache-tomcat-8.5.11/webapps
      name: app-volume
    ports:
    - containerPort: 8002
      hostPort: 8090
  volumes:
  - name: app-volume
    emptyDir: {}
    

[root@dock01 ~]# kubectl get pod javaweb-20210118 -o wide
NAME               READY   STATUS    RESTARTS   AGE   IP           NODE     NOMINATED NODE   READINESS GATES
javaweb-20210118   2/2     Running   0          28s   10.36.0.10   dock03   <none>           <none>


[root@dock01 ~]# kubectl describe pod javaweb-20210118
Name:         javaweb-20210118
Namespace:    default
Priority:     0
Node:         dock03/192.168.137.102
Start Time:   Mon, 18 Jan 2021 16:47:37 +0800
Labels:       <none>
Annotations:  <none>
Status:       Running
IP:           10.36.0.10

dock03:/root#docker ps -a | grep 20210118 | grep -v 'pause'
a082cc936d73   192.168.137.102:5000/centos_tomcat_v7                           "sh -c '/usr/local/a…"   About a minute ago   Up About a minute                                    k8s_tomcat2-20210118_javaweb-20210118_default_41502eda-7ea5-40c1-9931-d5f62395f254_0
cd9ce1ebd9db   192.168.137.102:5000/centos_tomcat_v7                           "/bin/sh -c 'sleep 3…"   About a minute ago   Up About a minute                                    k8s_tomcat1-20210118_javaweb-20210118_default_41502eda-7ea5-40c1-9931-d5f62395f254_0

dock03:/root#docker exec -it a082cc936d73 bash
[root@javaweb-20210118 /]# ifconfig -a
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1376
        inet 10.36.0.10  netmask 255.240.0.0  broadcast 10.47.255.255

        
dock03:/root#docker exec -it cd9ce1ebd9db  bash
[root@javaweb-20210118 /]# ifconfig -a
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1376
        inet 10.36.0.10  netmask 255.240.0.0  broadcast 10.47.255.255

标签:容器,两个,javaweb,tomcat,192.168,pod,20210118,root,name
来源: https://blog.csdn.net/zhaoyangjian724/article/details/112788561