Merge pull request #16347 from rifelpet/dnsnone-coredns

Include /etc/hosts coredns mounts for dns=none clusters
This commit is contained in:
Kubernetes Prow Robot 2024-02-10 23:02:38 -08:00 committed by GitHub
commit 01f4382676
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 47 additions and 12 deletions

View File

@ -14,7 +14,7 @@ spec:
version: 9.99.0
- id: k8s-1.12
manifest: coredns.addons.k8s.io/k8s-1.12.yaml
manifestHash: d2bbb7cbee5835c3891fe80fbacf8963508359ef9159f8480325ce9a7174f14a
manifestHash: 881d2ec248edb7ef6466985a51f30b4d50ec3e5f4997ca8fca95b03cb448d663
name: coredns.addons.k8s.io
selector:
k8s-addon: coredns.addons.k8s.io

View File

@ -80,6 +80,10 @@ data:
fallthrough in-addr.arpa ip6.arpa
ttl 30
}
hosts /rootfs/etc/hosts minimal.example.com {
ttl 30
fallthrough
}
prometheus :9153
forward . /etc/resolv.conf {
max_concurrent 1000
@ -180,6 +184,9 @@ spec:
- mountPath: /etc/coredns
name: config-volume
readOnly: true
- mountPath: /rootfs/etc/hosts
name: etc-hosts
readOnly: true
dnsPolicy: Default
nodeSelector:
kubernetes.io/os: linux
@ -205,6 +212,10 @@ spec:
- configMap:
name: coredns
name: config-volume
- hostPath:
path: /etc/hosts
type: File
name: etc-hosts
---

View File

@ -14,7 +14,7 @@ spec:
version: 9.99.0
- id: k8s-1.12
manifest: coredns.addons.k8s.io/k8s-1.12.yaml
manifestHash: d2bbb7cbee5835c3891fe80fbacf8963508359ef9159f8480325ce9a7174f14a
manifestHash: 9d6912241710a76fda7c973a9b116ca9da6d7827c57a0977e223b777018a5913
name: coredns.addons.k8s.io
selector:
k8s-addon: coredns.addons.k8s.io

View File

@ -80,6 +80,10 @@ data:
fallthrough in-addr.arpa ip6.arpa
ttl 30
}
hosts /rootfs/etc/hosts minimal-gce.example.com {
ttl 30
fallthrough
}
prometheus :9153
forward . /etc/resolv.conf {
max_concurrent 1000
@ -180,6 +184,9 @@ spec:
- mountPath: /etc/coredns
name: config-volume
readOnly: true
- mountPath: /rootfs/etc/hosts
name: etc-hosts
readOnly: true
dnsPolicy: Default
nodeSelector:
kubernetes.io/os: linux
@ -205,6 +212,10 @@ spec:
- configMap:
name: coredns
name: config-volume
- hostPath:
path: /etc/hosts
type: File
name: etc-hosts
---

View File

@ -14,7 +14,7 @@ spec:
version: 9.99.0
- id: k8s-1.12
manifest: coredns.addons.k8s.io/k8s-1.12.yaml
manifestHash: d2bbb7cbee5835c3891fe80fbacf8963508359ef9159f8480325ce9a7174f14a
manifestHash: 881d2ec248edb7ef6466985a51f30b4d50ec3e5f4997ca8fca95b03cb448d663
name: coredns.addons.k8s.io
selector:
k8s-addon: coredns.addons.k8s.io

View File

@ -80,6 +80,10 @@ data:
fallthrough in-addr.arpa ip6.arpa
ttl 30
}
hosts /rootfs/etc/hosts minimal.example.com {
ttl 30
fallthrough
}
prometheus :9153
forward . /etc/resolv.conf {
max_concurrent 1000
@ -180,6 +184,9 @@ spec:
- mountPath: /etc/coredns
name: config-volume
readOnly: true
- mountPath: /rootfs/etc/hosts
name: etc-hosts
readOnly: true
dnsPolicy: Default
nodeSelector:
kubernetes.io/os: linux
@ -205,6 +212,10 @@ spec:
- configMap:
name: coredns
name: config-volume
- hostPath:
path: /etc/hosts
type: File
name: etc-hosts
---

View File

@ -76,8 +76,8 @@ data:
fallthrough in-addr.arpa ip6.arpa
ttl 30
}
{{- if GossipName }}
hosts /rootfs/etc/hosts k8s.local {
{{- if not PublishesDNSRecords }}
hosts /rootfs/etc/hosts {{ ClusterDNSDomain }} {
ttl 30
fallthrough
}
@ -173,7 +173,7 @@ spec:
- name: config-volume
mountPath: /etc/coredns
readOnly: true
{{- if GossipName }}
{{- if not PublishesDNSRecords }}
- name: etc-hosts
mountPath: /rootfs/etc/hosts
readOnly: true
@ -220,7 +220,7 @@ spec:
- name: config-volume
configMap:
name: coredns
{{- if GossipName }}
{{- if not PublishesDNSRecords }}
- name: etc-hosts
hostPath:
path: /etc/hosts

View File

@ -51,7 +51,6 @@ import (
apiModel "k8s.io/kops/pkg/apis/kops/model"
"k8s.io/kops/pkg/apis/kops/util"
"k8s.io/kops/pkg/bootstrap/pkibootstrap"
"k8s.io/kops/pkg/dns"
"k8s.io/kops/pkg/featureflag"
"k8s.io/kops/pkg/flagbuilder"
"k8s.io/kops/pkg/kubemanifest"
@ -134,11 +133,14 @@ func (tf *TemplateFunctions) AddTo(dest template.FuncMap, secretStore fi.SecretS
}
return false
}
dest["GossipName"] = func() bool {
if dns.IsGossipClusterName(cluster.Name) {
return true
dest["PublishesDNSRecords"] = func() bool {
return cluster.PublishesDNSRecords()
}
dest["ClusterDNSDomain"] = func() string {
if cluster.UsesLegacyGossip() {
return "k8s.local"
}
return false
return cluster.Name
}
dest["NodeLocalDNSClusterIP"] = func() string {