kubernetes云平台管理实战: 最小的资源pod(二)
一、pod初体验
1、编辑k8s_pod.yml文件
[root@k8s-master ~]# cat k8s_pod.yml
apiVersion: v1
kind: Pod
metadata:
name: nginx
labels:
app: web
spec:
containers:
- name: nginx
image: 10.0.128.0:5000/nginx:latest
ports:
- containerPort: 80
2、下载镜像并上传到私有仓库
[root@k8s-master ~]# docker pull nginx:latest
Trying to pull repository docker.io/library/nginx ...
latest: Pulling from docker.io/library/nginx
177e7ef0df69: Pull complete
ea57c53235df: Pull complete
bbdb1fbd4a86: Pull complete
Digest: sha256:b543f6d0983fbc25b9874e22f4fe257a567111da96fd1d8f1b44315f1236398c
[root@k8s-master ~]# docker tag nginx:latest 10.0.128.0:5000/nginx:latest
[root@k8s-master ~]# docker push 10.0.128.0:5000/nginx:latest
The push refers to a repository [10.0.128.0:5000/nginx]
b7efe781401d: Pushed
c9c2a3696080: Pushed
7b4e562e58dc: Pushed
latest: digest: sha256:e2847e35d4e0e2d459a7696538cbfea42ea2d3b8a1ee8329ba7e68694950afd3 size: 948
3、启动pod
[root@k8s-master ~]# kubectl create -f k8s_pod.yml
pod "nginx" created
[root@k8s-master ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e166a705c0a7 busybox "/bin/sh" 31 minutes ago Exited (0) 10 minutes ago cranky_bardeen
ba8d9b958c7c registry "/entrypoint.sh /etc/" 44 minutes ago Up 44 minutes 0.0.0.0:5000->5000/tcp registry
15340ee09614 busybox "/bin/sh" 4 hours ago Exited (1) About an hour ago sleepy_mccarthy
二、无法创建pod故障现象
1、查看pod状态
[root@k8s-master ~]# kubectl get pod
NAME READY STATUS RESTARTS AGE
nginx 0/1 ContainerCreating 0 2m
2、获取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: Pending
IP:
Controllers: <none>
Containers:
nginx:
Container ID:
Image: 10.0.128.0:5000/nginx:latest
Image ID:
Port: 80/TCP
State: Waiting
Reason: ContainerCreating
Ready: False
Restart Count: 0
Volume Mounts: <none>
Environment Variables: <none>
Conditions:
Type Status
Initialized True
Ready False
PodScheduled True
No volumes.
QoS Class: BestEffort
Tolerations: <none>
Events:
FirstSeen LastSeen Count From SubObjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
3m 3m 1 {default-scheduler } Normal Scheduled Successfully assigned nginx to k8s-node1
3m 46s 5 {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)" 3m 8s 12 {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\""
错误是无法从registry.access.redhat.com仓库获取镜像,解决办法是更换镜像地址
三、pod故障解决方案
1、搜索pod-infrastructure
[root@k8s-master ~]# docker search pod-infrastructure
2、下载并上传到私有仓库
[root@k8s-master ~]# docker pull tianyebj/pod-infrastructure
Using default tag: latest
Trying to pull repository docker.io/tianyebj/pod-infrastructure ...
latest: Pulling from docker.io/tianyebj/pod-infrastructure
7bd78273b666: Pull complete
c196631bd9ac: Pull complete
3c917e6a9e1a: Pull complete
Digest: sha256:73cc48728e707b74f99d17b4e802d836e22d373aee901fdcaa781b056cdabf5c
[root@k8s-master ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/registry latest 33fbbf4a24e5 2 weeks ago 24.17 MB
10.0.128.0:5000/busybox latest 3a093384ac30 2 weeks ago 1.199 MB
docker.io/busybox latest 3a093384ac30 2 weeks ago 1.199 MB
10.0.128.0:5000/nginx latest 7042885a156a 3 weeks ago 109.2 MB
docker.io/nginx latest 7042885a156a 3 weeks ago 109.2 MB
docker.io/tianyebj/pod-infrastructure latest 34d3450d733b 24 months ago 205 MB
[root@k8s-master ~]# docker tag docker.io/tianyebj/pod-infrastructure:latest 10.0.128.0:5000/pod-infrastructure:latest
[root@k8s-master ~]# docker push 10.0.128.0:5000/pod-infrastructure:latest
The push refers to a repository [10.0.128.0:5000/pod-infrastructure]
ba3d4cbbb261: Pushed
0a081b45cb84: Pushed
df9d2808b9a9: Pushed
latest: digest: sha256:a378b2d7a92231ffb07fdd9dbd2a52c3c439f19c8d675a0d8d9ab74950b15a1b size: 948
3、修改镜像的地址
vim /etc/kubernetes/kubelet
修改内容如下:
KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=10.0.128.0:5000/pod-infrastructure:latest"
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
--------- -------- ----- ---- ------------- -------- ------ -------
48m 48m 1 {default-scheduler } Normal Scheduled Successfully assigned nginx to k8s-node1
48m 6m 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)" 47m 5m 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\"" 4m 4m 1 {kubelet k8s-node1} spec.containers{nginx} Normal Pulling pulling image "10.0.128.0:5000/nginx:latest"
4m 4m 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.
4m 4m 1 {kubelet k8s-node1} spec.containers{nginx} Normal Pulled Successfully pulled image "10.0.128.0:5000/nginx:latest"
4m 4m 1 {kubelet k8s-node1} spec.containers{nginx} Normal Created Created container with docker id 27d25a2ee024; Security:[seccomp=unconfined]
4m 4m 1 [root@k8s-master ~]# kubectl get pod -o wide
NAME READY STATUS RESTARTS AGE IP NODE
nginx 1/1 Running 0 48m 172.16.10.2 k8s-node1 [root@k8s-master ~]# curl 172.16.10.2
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p> <p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p>
</body>
</html>
elet k8s-node1} spec.containers{nginx} Normal Started Started container with docker id 27d25a2ee024
kubernetes云平台管理实战: 最小的资源pod(二)的更多相关文章
- kubernetes云平台管理实战: 高级资源deployment-滚动升级(八)
一.通过文件创建deployment 1.创建deployment文件 [root@k8s-master ~]# cat nginx_deploy.yml apiVersion: extensions ...
- kubernetes云平台管理实战:HPA水平自动伸缩(十一)
一.自动伸缩 1.启动 [root@k8s-master ~]# kubectl autoscale deployment nginx-deployment --max=8 --min=2 --cpu ...
- kubernetes云平台管理实战:deployment通过标签管理pod(十)
一.kubectl run命令拓展 1.RC创建 [root@k8s-master ~]# kubectl run web --generator=run/v1 --image=10.0.128.0: ...
- kubernetes云平台管理实战:如何创建deployment更好(九)
一.文件创建带--record 1.文件 [root@k8s-master ~]# cat nginx_deploy.yml apiVersion: extensions/v1beta1 kind: ...
- kubernetes云平台管理实战: 集群部署(一)
一.环境规划 1.架构拓扑图 2.主机规划 3.软件版本 [root@k8s-master ~]# cat /etc/redhat-release CentOS Linux release 7.4.1 ...
- 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云平台管理实战: 故障自愈实战(四)
一.创建实验文件 [root@k8s-master ~]# cat myweb-rc.yml apiVersion: v1 kind: ReplicationController metadata: ...
- kubernetes云平台管理实战: 服务发现和负载均衡(五)
一.rc控制器常用命令 1.rc控制器信息查看 [root@k8s-master ~]# kubectl get replicationcontroller NAME DESIRED CURRENT ...
随机推荐
- Linux shell编写脚本部署pxe网络装机
Linux shell编写脚本部署pxe网络装机 人工安装配置,Linux PXE无人值守网络装机 https://www.cnblogs.com/yuzly/p/10582254.html 脚本实 ...
- C 语言 IO 缓存 相关
必要了解函数的功能和使用场景: fflush, setbuf, setvbuf 了解的操作: setbuf(stdout,NULL); // 关闭输出缓冲区: libc 和 linux 内核IO缓存模 ...
- c#操作SQL Server入门总结
我是一名c#新手.本文只是我是常学习的随笔. 一.下载SQL server软件 听说下载开发板是最好的(开发板如果只是用来学习.研究不算是侵权).在安装的时候,我也遇到了很多问题,在公司的电脑安装第一 ...
- C语言简单实现链栈基本几个功能
接着上一次的顺序栈,今天我记一下链栈,因为我也是刚学不久,有些地方也稍稍理解不了,所以,一起共勉.我会用我自己结合教材上画的图,争取跟代码一起结合,用文字和图最大化的解释代码,这样的话 ...
- How To Size Your Apache Flink® Cluster: A Back-of-the-Envelope Calculation
January 11, 2018- Apache Flink Robert Metzger and Chris Ward A favorite session from Flink Forward B ...
- Linux操作系统上要慎用的6个命令及防范方法
Linux操作系统上要慎用的6个命令及防范方法 基于Linux平台工作的童鞋都知道Linux命令行使用起来非常高效和快捷,但有时候也很危险,尤其是在你不确定你自己在正在做什么时候(别笑,别以为自己真的 ...
- Java 8 新特性:6-Optional类
(原) 先看看上面的说明: /** * A container object which may or may not contain a non-null value. * If a value i ...
- 使用opencv进行简单的手势检测[by Python]
代码参考于:https://github.com/rainyear/lolita/issues/8 简单的手势识别,基本思路是基于皮肤检测,皮肤的颜色在HSV颜色空间下与周围环境的区分度更高,从RGB ...
- 06 Django REST Framework 版本控制
01-版本控制 对接口进行版本控制只是一种杀死已部署客户端的“礼貌”方式. - 罗伊菲尔丁. 1. API版本控制允许您更改不同客户端之间的行为.REST框架提供了许多不同的版本控制方案. 2. 版本 ...
- java遍历复杂json字符串获取想要的数据
https://blog.csdn.net/qq_34309663/article/details/80508125 java如何解析复杂的json数据关于json处理的包有好几个,比如jackson ...