一、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(二)的更多相关文章

  1. kubernetes云平台管理实战: 高级资源deployment-滚动升级(八)

    一.通过文件创建deployment 1.创建deployment文件 [root@k8s-master ~]# cat nginx_deploy.yml apiVersion: extensions ...

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

随机推荐

  1. Win10 - MySQL 5.7 密码重置

    Win10 - MySQL 5.7 密码重置 所有行为均发生在系统管理员权限的 Cmd 或 Powershell 下 注意! 本行为会导致数据库重置 # 重新安装 mysql 服务 mysqld -- ...

  2. C# 中使用特性获得函数被调用的路径,行号和函数

    自从 .net framework 4.5  增加了几个特性来获得函数的调用路径(CallerFilePath),调用行号(CallerLineNumber),和调用函数(CallerMemberNa ...

  3. 【PAT】B1014 福尔摩斯的约会

    因为前面两字符串中第 1 对相同的大写英文字母(大小写有区分)是第 4 个字母D,代表星期四: 第 2 对相同的字符是 E ,那是第 5 个英文字母,代表一天里的第 14 个钟头(于是一天的 0 点到 ...

  4. Win10 Service'MongoDB Server' failed to start. Verify that you have sufficient privileges to start system services【简记】

    最近工作中有需要用到 MongoDB数据库,以前用的3.*的版本,这次用的是较新4.0.6的版本,然后去官网下载安装. 安装到一半,就弹出如下提示,说是"MongoDB Server&quo ...

  5. DB2 因版本问题 Reorg 出错 解决办法

    call Sysproc.admin_cmd('REORG TABLE MY_TABLE_NAME');

  6. 面向对象___str__和__repr__

    老师的博客关于此知识点 http://www.cnblogs.com/Eva-J/articles/7351812.html#_label7 __str__和__repr__ 改变对象的字符串显示__ ...

  7. C# 里面swith的或者

    using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threa ...

  8. [转]C#通过委托更新UI(异步加载)

    我们在使用 windowform 编程的时候,我们或许可能会越到,各种在窗体加载的时候,会进行其他的操作: 1.如果是在加载之前进行其它操作,则整个界面出来的很慢,而且若是时间长的话,页面很久才能出来 ...

  9. WinForm程序完全退出总结

    this.Close();   只是关闭当前窗口,若不是主窗体的话,是无法退出程序的,另外若有托管线程(非主线程),也无法干净地退出: Application.Exit();  强制所有消息中止,退出 ...

  10. Python—kmeans算法学习笔记

    一.   什么是聚类 聚类简单的说就是要把一个文档集合根据文档的相似性把文档分成若干类,但是究竟分成多少类,这个要取决于文档集合里文档自身的性质.下面这个图就是一个简单的例子,我们可以把不同的文档聚合 ...