K8s pod 应用

/**

个人学习笔记,如有问题欢迎交流,文章编排和格式等问题见谅!

*/

(1)编写 pod.yaml 文件

pod 是 kubernetes 中最小的编排单位,一个 pod 里包含一个或多个容器。

apiVersion: v1 # 指定api版本
kind: Pod # kind: string类型,指定资源类型,例如Pod,Deployment,Service等
metadata: #资源的元数据/属性
  name: nginx #资源的名字,在同一个namespace中必须唯一
  labels: #设定资源的标签,详情请见http://blog.csdn.net/liyingke112/article/details/77482384
    app: nginx
spec:
  containers:
  - name: nginx
    image: nginx:alpine # 指定镜像
    ports: # 指定暴露端口
    - containerPort: 80

(2)部署 pod

kubectl apply -f pod.yaml

(3)查看 pod 情况

kubectl get pods
kubectl get pods -o wide
kubectl describe pod nginx

(4)删除 pod

kubectl delete -f pod.yaml

docker 配置镜像源:

# 创建或修改 /etc/docker/daemon.json 文件,修改为如下形式
{
    "registry-mirrors" : [
    "https://registry.docker-cn.com",
    "https://docker.mirrors.ustc.edu.cn",
    "http://hub-mirror.c.163.com",
    "https://cr.console.aliyun.com/"
  ]
}
# 重启docker服务使配置生效
$ systemctl restart docker.service

错误:

[node@k8s-node-2 ~]$ sudo docker pull registry.access.redhat.com/rhel7/pod-infrastructure:latest
Trying to pull repository registry.access.redhat.com/rhel7/pod-infrastructure ...
open /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt: no such file or directory

解决方法:

创建一个空白的缺少的文件即可。

如果还有错误,尝试执行如下命令:

yum install *rhsm* -y

参考链接:

https://www.cnblogs.com/lp19910807/p/10529746.html

docker国内镜像源_docker镜像源_zlzhaoe的博客-CSDN博客 

猜你喜欢

转载自blog.csdn.net/u011074149/article/details/131269161