一、共享容器IP地址

1、查看容器进程

[root@k8s-node1 ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
27d25a2ee024 10.0.128.0:5000/nginx:latest "nginx -g 'daemon off" 6 minutes ago Up 6 minutes k8s_nginx.d9a10343_nginx_default_eb1873c6-1c70-11e9-a431-000c292bd9e1_db2f2216
5a4f3b8afc83 10.0.128.0:5000/pod-infrastructure:latest "/pod" 6 minutes ago Up 6 minutes k8s_POD.be1401e9_nginx_default_eb1873c6-1c70-11e9-a431-000c292bd9e1_e0c2e5a9
3c681264cf57 busybox "/bin/sh" About an hour ago Exited (0) 45 minutes ago sleepy_euclid
f63325fd3fff busybox "/bin/sh" 4 hours ago Exited (1) About an hour ago tiny_darwin

2、查看容器网络

[root@k8s-node1 ~]# docker inspect 5a4f3b8afc83(pod)
"NetworkSettings": {
"Bridge": "",
"SandboxID": "fd91965070d661114647c421cccdd79c72fb34d4da0d05d07a0cec7f39e0a32e",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {},
"SandboxKey": "/var/run/docker/netns/fd91965070d6",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "d553e2a5b4f2b41597a366f66768bca11fe6684d8205325f5b357be155589b8c",
"Gateway": "172.16.10.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.16.10.2",
"IPPrefixLen": 24,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:10:0a:02",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "b5808699e84fb05d664674add787aa4a9e43d3ca94739c94df244f78d0f2146f",
"EndpointID": "d553e2a5b4f2b41597a366f66768bca11fe6684d8205325f5b357be155589b8c",
"Gateway": "172.16.10.1",
"IPAddress": "172.16.10.2",
"IPPrefixLen": 24,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:10:0a:02"
}
}
}
}
]
[root@k8s-node1 ~]# docker inspect 27d25a2ee024 },
"NetworkSettings": {
"Bridge": "",
"SandboxID": "",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": null,
"SandboxKey": "",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": null
}
}
]

3、小结

k8s每启动一个容器,都需要先启动一个pod容器,启动的容器共用pod容器的ip地址

二、多pod体验

1、修改k8s_pod.yml文件

[root@k8s-master ~]# cat k8s_pod.yml
apiVersion: v1
kind: Pod
metadata:
name: nginx2
labels:
app: web
spec:
containers:
- name: nginx2
image: 10.0.128.0:5000/nginx:latest
ports:
- containerPort: 80

2、启动pod

[root@k8s-master ~]# kubectl create -f k8s_pod.yml
pod "nginx2" created

3、获取pod信息(简版)

[root@k8s-master ~]# kubectl get pod
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 1h
nginx2 0/1 ContainerCreating 0 18s

4、获取pod信息(详细)

[root@k8s-master ~]# kubectl describe pod nginx
Name: nginx
Namespace: default
Node: k8s-node1/10.0.128.1
Start Time: Sun, 20 Jan 2019 13:04:51 +0800
Labels: app=web
Status: Running
IP: 172.16.10.2
Controllers: <none>
Containers:
nginx:
Container ID: docker://27d25a2ee0248b103991a27b81e3f244382ebdb642694e2aeb5503c373fdb912
Image: 10.0.128.0:5000/nginx:latest
Image ID: docker-pullable://10.0.128.0:5000/nginx@sha256:e2847e35d4e0e2d459a7696538cbfea42ea2d3b8a1ee8329ba7e68694950afd3
Port: 80/TCP
State: Running
Started: Sun, 20 Jan 2019 13:48:30 +0800
Ready: True
Restart Count: 0
Volume Mounts: <none>
Environment Variables: <none>
Conditions:
Type Status
Initialized True
Ready True
PodScheduled True
No volumes.
QoS Class: BestEffort
Tolerations: <none>
Events:
FirstSeen LastSeen Count From SubObjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
1h 20m 13 {kubelet k8s-node1} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "POD" with ErrImagePull: "image pull failed for registry.access.redhat.com/rhel7/pod-infrastructure:latest, this may be because there are no credentials on this request. details: (open /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt: no such file or directory)" 1h 19m 182 {kubelet k8s-node1} Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "POD" with ImagePullBackOff: "Back-off pulling image \"registry.access.redhat.com/rhel7/pod-infrastructure:latest\"" 19m 19m 1 {kubelet k8s-node1} spec.containers{nginx} Normal Pulling pulling image "10.0.128.0:5000/nginx:latest"
19m 18m 2 {kubelet k8s-node1} Warning MissingClusterDNS kubelet does not have ClusterDNS IP configured and cannot create Pod using "ClusterFirst" policy. Falling back to DNSDefault policy.
18m 18m 1 {kubelet k8s-node1} spec.containers{nginx} Normal Pulled Successfully pulled image "10.0.128.0:5000/nginx:latest"
18m 18m 1 {kubelet k8s-node1} spec.containers{nginx} Normal Created Created container with docker id 27d25a2ee024; Security:[seccomp=unconfined]
18m 18m 1 {kubelet k8s-node1} spec.containers{nginx} Normal Started Started container with docker id 27d25a2ee024
[root@k8s-master ~]# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE
nginx 1/1 Running 0 1h 172.16.10.2 k8s-node1
nginx2 1/1 Running 0 52s 172.16.48.2 k8s-node2

kubernetes云平台管理实战: pod资源共享(三)的更多相关文章

  1. kubernetes云平台管理实战:deployment通过标签管理pod(十)

    一.kubectl run命令拓展 1.RC创建 [root@k8s-master ~]# kubectl run web --generator=run/v1 --image=10.0.128.0: ...

  2. kubernetes云平台管理实战: 最小的资源pod(二)

    一.pod初体验 1.编辑k8s_pod.yml文件 [root@k8s-master ~]# cat k8s_pod.yml apiVersion: v1 kind: Pod metadata: n ...

  3. kubernetes云平台管理实战:HPA水平自动伸缩(十一)

    一.自动伸缩 1.启动 [root@k8s-master ~]# kubectl autoscale deployment nginx-deployment --max=8 --min=2 --cpu ...

  4. kubernetes云平台管理实战: 滚动升级秒级回滚(六)

    一.nginx保证有两个版本 1.查看当前容器运行nginx版本 [root@k8s-master ~]# kubectl get pod -o wide NAME READY STATUS REST ...

  5. kubernetes云平台管理实战: 自动加载到负载均衡(七)

    一.如何实现外界能访问 外界访问不了 1.启动svc [root@k8s-master ~]# cat myweb-svc.yaml apiVersion: v1 kind: Service meta ...

  6. kubernetes云平台管理实战: 集群部署(一)

    一.环境规划 1.架构拓扑图 2.主机规划 3.软件版本 [root@k8s-master ~]# cat /etc/redhat-release CentOS Linux release 7.4.1 ...

  7. kubernetes云平台管理实战: 服务发现和负载均衡(五)

    一.rc控制器常用命令 1.rc控制器信息查看 [root@k8s-master ~]# kubectl get replicationcontroller NAME DESIRED CURRENT ...

  8. kubernetes云平台管理实战:如何创建deployment更好(九)

    一.文件创建带--record 1.文件 [root@k8s-master ~]# cat nginx_deploy.yml apiVersion: extensions/v1beta1 kind: ...

  9. kubernetes云平台管理实战: 故障自愈实战(四)

    一.创建实验文件 [root@k8s-master ~]# cat myweb-rc.yml apiVersion: v1 kind: ReplicationController metadata: ...

随机推荐

  1. SQL Server数据库————连接查询和分组查询

    SQL Server数据库————连接查询和分组查询 分组查询 select 列from  <表名> where  …… group by  列 注意:跟order  by一样group ...

  2. 【原】Java学习笔记022 - 字符串

    package cn.temptation; public class Sample01 { public static void main(String[] args) { // 字符串 // 定义 ...

  3. 【原】Java学习笔记007 - 流程控制

    package cn.temptation; public class Sample01 { public static void main(String[] args) { // for循环 // ...

  4. 一个小错误:error LNK2019: 无法解析的外部符号 "public: __thiscall Turtle::~Turtle(void)" (??1Turtle@@QAE@XZ),该符号在函数 _main 中被引用

    昨天在撸代码的时候遇到了一个十分蛋疼的错误 : 错误: 1>3.obj : error LNK2019: 无法解析的外部符号 "public: __thiscall Turtle::~ ...

  5. 腾讯大数据平台Oceanus: A one-stop platform for real time stream processing powered by Apache Flink

    January 25, 2019Use Cases, Apache Flink The Big Data Team at Tencent     In recent years, the increa ...

  6. adb常用命令(golang版)及输入中文

    package main import ( "crypto/md5" "fmt" "image/png" "io/ioutil&q ...

  7. Django view(视图)

    在Django MTV模式中,View视图负责业务逻辑部分,路由系统接收到HTTP请求,并将任务分配给相应的视图函数,由视图函数来负责响应这个请求.无论视图本身包含什么逻辑,都要返回响应. 在这里HT ...

  8. vue diff 算法学习

    function updateChildren (parentElm, oldCh, newCh, insertedVnodeQueue, removeOnly) { let oldStartIdx ...

  9. 深入理解 Java 基本数据类型

    深入理解 Java 基本数据类型

  10. HNOI2019:My Dream

    反正这次的目标也不是进省队,目标就是做到最好吧-- 下面都是流水账~ Day -INF ~ Day -3 专题交流没什么好说的,模拟赛详见3.11-3.27省选前多校联考乱记和3.28-4.2CJ大毒 ...