k8s固定pod在某一节点, node添加Label
基本信息:172.16.207.4 172.16.207.5 172.16.207.6容器:claimlog配置文件:claimlog.yamlkind: DeploymentapiVersion: extensions/v1beta1metadata:labels:app: devops-claimlogname: deploy-devops-claimlog...
基本信息:172.16.207.4 172.16.207.5 172.16.207.6
容器:claimlog
配置文件:claimlog.yaml
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
labels:
app: devops-claimlog
name: deploy-devops-claimlog
namespace: chesun-test
spec:
replicas: 1
selector:
matchLabels:
app: devops-claimlog
template:
metadata:
labels:
app: devops-claimlog
# Comment the following annotation if Dashboard must not be deployed on master
#annotations:
# scheduler.alpha.kubernetes.io/tolerations: |
# [
# {
# "key": "dedicated",
# "operator": "Equal",
# "value": "master",
# "effect": "NoSchedule"
# }
# ]
spec:
nodeSelector:
name: 172.16.207.6
containers:
- name: devops-claimlog
image: 172.16.207.205/chesun-test/claimlog:2020-01-03_14_55_57
#command: ["/apps/openresty/openresty"]
imagePullPolicy: Always
#securityContext:
# privileged: true
ports:
- containerPort: 20990
protocol: TCP
---
kind: Service
apiVersion: v1
metadata:
labels:
app: devops-claimlog
name: srv-devops-claimlog
namespace: chesun-test
spec:
type: NodePort
ports:
- name: http
port: 20990
targetPort: 20990
# nodePort: 30006
selector:
app: devops-claimlog
sessionAffinity: ClientIP
sessionAffinityConfig:
clientIP:
timeoutSeconds: 10800
查看现有node及label: kubectl get node --show-labels
添加label: kubectl label nodes <node-name> <label-key>=<label-value>
kubectl label nodes 172.16.207.6 name=172.16.207.6
删除label: kubectl label nodes <node-name> <label-key>
修改Label的值: kubectl label nodes <node-name> <label-key>=<label-value> --overwrite
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
labels:
app: devops-claimlog
name: deploy-devops-claimlog
namespace: chesun-test
spec:
replicas: 1
selector:
matchLabels:
app: devops-claimlog
template:
metadata:
labels:
app: devops-claimlog
# Comment the following annotation if Dashboard must not be deployed on master
#annotations:
# scheduler.alpha.kubernetes.io/tolerations: |
# [
# {
# "key": "dedicated",
# "operator": "Equal",
# "value": "master",
# "effect": "NoSchedule"
# }
# ]
spec:
nodeSelector:
name: 172.16.207.6
containers:
- name: devops-claimlog
image: 172.16.207.205/chesun-test/claimlog:2020-01-03_14_55_57
#command: ["/apps/openresty/openresty"]
imagePullPolicy: Always
#securityContext:
# privileged: true
ports:
- containerPort: 20990
protocol: TCP
重新应用一下: kubectl apply -f claimlog.yaml
更多推荐
所有评论(0)