当前位置:首页 > Web开发 > 正文

"SUCCESS" ]kubectl create -f pod1.yaml kubectl get pods#此时会

2024-03-31 Web开发

标签:

Pod特点 k8s的最小打点单元 一组容器的调集 一个Pod中的容器共享网络命令空间 Pod是短暂的 Pod容器分类

1.infrastructure container 根本容器(维护整个Pod网络空间)

node节点操纵

#检察容器的网络 cat /opt/kubernetes/cfg/kubelet #每次创建Pod时候就会创建,与Pod对应的,,对付用户是透明的,网络组件会被自动加载成一个组件供给出去 docker ps

2.initcontainers 初始化容器

pod在进行创建时必然会被执行傍边的初始化initcontainers, 在老版本中执行时不会区分前后挨次(在系统进行加载时PID号数字越小,优先级别越高,越先被启动), 跟着云平台的改造,启动模式改为主机形式,分隔断绝分手出的初始化容器会被优先加载, 在初始化容器加载完成之后后面的业务容器才华正常接着运行

3.container 业务容器,并行启动

示例

Init containers in use

This example defines a simple Pod that has two init containers. The first waits for myservice, and the second waits for mydb. Once both init containers complete, the Pod runs the app container from its spec section. apiVersion: v1 kind: Pod metadata: name: myapp-pod labels: app: myapp spec: containers: - name: myapp-container image: busybox:1.28 command: [‘sh‘, ‘-c‘, ‘echo The app is running! && sleep 3600‘] initContainers: - name: init-myservice image: busybox:1.28 command: [‘sh‘, ‘-c‘, ‘until nslookup myservice; do echo waiting for myservice; sleep 2; done;‘] - name: init-mydb image: busybox:1.28 command: [‘sh‘, ‘-c‘, ‘until nslookup mydb; do echo waiting for mydb; sleep 2; done;‘] 镜像拉取计谋(image PullPolicy) IfNotPresent:默认值,镜像在宿主机上不存在时才拉取 Always:每次创建Pod城市从头拉取一次镜像 Never:Pod永远不会主动拉取这个镜像

示例:

Verify by creating a pod that uses a private image, e.g.: kubectl apply -f - <<EOF apiVersion: v1 kind: Pod metadata: name: private-image-test-1 spec: containers: - name: uses-private-image image: $PRIVATE_IMAGE_NAME imagePullPolicy: Always command: [ "echo", "SUCCESS" ] EOF 在master1端操纵 kubectl get pods kubectl edit deployment/nginx cd demo/ vim pod1.yaml apiVersion: v1 kind: Pod metadata: name: mypod spec: containers: - name: nginx image: nginx imagePullPolicy: Always command: [ "echo", "SUCCESS" ] kubectl create -f pod1.yaml kubectl get pods #此时会呈现CrashLoopBackOff创建之后又封锁的状态提示 #掉败的状态的原因是因为命令启动斗嘴 #删除 command: [ "echo", "SUCCESS" ] #同时变动一下版本 image: nginx:1.14 #删除原有的资源 kubectl delete -f pod1.yaml #更新资源 kubectl apply -f pod1.yaml #检察分配节点 kubectl get pods -o wide NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE mypod 1/1 Running 0 1m42s 172.17.56.3 192.168.142.130 <none> #在任意node节点使用curl检察头部信息 curl -I 172.17.56.3 HTTP/1.1 200 OK Server: nginx/1.14.2 Date: Sat, 18 Feb 2020 19:32:55 GMT Content-Type: text/html Content-Length: 612 Last-Modified: Tue, 04 Dec 2018 14:44:49 GMT Connection: keep-alive ETag: "5c0692e1-264" Accept-Ranges: bytes 感谢阅读!

Kubernetes--Pod资源打点

标签:

原文地点:https://blog.51cto.com/14449521/2472104

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/29925.html