BlueXIII's Blog

热爱技术,持续学习

0%

K8S常用配置

亲和性

https://tachingchen.com/tw/blog/kubernetes-assigning-pod-to-nodes/

1
2
kubectl get nodes --show-labels
kubectl label nodes worker-s001 dubhe/role=middleware

deploy.yaml:

1
2
3
4
5
6
7
8
9
10
11
12
13
spec:
template:
spec:
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
preference:
matchExpressions:
- key: dubhe/role
operator: In
values:
- middleware

coredns自定义解析

1
2
3
4
5
6
7
8
9
10
11
12
13
# 编辑configmap
kubectl -n kube-system edit configmap coredns

# 添加自定义解析
hosts /etc/coredns/NodeHosts {
10.193.36.252 harbor.dubhe
10.193.36.33 gogs.dubhe
ttl 60
reload 15s
fallthrough
}

# 重启coredns的deployment