# my-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: my-pod
labels:
app: webserver
tier: backend
annotations:
version: latest
release_date: 2017/12/28
contact: baoguo.ding@foxmail.com
spec:
containers:
- name: pod-demo
image: baoguoding/demo
ports:
- containerPort: 3000
kubectl create -f my-pod.yaml
kubectl get pod --show-labels
kubectl describe pod my-pod
kubectl label pod my-pod env=production
kubectl get pods --show-labels
kubectl edit pod my-pod
---
kubectl get nodes --show-lables
# my-pod-with-node-selector.yaml
apiVersion: v1
kind: Pod
metadata:
name: my-pod
labels:
app: webserver
tier: backend
annotations:
version: latest
release_date: 2017/12/28
contact: baoguo.ding@foxmail.com
spec:
containers:
- name: pod-demo
image: baoguoding/demo
ports:
- containerPort: 3000
nodeSelector:
hardware: high-memory
kubectl create -f my-pod-with-node-selector.yaml
kubectl describe pod my-pod
kubectl label node <node-name> hardware=high-memory
kubectl get pods
kubectl describe pod my-pod
参考