概述
通常Kubernetes Master节点上会有污点Taints,如果希望DaemonSet运行在Kubernetes所有节点上则需要在Pod Spec层级添加对应tolerations。
1. 查看Master节点Tolerations
可以通过kuberctl describe nodes 查看指定Master Taints
[root@k8s~]# kubectl describe nodes kubernetes-master01
Name: kubernetes-master01
Roles: controlplane,etcd
Labels: beta.kubernetes.io/arch=amd64
beta.kubernetes.io/os=linux
kubernetes.io/arch=amd64
kubernetes.io/hostname=kubernetes-master01
kubernetes.io/os=linux
node-role.kubernetes.io/controlplane=true
node-role.kubernetes.io/etcd=true
Annotations: flannel.alpha.coreos.com/backend-data: {"VtepMAC":"ca:89:74:c4:d1:5d"}
flannel.alpha.coreos.com/backend-type: vxlan
flannel.alpha.coreos.com/kube-subnet-manager: true
flannel.alpha.coreos.com/public-ip: 10.10.10.1
node.alpha.kubernetes.io/ttl: 0
projectcalico.org/IPv4IPIPTunnelAddr: 10.42.1.1
rke.cattle.io/external-ip: 10.10.10.1
rke.cattle.io/internal-ip: 10.10.10.1
volumes.kubernetes.io/controller-managed-attach-detach: true
CreationTimestamp: Sat, 27 Jun 2020 19:06:44 +0800
Taints: node-role.kubernetes.io/etcd=true:NoExecute
node-role.kubernetes.io/controlplane=true:NoSchedule
Unschedulable: false
Lease:
HolderIdentity: kubernetes-master01
AcquireTime: <unset>
RenewTime: Sun, 19 Jul 2020 17:30:00 +0800
2. 在DaemonSet YAML中配置Tolerations
在pod spec层级下添加tolerations对应Master节点上的Taints。
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: daemonset-test
namespace: demo
spec:
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
tolerations:
- key: node-role.kubernetes.io/controlplane
operator: Exists
effect: NoSchedule
- key: node-role.kubernetes.io/etcd
operator: Exists
effect: NoExecute
containers:
- name: nginx
image: nginx:latest
imagePullPolicy: IfNotPresent
3. 查看效果
可以看到DaemonSet在Kubernetes所有节点上都运行了一个Pod。
[root@k8s ~]# kubectl get pod -n demo -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
daemonset-test-9tq2n 1/1 Running 0 26m 10.42.2.2 kubernetes-master03 <none> <none>
daemonset-test-pxqdf 1/1 Running 0 26m 10.42.0.2 kubernetes-master02 <none> <none>
daemonset-test-gxc8j 1/1 Running 0 26m 10.42.1.3 kubernetes-master01 <none> <none>
daemonset-test-2vd94 1/1 Running 0 26m 10.42.5.93 kubernetes-node01 <none> <none>
daemonset-test-wnsdc 1/1 Running 0 26m 10.42.4.145 kubernetes-node03 <none> <none>
daemonset-test-zz9wp 1/1 Running 0 26m 10.42.3.22 kubernetes-node02 <none> <none>
最后
以上就是要减肥汽车为你收集整理的Kubernetes 在Master节点上运行DaemonSet的全部内容,希望文章能够帮你解决Kubernetes 在Master节点上运行DaemonSet所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复