|
[root@www pod_nginx_redis_kube]# vi test2_redis_nginx_pod.yaml
name: perofu4
labels:
name: perofu4
spec:
replicas: 1
selector:
name: perofu4
template:
metadata:
labels:
name: perofu4
spec:
containers:
- name: redis
image: www.perofu.com:7070/centos6.4_redis
command:
- '/bin/bash'
- '-c'
- '/etc/rc.local'
- name: nginx
image: www.perofu.com:7070/registry
[root@www pod_nginx_redis_kube]# /usr/bin/kubectl create -f test2_redis_nginx_pod.yaml
replicationcontrollers/perofu4
[root@www pod_nginx_redis_kube]#
[root@www pod_nginx_redis_kube]# /usr/bin/kubectl get pod
NAME READY STATUS RESTARTS AGE
perofu-wduar 1/2 Running 1 14s
[root@www pod_nginx_redis_kube]# /usr/bin/kubectl get pod
NAME READY STATUS RESTARTS AGE
perofu-wduar 2/2 Running 2 2m
[root@www pod_nginx_redis_kube]#
[root@www pod_nginx_redis_kube]# /usr/bin/kubectl get pod
NAME READY STATUS RESTARTS AGE
perofu-wduar 2/2 Running 2 2m
[root@www pod_nginx_redis_kube]#
[root@www pod_nginx_redis_kube]# /usr/bin/kubectl describe pod perofu-wduar
Name: perofu-wduar
Namespace: default
Image(s): www.perofu.com:7070/centos6.4_redis,www.perofu.com:7070/registry
Node: 192.168.16.240/192.168.16.240
Labels: name=perofu4
Status: Running
Reason:
Message:
IP: 172.22.2.9
Replication Controllers: perofu4 (1/1 replicas created)
Containers:
redis:
Image: www.perofu.com:7070/centos6.4_redis
State: Running
Started: Tue, 16 Feb 2016 16:54:32 +0800
Ready: True
Restart Count: 0
nginx:
Image: www.perofu.com:7070/registry
State: Running
Started: Tue, 16 Feb 2016 16:54:50 +0800
Ready: True
Restart Count: 2
Conditions:
Type Status
Ready True
#验证
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
5c6581d919a5 www.perofu.com:7070/registry:latest "docker-registry" 2 minutes ago Up 2 minutes k8s_nginx.65e9d290_perofu-wduar_default_eaa53352-cc1f-11e5-938c-000c29eae008_03b774d2
08315bce234b centos6.4_redis:latest "/bin/bash -c /etc/r 2 minutes ago Up 2 minutes k8s_redis.510ddc4c_perofu-wduar_default_eaa53352-cc1f-11e5-938c-000c29eae008_3e6b7907
15bd3a44a717 gcr.io/google_containers/pause:0.8.0 "/pause" 2 minutes ago Up 2 minutes k8s_POD.e4cc795_perofu-wduar_default_eaa53352-cc1f-11e5-938c-000c29eae008_8c768cca
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# docker exec -it 08315bce234b /bin/bash
[root@perofu-wduar /]#
[root@perofu-wduar /]# ifconfig
eth0 Link encap:Ethernet HWaddr 02:42:AC:16:02:09
inet addr:172.22.2.9 Bcast:0.0.0.0 Mask:255.255.255.0
inet6 addr: fe80::42:acff:fe16:209/64 Scope:Link
UP BROADCAST RUNNING MTU:1500 Metric:1
RX packets:10 errors:0 dropped:0 overruns:0 frame:0
TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:823 (823.0 b) TX bytes:718 (718.0 b)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:518 (518.0 b) TX bytes:518 (518.0 b)
[root@perofu-wduar /]# netstat -anplt
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 26/sshd
tcp 0 0 0.0.0.0:5000 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 27/redis-server 0.0
tcp 0 0 :::22 :::* LISTEN 26/sshd
[root@perofu-wduar /]#
[root@perofu-wduar /]# ps axu
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.2 11348 1288 ? Ss 03:54 0:00 /bin/sh /etc/rc.local
root 26 0.0 0.6 64168 2972 ? S 03:54 0:00 /usr/sbin/sshd -D
root 27 0.1 0.3 36484 1896 ? Ssl 03:54 0:00 redis-server 0.0.0.0:6379
root 30 0.1 0.3 11484 1816 ? S 03:59 0:00 /bin/bash
root 45 0.0 0.2 13364 1044 ? R+ 04:00 0:00 ps axu
[root@perofu-wduar /]#
[root@perofu-wduar /]# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 03:54 ? 00:00:00 /bin/sh /etc/rc.local
root 26 1 0 03:54 ? 00:00:00 /usr/sbin/sshd -D
root 27 1 0 03:54 ? 00:00:00 redis-server 0.0.0.0:6379
root 30 0 0 03:59 ? 00:00:00 /bin/bash
root 46 30 0 04:01 ? 00:00:00 ps -ef
#登陆第二个容器:
[root@localhost ~]# docker exec -it 5c6581d919a5 /bin/bash
root@perofu-wduar:/#
root@perofu-wduar:/# ifconfig
eth0 Link encap:Ethernet HWaddr 02:42:ac:16:02:09
inet addr:172.22.2.9 Bcast:0.0.0.0 Mask:255.255.255.0
inet6 addr: fe80::42:acff:fe16:209/64 Scope:Link
UP BROADCAST RUNNING MTU:1500 Metric:1
RX packets:10 errors:0 dropped:0 overruns:0 frame:0
TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:823 (823.0 B) TX bytes:718 (718.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:518 (518.0 B) TX bytes:518 (518.0 B)
root@perofu-wduar:/#
root@perofu-wduar:/# ps axu
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.9 55520 4716 ? Ss 08:54 0:00 /usr/bin/python /usr/local/bin/gunicorn --access-logfile - --error-logfile - --max-requests 100 -k gevent --grac
root 16 0.9 5.8 104620 28940 ? S 08:54 0:07 /usr/bin/python /usr/local/bin/gunicorn --access-logfile - --error-logfile - --max-requests 100 -k gevent --grac
root 17 0.9 6.3 104632 31392 ? S 08:54 0:07 /usr/bin/python /usr/local/bin/gunicorn --access-logfile - --error-logfile - --max-requests 100 -k gevent --grac
root 20 0.9 6.3 104644 31356 ? S 08:54 0:07 /usr/bin/python /usr/local/bin/gunicorn --access-logfile - --error-logfile - --max-requests 100 -k gevent --grac
root 21 0.9 6.3 104656 31456 ? S 08:54 0:07 /usr/bin/python /usr/local/bin/gunicorn --access-logfile - --error-logfile - --max-requests 100 -k gevent --grac
root 28 0.7 0.3 18140 1968 ? S 09:08 0:00 /bin/bash
root 44 0.0 0.2 15568 1132 ? R+ 09:08 0:00 ps axu
root@perofu-wduar:/#
root@perofu-wduar:/# netstat -anptl
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:5000 0.0.0.0:* LISTEN 1/python
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
root@perofu-wduar:/#
#在同一个pod的两个容器中,都有ip:172.22.2.9,都出现了redis的6397端口和python端口5000
[root@www pod_nginx_redis_kube]# /usr/bin/kubectl get pod
NAME READY STATUS RESTARTS AGE
perofu-wduar 2/2 Running 2 17h
|
|
|
|
|
|
|