当前位置:网站首页>Detailed explanation of kubernetes (IX) -- actual combat of creating pod with resource allocation list

Detailed explanation of kubernetes (IX) -- actual combat of creating pod with resource allocation list

2022-04-23 15:12:00 Always a teenager

Today I will continue to introduce Linux Operation and maintenance related knowledge , The main content of this paper is to create a resource allocation list Pod actual combat .

One 、 Preparation of resource allocation list

Above Kubernetes Detailed explanation ( 8、 ... and )——Kubernetes Resource allocation list in , We introduced Kubernetes Common fields of resource configuration list , today , Let's use the resource allocation list , To actually generate one Pod object , So as to show Kubernetes The role of the resource allocation list .
First , Let's create a resource configuration manifest file pod-demo-test.yaml, And write the following :

apiVersion: v1
kind: Pod
metadata:
  name: pod-demo-test
  namespace: default
  labels:
    label1: mypod1
    label2: mypod2
spec:
  containers:
  - name: container
    image: ikubernetes/myapp:v1
  - name: busybox
    image: busybox
    command:
    - "/bin/bash"
    - "-c"
    - "sleep 7200"

In this resource list , We define a Pod object , The previous contents are basically fixed , And already in Kubernetes Detailed explanation ( 8、 ... and )——Kubernetes Resource allocation list In this article, I introduced . Back spec Under the field , We mainly have containers Field of , This field defines the Pod Containers within resources ,name Field defines the name of the container ;image Field defines the image of the container ;command Field defines the command to be executed after the container is run . It can be seen that , In the Pod In the resource object , We define two containers , One is myapp, One is busybox.
After the resource object is configured , As shown below :
 Insert picture description here

Two 、 Resource configuration list creation Pod

After the resource list is completed , We can create a..., based on the resource list Pod Resource object .
Carry out orders :

kubectl create -f pod-demo.test.yaml

Can make Kubernetes Create one according to the configuration of our resource list Pod object . In the above order ,-f Parameter specifies a file , Followed by the file name .
Be careful : What we're using here is YAML The format of ,YAML The format is very strict with spaces and indents , Therefore, we should pay special attention to !
The execution result of this command is as follows :
 Insert picture description here
After the command is executed , We can check the Pod object , Carry out orders :

kubectl describe pods pod-demo-test

The execution result of this command is as follows :
 Insert picture description here

3、 ... and 、 Mirror image and Pod Medium Command Relationship description

Last , Let's talk about the following images and Pod Medium Command The relationship between orders .
In the resource configuration list , We configured... Under the image command command , And it's actually Pod Under the resource list , We can also configure CMD( similar Command). And in the mirror and Pod We can also configure args Variable ( Yes in the mirror ENTRYPOINT). Mirror down and Pod Medium Command Command and args The parameter configuration relationship is as follows :
1、 If Pod No configuration in Command and args, Then... In the image is used CMD and ENTRYPOINT
2、 If Pod Set up in Command, But no args, Then use Pod Medium Command, Ignore... In the mirror CMD and ENTRYPOINT
3、 If Pod Only args, be args Give as a parameter to... In the mirror ENTRYPOINT Use .
4、 If Pod And in the image Command and args, So in the mirror CMD and ENTRYPINT Will be ignored ,Pod Medium Command and args Will be used .
Originality is not easy. , Reprint please explain the source :https://blog.csdn.net/weixin_40228200

版权声明
本文为[Always a teenager]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231507194557.html