您的位置 首页 k8s

pod的基础管理 命令

asfd

kubectl explain pods.spec.containers

 

 

	- Pod的基础管理
		- kubectl explain
			查看文档的帮助信息。
			举个例子:
				kubectl explain po
				kubectl explain.po.spec
				kubectl explain.po.spec.containers
				
		- kubectl get 
			查看资源的列表 。
			举个例子:
				kubectl get pods 
				kubectl get pods -o wide
				kubectl get pods -o yaml
				kubectl get pods -o json
				
		- Kubectl delete
			删除资源。
			举个例子:
				kubectl delete pods <Pod_name>
				kubectl delete -f xxx.yaml 
				kubectl delete pods --all
				
		- kubectl apply
			更新资源。
			举个例子:
				kubectl apply -f xxx.yaml
				
		- kubectl exec
			连接Pod的容器
			举个例子:
				kubectl exec <Pod_name> -- COMMAND ARGS
				kubectl exec -it <Pod_name> -c <container_name> -- COMMAND ARGS
				
		- kubectl describe
			查看资源你的详细信息。
			举个例子:
				kubectl describe pods [<Pod_name>]
				kubectl describe nodes [<Node_name>]

 

- 编写Pod的资源清单

 

apiVersion: v1
kind: Pod
meta_data:
  name: 
spec:
  nodeName:
  hostNetwork:
  RestartPolicy: Always|Never|OnFailure
  containers:  
  - name:
    image:
	command:
	env:
	- name:
	  value:
	imagePullPolicy: Always|Never|IfNotPresent
	resources:
	   requests:
	     cpu:
		 memory:
	   limits:
	     cpu:
		 memory:
	ports:
    - containerPort: 9200
      hostIP: 0.0.0.0
      hostPort: 9200
      name: es-webui
      protocol: TCP|UDP|SCTP
    - containerPort: 9300
	  name: es-data

 

demo

apiVersion: v1
kind: Pod
metadata:
  name: image-resources-stress-04
spec:
  # nodeName: worker232
  nodeName: work232
  restartPolicy: Always
  containers: 
  - name: stress
    image: jasonyin2020/baimeidashuedu-linux-tools:v0.1
   
    imagePullPolicy: Always
    command: ["tail","-f","/etc/hosts"]
    # 配置资源限制
    resources:
      # 指定容器期望资源,若满足不了,则无法完成调度
      requests:
        # 指定内存限制
        memory: "4G"
        # memory: "200M"
        # 1core=1000m
        cpu: "250m"
      # 指定资源的上限
      limits:
        # memory: "500M"
        memory: "4G"
        # 表示使用1.5core,即1500m
        cpu: 1.5
        #cpu: 0.5

 

欢迎来撩 : 汇总all

白眉大叔

关于白眉大叔linux云计算: 白眉大叔

热门文章