nginx亲和性配置
一、使用如下yaml即可apiVersion: apps/v1kind: Deploymentmetadata:annotations:deployment.kubernetes.io/revision: "4"generation: 4labels:k8s-app: nginx3qcloud-app: nginx3managedFields:- apiVersion: apps/v1manage
·
一、使用如下yaml即可
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "1"
generation: 1
labels:
k8s-app: nginx
qcloud-app: nginx
managedFields:
- apiVersion: apps/v1
manager: tke-apiserver
operation: Update
- apiVersion: apps/v1
manager: kube-controller-manager
operation: Update
name: nginx3
namespace: default
spec:
progressDeadlineSeconds: 600
replicas: 1
revisionHistoryLimit: 10
selector:
matchLabels:
k8s-app: nginx
strategy:
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
type: RollingUpdate
template:
metadata:
labels:
k8s-app: nginx
qcloud-app: nginx
spec:
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution: #尽量满足条件(调度期间如果满足其中一个亲和性条件则调度到对应node,如果没有节点满足条件则随机调度到任意节点)
- preference:
matchExpressions:
- key: kubernetes
operator: In
values:
- ljx1
weight: 1
requiredDuringSchedulingIgnoredDuringExecution: #强制满足条件(调度期间如果满足其中一个亲和性条件则调度到对应node,如果没有节点满足条件则调度失败)
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes
operator: In
values:
- ljx
containers:
- image: nginx:latest
imagePullPolicy: Always
lifecycle:
postStart:
exec:
command:
- /bin/sh
- '-c'
- su -s /bin/sh -c " chmod -R 777 /data/log/nginxlog"
name: nginx
resources:
limits:
cpu: 500m
memory: 256Mi
requests:
cpu: 250m
memory: 128Mi
securityContext:
privileged: false
dnsPolicy: ClusterFirst
imagePullSecrets:
- name: secret
restartPolicy: Always
schedulerName: default-scheduler
securityContext: {}
terminationGracePeriodSeconds: 30
二、node节点添加label方法
添加label语法
kubectl label nodes <node-name> <label-key>=<label-value>
添加lebel示例
kubectl label node node1 kubernetes=ljx
查看node节点label
kubectl get node --show-labels
三、node节点删除label方法
删除label语法
kubectl label nodes <node-name> <label-key>-
删除label示例
kubectl label node node1 kubernetes-
更多推荐
已为社区贡献45条内容
所有评论(0)