kubernetes云平台管理实战: pod资源共享(三)
一、共享容器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资源共享(三)的更多相关文章
- kubernetes云平台管理实战:deployment通过标签管理pod(十)
一.kubectl run命令拓展 1.RC创建 [root@k8s-master ~]# kubectl run web --generator=run/v1 --image=10.0.128.0: ...
- kubernetes云平台管理实战: 最小的资源pod(二)
一.pod初体验 1.编辑k8s_pod.yml文件 [root@k8s-master ~]# cat k8s_pod.yml apiVersion: v1 kind: Pod metadata: n ...
- kubernetes云平台管理实战:HPA水平自动伸缩(十一)
一.自动伸缩 1.启动 [root@k8s-master ~]# kubectl autoscale deployment nginx-deployment --max=8 --min=2 --cpu ...
- kubernetes云平台管理实战: 滚动升级秒级回滚(六)
一.nginx保证有两个版本 1.查看当前容器运行nginx版本 [root@k8s-master ~]# kubectl get pod -o wide NAME READY STATUS REST ...
- kubernetes云平台管理实战: 自动加载到负载均衡(七)
一.如何实现外界能访问 外界访问不了 1.启动svc [root@k8s-master ~]# cat myweb-svc.yaml apiVersion: v1 kind: Service meta ...
- kubernetes云平台管理实战: 集群部署(一)
一.环境规划 1.架构拓扑图 2.主机规划 3.软件版本 [root@k8s-master ~]# cat /etc/redhat-release CentOS Linux release 7.4.1 ...
- kubernetes云平台管理实战: 服务发现和负载均衡(五)
一.rc控制器常用命令 1.rc控制器信息查看 [root@k8s-master ~]# kubectl get replicationcontroller NAME DESIRED CURRENT ...
- kubernetes云平台管理实战:如何创建deployment更好(九)
一.文件创建带--record 1.文件 [root@k8s-master ~]# cat nginx_deploy.yml apiVersion: extensions/v1beta1 kind: ...
- kubernetes云平台管理实战: 故障自愈实战(四)
一.创建实验文件 [root@k8s-master ~]# cat myweb-rc.yml apiVersion: v1 kind: ReplicationController metadata: ...
随机推荐
- navicat 将自增长字段重置(重新从1开始)的方法
先说明,此语句会将你的表中数据全部删除. 很简单,运行如下sql语句: TRUNCATE TABLE 表名;
- c/c++浮点数在内存中存储方式
转自:https://www.cnblogs.com/dolphin0520/archive/2011/10/02/2198280.html 任何数据在内存中都是以二进制的形式存储的,例如一个shor ...
- .NET 术语
.NET 术语 1. AOT 预编译器.与 JIT 类似,此编译器还可将 IL 转换为机器代码. 与 JIT 编译相比,AOT 编译在应用程序执行前进行并且通常在不同计算机上执行. 由于在运行时 AO ...
- LeetCode算法题-Keyboard Row(Java实现)
这是悦乐书的第245次更新,第258篇原创 01 看题和准备 今天介绍的是LeetCode算法题中Easy级别的第112题(顺位题号是500).给定一个单词列表,返回可以在美国键盘的一行上使用字母表键 ...
- kernel笔记——进程调度
调度器完成以下任务: 时钟中断(或类似的定时器)时间内刷新进程的时间片,设置进程调度标志 系统调用返回或中断完成时检查调度标志 schedule函数 内核代码中完成进程调度的函数为schedule() ...
- keras 中模型的保存
参考:https://www.cnblogs.com/weiyinfu/p/9788179.html#0 1.model.summary() 这个函数会打印模型结构,但是仅仅是打印到控制台,不能保存 ...
- 数据采集工具Telegraf:简介及安装
接着上一篇博客:InfluxDB简介及安装,这篇博客介绍下Linux环境下Telegraf安装以及其功能特点... 官网地址:influxdata 官方文档:telegraf文档 环境:CentOS7 ...
- jenkins的安装部署
jenkins安装 参考连接: https://wiki.jenkins.io/display/JENKINS/Installing+Jenkins+on+Red+Hat+distributions ...
- linux-高并发与负载均衡-lvs-3种模型推导
NAT地址转换:
- Python之find命令中的位置的算法
find("s",a,b) #s表示的是一个子序列,a表示的是检索的起始位置,b表示的是检索的终止位置,ab可有可无 test = "abcdefgh" ...