nodeSelector
: assgin a pod to a node via kube-schedulerapiVersion: v1 kind: Pod metadata: name: nginx spec: containers: - image: nginx name: nginx nodeSelector: kubernetes.io/hostname: target-node
nodeName
: manually assgin pod to node by kubelet, skipping kube-schedulerapiVersion: v1 kind: Pod metadata: name: nginx spec: containers: - image: nginx name: nginx nodeName: target-node
Select resources by label
$ kubectl get pods --selector="environment=prod" $ kubectl get all -l="environment=prod,tier=backend"
Create a taint & remove a taint
$ kubectl taint nodes production-node env=prod:NoSchedule $ kubectl taint nodes production-node env=prod:NoSchedule- # -
Create a pod which tolerates the taint
# backend-prod.yaml apiVersion: v1 kind: Pod metadata: creationTimestamp: null labels: run: backend-prod name: backend-prod spec: containers: - image: busybox name: backend-prod resources: {} tolerations: - key: env value: prod operator: Equal effect: NoSchedule dnsPolicy: ClusterFirst restartPolicy: Always status: {}
Add a label to node
$ kubectl label nodes <your-node-name> disktype=ssd
Create a deployment which has an node affinity rule
apiVersion: v1 kind: Pod metadata: name: nginx spec: affinity: nodeAffinity: preferredDuringSchedulingIgnoredDuringExecution: - weight: 1 preference: matchExpressions: - key: disktype operator: In values: - ssd containers: - name: nginx image: nginx
Control CPU and memory usage per container
apiVersion: v1 kind: Pod metadata: name: frontend spec: containers: - name: app image: images.my-company.example/app:v4 resources: requests: memory: "64Mi" cpu: "250m" limits: memory: "128Mi" cpu: "500m"
Static Pod의 yaml 파일 위치는 kubelet 실행 시 설정 값(
kubelet --config=/var/lib/kubelet/config.yaml
)에서 확인할 수 있다. 기본 값은/etc/kubernetes/manifes
이다.