Kubenete study notes (POD)

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

猜你喜欢

转载自blog.51cto.com/shadowisper/2476295