@@ -1160,9 +1160,14 @@ write_files:
1160
1160
"${mfdir}/kube-dns-autoscaler-de.yaml" \
1161
1161
"${mfdir}/kube-dns-de.yaml"
1162
1162
{{- end }}
1163
- {{ if .KubeDns.NodeLocalResolver -}}
1163
+ {{- if .KubeDns.NodeLocalResolver }}
1164
+ {{- if .KubeDns.DNSMasq.CoreDNSLocal.Enabled }}
1165
+ deploy "${mfdir}/dnsmasq-node-coredns-local.yaml"
1166
+ {{- else }}
1167
+ remove "${mfdir}/dnsmasq-node-coredns-local.yaml"
1168
+ {{- end }}
1164
1169
deploy "${mfdir}/dnsmasq-node-ds.yaml"
1165
- {{ end - }}
1170
+ {{- end }}
1166
1171
forceapply "${mfdir}/kube-dns-pdb.yaml"
1167
1172
1168
1173
{{ if .Addons.MetricsServer.Enabled -}}
@@ -5384,6 +5389,9 @@ write_files:
5384
5389
namespace: kube-system
5385
5390
data:
5386
5391
Corefile: |
5392
+ {{- if and (eq .KubeDns.Provider "coredns") .KubeDns.AdditionalZoneCoreDNSConfig }}
5393
+ {{ .KubeDns.AdditionalZoneCoreDNSConfig | indent 10 }}
5394
+ {{- end }}
5387
5395
.:53 {
5388
5396
errors
5389
5397
health
@@ -5406,9 +5414,6 @@ write_files:
5406
5414
reload
5407
5415
loadbalance
5408
5416
}
5409
- {{- if and (eq .KubeDns.Provider "coredns") .KubeDns.AdditionalZoneCoreDNSConfig }}
5410
- {{ .KubeDns.AdditionalZoneCoreDNSConfig | indent 10 }}
5411
- {{- end }}
5412
5417
{{- else }}
5413
5418
- path: /srv/kubernetes/manifests/kube-dns-sa.yaml
5414
5419
content: |
@@ -5474,9 +5479,86 @@ write_files:
5474
5479
- --v=2
5475
5480
- --logtostderr
5476
5481
5482
+ - path: /srv/kubernetes/manifests/dnsmasq-node-coredns-local.yaml
5483
+ content: |
5484
+ apiVersion: v1
5485
+ kind: ConfigMap
5486
+ metadata:
5487
+ name: coredns-local
5488
+ namespace: kube-system
5489
+ labels:
5490
+ application: coredns
5491
+ data:
5492
+ Corefile: |
5493
+ {{- if and (eq .KubeDns.Provider "coredns") .KubeDns.AdditionalZoneCoreDNSConfig }}
5494
+ {{ .KubeDns.AdditionalZoneCoreDNSConfig | indent 12 }}
5495
+ {{- end }}
5496
+
5497
+ cluster.local:9254 {{ .PodCIDR }}:9254 {{ .ServiceCIDR }}:9254 {
5498
+ errors
5499
+ kubernetes {
5500
+ pods insecure
5501
+ }
5502
+ cache 30
5503
+ log svc.svc.cluster.local.
5504
+ prometheus :9153
5505
+ }
5506
+
5507
+ .:9254 {
5508
+ errors
5509
+ health :9154 # this is global for all servers
5510
+ prometheus :9153
5511
+ forward . /etc/resolv.conf
5512
+ pprof 127.0.0.1:9156
5513
+ cache 30
5514
+ reload
5515
+ }
5516
+
5477
5517
{{ if .KubeDns.NodeLocalResolver }}
5478
5518
- path: /srv/kubernetes/manifests/dnsmasq-node-ds.yaml
5479
5519
content: |
5520
+ apiVersion: v1
5521
+ kind: ServiceAccount
5522
+ metadata:
5523
+ name: dnsmasq
5524
+ namespace: kube-system
5525
+ ---
5526
+ apiVersion: rbac.authorization.k8s.io/v1
5527
+ kind: ClusterRole
5528
+ metadata:
5529
+ name: dnsmasq
5530
+ rules:
5531
+ - apiGroups: [""]
5532
+ resources: ["endpoints", "services", "pods", "namespaces"]
5533
+ verbs: ["list", "watch"]
5534
+ ---
5535
+ apiVersion: rbac.authorization.k8s.io/v1
5536
+ kind: ClusterRoleBinding
5537
+ metadata:
5538
+ name: dnsmasq
5539
+ roleRef:
5540
+ apiGroup: rbac.authorization.k8s.io
5541
+ kind: ClusterRole
5542
+ name: dnsmasq
5543
+ subjects:
5544
+ - kind: ServiceAccount
5545
+ name: dnsmasq
5546
+ namespace: kube-system
5547
+ ---
5548
+ apiVersion: rbac.authorization.k8s.io/v1
5549
+ kind: RoleBinding
5550
+ metadata:
5551
+ name: dnsmasq-privileged-psp
5552
+ namespace: kube-system
5553
+ roleRef:
5554
+ apiGroup: rbac.authorization.k8s.io
5555
+ kind: ClusterRole
5556
+ name: privileged-psp
5557
+ subjects:
5558
+ - kind: ServiceAccount
5559
+ name: dnsmasq
5560
+ namespace: kube-system
5561
+ ---
5480
5562
apiVersion: apps/v1
5481
5563
kind: DaemonSet
5482
5564
metadata:
@@ -5485,9 +5567,12 @@ write_files:
5485
5567
labels:
5486
5568
k8s-app: dnsmasq-node
5487
5569
spec:
5570
+ selector:
5571
+ matchLabels:
5572
+ k8s-app: dnsmasq-node
5488
5573
updateStrategy:
5489
5574
rollingUpdate:
5490
- maxUnavailable: 100 %
5575
+ maxUnavailable: 10 %
5491
5576
type: RollingUpdate
5492
5577
selector:
5493
5578
matchLabels:
@@ -5512,15 +5597,24 @@ write_files:
5512
5597
configMap:
5513
5598
name: kube-dns
5514
5599
optional: true
5600
+ {{ if .KubeDns.DNSMasq.CoreDNSLocal.Enabled }}
5601
+ - name: coredns-local-config
5602
+ configMap:
5603
+ name: coredns-local
5604
+ items:
5605
+ - key: Corefile
5606
+ path: Corefile
5607
+ {{ end }}
5515
5608
containers:
5516
5609
- name: dnsmasq
5517
5610
image: {{ .KubeDnsMasqImage.RepoWithTag }}
5518
5611
livenessProbe:
5519
5612
httpGet:
5520
5613
path: /healthcheck/dnsmasq
5521
- port: 10054
5614
+ port: 9054
5522
5615
scheme: HTTP
5523
5616
initialDelaySeconds: 60
5617
+ periodSeconds: 10
5524
5618
timeoutSeconds: 5
5525
5619
successThreshold: 1
5526
5620
failureThreshold: 5
@@ -5531,13 +5625,24 @@ write_files:
5531
5625
- -restartDnsmasq=true
5532
5626
- --
5533
5627
- -k
5534
- - --min-port=1024
5535
- - --cache-size=1000
5628
+ - --cache-size={{ .KubeDns.DNSMasq.CacheSize }}
5629
+ - --dns-forward-max={{ .KubeDns.DNSMasq.DNSForwardMax }}
5630
+ - --log-facility=-
5631
+ {{ if .KubeDns.DNSMasq.CoreDNSLocal.Enabled }}
5632
+ - --no-resolv
5633
+ - --keep-in-foreground
5634
+ - --neg-ttl={{ .KubeDns.DNSMasq.NegTTL }}
5635
+ # Send requests to the last server (coredns-local) first and only
5636
+ # fallback to the previous one (global coredns) if it's unreachable.
5637
+ - --strict-order
5638
+ - --server={{.DNSServiceIP}}#53
5639
+ - --server=127.0.0.1#9254
5640
+ {{ else }}
5536
5641
- --server=//{{.DNSServiceIP}}
5537
5642
- --server=/cluster.local/{{.DNSServiceIP}}
5538
5643
- --server=/in-addr.arpa/{{.DNSServiceIP}}
5539
5644
- --server=/ip6.arpa/{{.DNSServiceIP}}
5540
- - --log-facility=-
5645
+ {{ end }}
5541
5646
{{- if ne (len .KubeDns.NodeLocalResolverOptions) 0 }}
5542
5647
{{- range .KubeDns.NodeLocalResolverOptions }}
5543
5648
- {{.}}
@@ -5553,8 +5658,10 @@ write_files:
5553
5658
# see: https://github.com/kubernetes/kubernetes/issues/29055 for details
5554
5659
resources:
5555
5660
requests:
5556
- cpu: 150m
5557
- memory: 20Mi
5661
+ ephemeral-storage: 256Mi
5662
+ limits:
5663
+ cpu: 10m
5664
+ memory: 45Mi
5558
5665
volumeMounts:
5559
5666
- name: kube-dns-config
5560
5667
mountPath: /etc/k8s/dns/dnsmasq-nanny
@@ -5563,7 +5670,7 @@ write_files:
5563
5670
livenessProbe:
5564
5671
httpGet:
5565
5672
path: /metrics
5566
- port: 10054
5673
+ port: 9054
5567
5674
scheme: HTTP
5568
5675
initialDelaySeconds: 60
5569
5676
timeoutSeconds: 5
@@ -5572,17 +5679,70 @@ write_files:
5572
5679
args:
5573
5680
- --v=2
5574
5681
- --logtostderr
5682
+ {{ if .KubeDns.DNSMasq.CoreDNSLocal.Enabled }}
5683
+ - --probe=dnsmasq,127.0.0.1:9254,ec2.amazonaws.com,5,A
5684
+ {{ else }}
5575
5685
- --probe=dnsmasq,127.0.0.1:53,ec2.amazonaws.com,5,A
5686
+ {{ end }}
5687
+ - --prometheus-port=9054
5576
5688
ports:
5577
- - containerPort: 10054
5689
+ - containerPort: 9054
5578
5690
name: metrics
5579
5691
protocol: TCP
5580
5692
resources:
5581
5693
requests:
5582
- memory: 20Mi
5694
+ ephemeral-storage: 256Mi
5695
+ limits:
5696
+ cpu: 100m
5697
+ memory: 50Mi
5698
+ terminationMessagePath: /dev/termination-log
5699
+ terminationMessagePolicy: File
5700
+ {{ if .KubeDns.DNSMasq.CoreDNSLocal.Enabled }}
5701
+ - name: coredns
5702
+ image: {{ .CoreDnsImage.RepoWithTag }}
5703
+ args: ["-conf", "/etc/coredns/Corefile"]
5704
+ volumeMounts:
5705
+ - name: coredns-local-config
5706
+ mountPath: /etc/coredns
5707
+ ports:
5708
+ - containerPort: 9254
5709
+ name: dns
5710
+ protocol: UDP
5711
+ - containerPort: 9254
5712
+ name: dns-tcp
5713
+ protocol: TCP
5714
+ livenessProbe:
5715
+ httpGet:
5716
+ path: /health
5717
+ port: 9154
5718
+ scheme: HTTP
5719
+ initialDelaySeconds: 60
5720
+ timeoutSeconds: 5
5721
+ successThreshold: 1
5722
+ failureThreshold: 5
5723
+ resources:
5724
+ requests:
5725
+ ephemeral-storage: 256Mi
5726
+ {{ if .KubeDns.DNSMasq.CoreDNSLocal.ComputeResources.Requests.Cpu }}
5727
+ cpu: {{ .KubeDns.DNSMasq.CoreDNSLocal.ComputeResources.Requests.Cpu }}
5728
+ {{ end }}
5729
+ {{ if .KubeDns.DNSMasq.CoreDNSLocal.ComputeResources.Requests.Memory }}
5730
+ memory: {{ .KubeDns.DNSMasq.CoreDNSLocal.ComputeResources.Requests.Memory }}
5731
+ {{ end }}
5732
+ {{ if or .KubeDns.DNSMasq.CoreDNSLocal.ComputeResources.Limits.Cpu .KubeDns.DNSMasq.CoreDNSLocal.ComputeResources.Limits.Memory }}
5733
+ limits:
5734
+ {{ if .KubeDns.DNSMasq.CoreDNSLocal.ComputeResources.Limits.Cpu }}
5735
+ cpu: {{ .KubeDns.DNSMasq.CoreDNSLocal.ComputeResources.Limits.Cpu }}
5736
+ {{ end }}
5737
+ {{ if .KubeDns.DNSMasq.CoreDNSLocal.ComputeResources.Limits.Memory }}
5738
+ memory: {{ .KubeDns.DNSMasq.CoreDNSLocal.ComputeResources.Limits.Memory }}
5739
+ {{ end }}
5740
+ {{ end }}
5741
+ {{ end }}
5583
5742
hostNetwork: true
5584
5743
dnsPolicy: Default
5585
- automountServiceAccountToken: false
5744
+ automountServiceAccountToken: true
5745
+ serviceAccountName: dnsmasq
5586
5746
{{ end }}
5587
5747
5588
5748
{{- if eq .KubeDns.Provider "coredns" }}
0 commit comments