Kubenete study notes (POD)

坚强是说给别人听的谎言 提交于 2020-04-03 17:09:42

Pod Definition:

Create pod by definition: kubectl create -f [filename]
Display pod definition: kubectl get po [pod name] -o yaml/json
Getting log: kubectl logs [pod name] -c [container name]

Port forwarding: kubectl port-forward [pod name] [localport]:[pod port]
Delete pod:
kubectl delete po [pod name]
kubectl delete po -l [label name=value]
kubectl delete ns deletes all pods in a namespace
kubectl delete po --all -n [namespace]

Spec/containers/image specify container image to use in pod
Spec/containers/port is just for information:

Labels:
App: which specifies which app, component, or microservice the pod belongs to.
Rel: which shows whether the application running in the pod is a stable, beta,
or a canary release.
Attach label:
kubectl label po [pod name] [label name=value] --overwrite
kubectl label node [node name] [label name=value] --overwrite

Label selector: kubectl get po -l [label selector]
Use label selector to schedule pod so that it satisfy different hardware requirements
Schedule pod to a set of nodes: Use nodeSelector in pod definition: Spec/nodeSelector/
Schedule pod to specific node: Set nodeSelector to kubernetes.io/hostname=xxx

Annotation:
Used to introduce new features in kubenete

Namespace:
Resource names only need to be unique within a namespace. Two different namespaces can contain resources of the same name. Can be used to implement multi-tenancy
Namespace can be used to limit resource usage and access right
Node is not tied to namespace.
kubectl create -f [yaml file name] namespace [xxx] to create pod that ties to a specific namespace

Pod failure can be recovered by kubelet while node failure needs to be recovered by replicationController

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!