@@ -1058,6 +1058,11 @@ write_files:
1058
1058
"${mfdir}/kube-dns-de.yaml"
1059
1059
{{- end }}
1060
1060
{{ if .KubeDns.NodeLocalResolver -}}
1061
+ {{ if .KubeDns.dnsmasq.CoreDNSLocal.Enabled -}}
1062
+ deploy "${mfdir}/dnsmasq-node-coredns-local.yaml"
1063
+ {{- else }}
1064
+ remove "${mfdir}/dnsmasq-node-coredns-local.yaml"
1065
+ {{ end -}}
1061
1066
deploy "${mfdir}/dnsmasq-node-ds.yaml"
1062
1067
{{ end -}}
1063
1068
forceapply "${mfdir}/kube-dns-pdb.yaml"
@@ -3882,6 +3887,10 @@ write_files:
3882
3887
namespace: kube-system
3883
3888
data:
3884
3889
Corefile: |
3890
+ {{- if and (eq .KubeDns.Provider "coredns") .KubeDns.AdditionalZoneCoreDNSConfig }}
3891
+ {{ .KubeDns.AdditionalZoneCoreDNSConfig | indent 12 }}
3892
+ {{- end }}
3893
+
3885
3894
.:53 {
3886
3895
errors
3887
3896
health
@@ -3904,9 +3913,6 @@ write_files:
3904
3913
reload
3905
3914
loadbalance
3906
3915
}
3907
- {{- if and (eq .KubeDns.Provider "coredns") .KubeDns.AdditionalZoneCoreDNSConfig }}
3908
- {{ .KubeDns.AdditionalZoneCoreDNSConfig | indent 12 }}
3909
- {{- end }}
3910
3916
{{- else }}
3911
3917
- path: /srv/kubernetes/manifests/kube-dns-sa.yaml
3912
3918
content: |
@@ -3969,6 +3975,85 @@ write_files:
3969
3975
- --v=2
3970
3976
- --logtostderr
3971
3977
3978
+ {{ if and .KubeDns.NodeLocalResolver .KubeDns.DNSMasq.CoreDNSLocal.Enabled }}
3979
+ - path: /srv/kubernetes/manifests/dnsmasq-node-coredns-local.yaml
3980
+ content: |
3981
+ apiVersion: v1
3982
+ kind: ServiceAccount
3983
+ metadata:
3984
+ name: dnsmasq
3985
+ namespace: kube-system
3986
+ ---
3987
+ apiVersion: rbac.authorization.k8s.io/v1
3988
+ kind: ClusterRole
3989
+ metadata:
3990
+ name: dnsmasq
3991
+ rules:
3992
+ - apiGroups: [""]
3993
+ resources: ["endpoints", "services", "pods", "namespaces"]
3994
+ verbs: ["list", "watch"]
3995
+ ---
3996
+ apiVersion: rbac.authorization.k8s.io/v1
3997
+ kind: ClusterRoleBinding
3998
+ metadata:
3999
+ name: dnsmasq
4000
+ roleRef:
4001
+ apiGroup: rbac.authorization.k8s.io
4002
+ kind: ClusterRole
4003
+ name: dnsmasq
4004
+ subjects:
4005
+ - kind: ServiceAccount
4006
+ name: dnsmasq
4007
+ namespace: kube-system
4008
+ ---
4009
+ apiVersion: rbac.authorization.k8s.io/v1
4010
+ kind: RoleBinding
4011
+ metadata:
4012
+ name: dnsmasq-privileged-psp
4013
+ namespace: kube-system
4014
+ roleRef:
4015
+ apiGroup: rbac.authorization.k8s.io
4016
+ kind: ClusterRole
4017
+ name: privileged-psp
4018
+ subjects:
4019
+ - kind: ServiceAccount
4020
+ name: dnsmasq
4021
+ namespace: kube-system
4022
+ ---
4023
+ apiVersion: v1
4024
+ kind: ConfigMap
4025
+ metadata:
4026
+ name: coredns-local
4027
+ namespace: kube-system
4028
+ labels:
4029
+ application: coredns
4030
+ data:
4031
+ Corefile: |
4032
+ {{- if and (eq .KubeDns.Provider "coredns") .KubeDns.AdditionalZoneCoreDNSConfig }}
4033
+ {{ .KubeDns.AdditionalZoneCoreDNSConfig | indent 12 }}
4034
+ {{- end }}
4035
+
4036
+ cluster.local:9254 {{ .PodCIDR }}:9254 {{ .ServiceCIDR }}:9254 {
4037
+ errors
4038
+ kubernetes {
4039
+ pods insecure
4040
+ }
4041
+ cache 30
4042
+ log svc.svc.cluster.local.
4043
+ prometheus :9153
4044
+ }
4045
+
4046
+ .:9254 {
4047
+ errors
4048
+ health :9154 # this is global for all servers
4049
+ prometheus :9153
4050
+ forward . /etc/resolv.conf
4051
+ pprof 127.0.0.1:9156
4052
+ cache 30
4053
+ reload
4054
+ }
4055
+ {{ end }}
4056
+
3972
4057
{{ if .KubeDns.NodeLocalResolver }}
3973
4058
- path: /srv/kubernetes/manifests/dnsmasq-node-ds.yaml
3974
4059
content: |
@@ -3980,9 +4065,12 @@ write_files:
3980
4065
labels:
3981
4066
k8s-app: dnsmasq-node
3982
4067
spec:
4068
+ selector:
4069
+ matchLabels:
4070
+ k8s-app: dnsmasq-node
3983
4071
updateStrategy:
3984
4072
rollingUpdate:
3985
- maxUnavailable: 100 %
4073
+ maxUnavailable: 10 %
3986
4074
type: RollingUpdate
3987
4075
template:
3988
4076
metadata:
@@ -3997,22 +4085,29 @@ write_files:
3997
4085
effect: NoSchedule
3998
4086
- operator: Exists
3999
4087
effect: NoExecute
4000
- - operator: Exists
4001
- key: CriticalAddonsOnly
4002
4088
volumes:
4003
4089
- name: kube-dns-config
4004
4090
configMap:
4005
4091
name: kube-dns
4006
4092
optional: true
4093
+ {{ if .KubeDns.DNSMasq.CoreDNSLocal.Enabled }}
4094
+ - name: coredns-local-config
4095
+ configMap:
4096
+ name: coredns-local
4097
+ items:
4098
+ - key: Corefile
4099
+ path: Corefile
4100
+ {{ end }}
4007
4101
containers:
4008
4102
- name: dnsmasq
4009
4103
image: {{ .KubeDnsMasqImage.RepoWithTag }}
4010
4104
livenessProbe:
4011
4105
httpGet:
4012
4106
path: /healthcheck/dnsmasq
4013
- port: 10054
4107
+ port: 9054
4014
4108
scheme: HTTP
4015
4109
initialDelaySeconds: 60
4110
+ periodSeconds: 10
4016
4111
timeoutSeconds: 5
4017
4112
successThreshold: 1
4018
4113
failureThreshold: 5
@@ -4023,13 +4118,24 @@ write_files:
4023
4118
- -restartDnsmasq=true
4024
4119
- --
4025
4120
- -k
4026
- - --min-port=1024
4027
- - --cache-size=1000
4121
+ - --cache-size={{ .KubeDns.DNSMasq.CacheSize }}
4122
+ - --dns-forward-max={{ .KubeDns.DNSMasq.DNSForwardMax }}
4123
+ - --log-facility=-
4124
+ {{ if .KubeDns.DNSMasq.CoreDNSLocal.Enabled }}
4125
+ - --no-resolv
4126
+ - --keep-in-foreground
4127
+ - --neg-ttl={{ .KubeDns.DNSMasq.NegTTL }}
4128
+ # Send requests to the last server (coredns-local) first and only
4129
+ # fallback to the previous one (global coredns) if it's unreachable.
4130
+ - --strict-order
4131
+ - --server={{.DNSServiceIP}}#53
4132
+ - --server=127.0.0.1#9254
4133
+ {{ else }}
4028
4134
- --server=//{{.DNSServiceIP}}
4029
4135
- --server=/cluster.local/{{.DNSServiceIP}}
4030
4136
- --server=/in-addr.arpa/{{.DNSServiceIP}}
4031
4137
- --server=/ip6.arpa/{{.DNSServiceIP}}
4032
- - --log-facility=-
4138
+ {{ end }}
4033
4139
{{- if ne (len .KubeDns.NodeLocalResolverOptions) 0 }}
4034
4140
{{- range .KubeDns.NodeLocalResolverOptions }}
4035
4141
- {{.}}
@@ -4044,9 +4150,11 @@ write_files:
4044
4150
protocol: TCP
4045
4151
# see: https://github.com/kubernetes/kubernetes/issues/29055 for details
4046
4152
resources:
4153
+ limits:
4154
+ cpu: 100m
4155
+ memory: 50Mi
4047
4156
requests:
4048
- cpu: 150m
4049
- memory: 20Mi
4157
+ ephemeral-storage: 256Mi
4050
4158
volumeMounts:
4051
4159
- name: kube-dns-config
4052
4160
mountPath: /etc/k8s/dns/dnsmasq-nanny
@@ -4055,7 +4163,7 @@ write_files:
4055
4163
livenessProbe:
4056
4164
httpGet:
4057
4165
path: /metrics
4058
- port: 10054
4166
+ port: 9054
4059
4167
scheme: HTTP
4060
4168
initialDelaySeconds: 60
4061
4169
timeoutSeconds: 5
@@ -4064,17 +4172,70 @@ write_files:
4064
4172
args:
4065
4173
- --v=2
4066
4174
- --logtostderr
4175
+ {{ if .KubeDns.DNSMasq.CoreDNSLocal.Enabled }}
4176
+ - --probe=dnsmasq,127.0.0.1:9254,ec2.amazonaws.com,5,A
4177
+ {{ else }}
4067
4178
- --probe=dnsmasq,127.0.0.1:53,ec2.amazonaws.com,5,A
4179
+ {{ end }}
4180
+ - --prometheus-port=9054
4068
4181
ports:
4069
- - containerPort: 10054
4182
+ - containerPort: 9054
4070
4183
name: metrics
4071
4184
protocol: TCP
4072
4185
resources:
4073
4186
requests:
4074
- memory: 20Mi
4187
+ ephemeral-storage: 256Mi
4188
+ limits:
4189
+ cpu: 10m
4190
+ memory: 45Mi
4191
+ terminationMessagePath: /dev/termination-log
4192
+ terminationMessagePolicy: File
4193
+ {{ if .KubeDns.DNSMasq.CoreDNSLocal.Enabled }}
4194
+ - name: coredns
4195
+ image: {{ .CoreDnsImage.RepoWithTag }}
4196
+ args: ["-conf", "/etc/coredns/Corefile"]
4197
+ volumeMounts:
4198
+ - name: coredns-local-config
4199
+ mountPath: /etc/coredns
4200
+ ports:
4201
+ - containerPort: 9254
4202
+ name: dns
4203
+ protocol: UDP
4204
+ - containerPort: 9254
4205
+ name: dns-tcp
4206
+ protocol: TCP
4207
+ livenessProbe:
4208
+ httpGet:
4209
+ path: /health
4210
+ port: 9154
4211
+ scheme: HTTP
4212
+ initialDelaySeconds: 60
4213
+ timeoutSeconds: 5
4214
+ successThreshold: 1
4215
+ failureThreshold: 5
4216
+ resources:
4217
+ requests:
4218
+ ephemeral-storage: 256Mi
4219
+ {{ if .KubeDns.DNSMasq.CoreDNSLocal.ComputeResources.Requests.Cpu }}
4220
+ cpu: {{ .KubeDns.DNSMasq.CoreDNSLocal.ComputeResources.Requests.Cpu }}
4221
+ {{ end }}
4222
+ {{ if .KubeDns.DNSMasq.CoreDNSLocal.ComputeResources.Requests.Memory }}
4223
+ memory: {{ .KubeDns.DNSMasq.CoreDNSLocal.ComputeResources.Requests.Memory }}
4224
+ {{ end }}
4225
+ {{ if or .KubeDns.DNSMasq.CoreDNSLocal.ComputeResources.Limits.Cpu .KubeDns.DNSMasq.CoreDNSLocal.ComputeResources.Limits.Memory }}
4226
+ limits:
4227
+ {{ if .KubeDns.DNSMasq.CoreDNSLocal.ComputeResources.Limits.Cpu }}
4228
+ cpu: {{ .KubeDns.DNSMasq.CoreDNSLocal.ComputeResources.Limits.Cpu }}
4229
+ {{ end }}
4230
+ {{ if .KubeDns.DNSMasq.CoreDNSLocal.ComputeResources.Limits.Memory }}
4231
+ memory: {{ .KubeDns.DNSMasq.CoreDNSLocal.ComputeResources.Limits.Memory }}
4232
+ {{ end }}
4233
+ {{ end }}
4234
+ {{ end }}
4075
4235
hostNetwork: true
4076
4236
dnsPolicy: Default
4077
- automountServiceAccountToken: false
4237
+ automountServiceAccountToken: true
4238
+ serviceAccountName: dnsmasq
4078
4239
{{ end }}
4079
4240
4080
4241
{{- if eq .KubeDns.Provider "coredns" }}
0 commit comments