需要的博友请联系誉天教育()
标签:
一 pod简介 1.1 介绍Pod是K8s集群中所有业务类型的根本
Pod是在K8s集群中运行部署应用或处事的最小单元,它是可以撑持多容器的。
Pod的设计理念是撑持多个容器在一个Pod中共享网络地点和文件系统
pod和容器的区别就是,一个pod可以有多个容器,当一个pod只有一个容器的时候,访谒pod就是访谒容器,对付一个kubernets来说,一个pods至少有两个容器,一个是不偏见的,称为pause容器,另一个就是业务容器
pod是一个逻辑观点,pod中的一个容器异常,整个pod从头创建
Kubernetes为每个Pod都分配了独一的IP地点,称之为PodIP,一个Pod里的多个容器共享PodIP地点。要求底层网络撑持集群内任意两个Pod之间的直接通信,凡是给与虚拟二层网络技术来实现(Flannel)。
POD可以与其它主机上的POD直接通讯。
如果有POD不测遏制,K8S会按照资源设定重启或创建POD,直到切合预期设定值
pause容器劫持业务容器的所有流量,IP是配置在pause容器的,在创建pod的时候,自动创建,用来接管容器网络
1.2 pod的一个应用场景pod含有两个容器,File Puller先于web server容器启动
拉代替码放到volume中,然后自毁
web server容器启动,读物volume的代码,用于用户访谒
二 POD简单操纵 2.1 创建一个关于nginx的pods[[email protected] namespace]# cd ../
[[email protected] yamls]# mkdir pods
[[email protected] yamls]# cd pods
[[email protected] pods]# vi nginx-pods.yaml
apiVersion: v1 kind: Pod metadata: name: nginx labels: app: nginx annotations: test: this is a test app spec: #资源描述信息 containers: - name: nginx image: nginx ports: - containerPort: 80
这是一个最简单的pods,只是运行一个nginx的业务,没有任何其他的对象
[[email protected] pods]# kubectl apply -f nginx-pods.yaml
由于没有指定ns,所以pods运行在defaults中,检察
[[email protected] pods]# kubectl get pods
NAME READY STATUS RESTARTS AGE nginx 1/1 Running 0 85s
1/1:后面的1暗示这个pods运行了几个容器,前面的1暗示几个容器处于redy状态
检察容器
[[email protected] pods]# kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES nginx 1/1 Running 0 6m41s 10.244.2.6 192.168.132.133 <none> <none>
访谒
[[email protected] pods]# curl
<!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://www.mamicode.com/"">nginx.org</a>.<br/> Commercial support is available at <a href=http://www.mamicode.com/"">nginx.com</a>.</p> <p><em>Thank you for using nginx.</em></p> </body> </html>
2.2 配置映射端口[[email protected] pods]# vim nginx-pods.yaml
apiVersion: v1 kind: Pod metadata: name: nginx labels: app: nginx spec: hostNetwork: true containers: - name: nginx image: nginx ports: - containerPort: 80
[[email protected] pods]# kubectl delete -f nginx-pods.yaml
[[email protected] pods]# kubectl create -f nginx-pods.yaml
[[email protected] pods]# kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES nginx 0/1 ContainerCreating 0 4s 192.168.132.133 192.168.132.133 <none> <none>
[[email protected] pods]# kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES nginx 1/1 Running 0 95s 192.168.132.133 192.168.132.133 <none> <none>
2.3 pod常用配置温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/31734.html
- 上一篇:根据不同操作系统选择不同的版本
- 下一篇:请提供认证密钥 容器如果挂掉了