Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include /etc/hosts coredns mounts for dns=none clusters #16347

Merged
merged 2 commits into from Feb 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -205,6 +212,10 @@ spec:
- configMap:
name: coredns
name: config-volume
- hostPath:
path: /etc/hosts
type: File
name: etc-hosts

---

Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -205,6 +212,10 @@ spec:
- configMap:
name: coredns
name: config-volume
- hostPath:
path: /etc/hosts
type: File
name: etc-hosts

---

Expand Down
Expand Up @@ -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
Expand Down
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -205,6 +212,10 @@ spec:
- configMap:
name: coredns
name: config-volume
- hostPath:
path: /etc/hosts
type: File
name: etc-hosts

---

Expand Down
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -220,7 +220,7 @@ spec:
- name: config-volume
configMap:
name: coredns
{{- if GossipName }}
{{- if not PublishesDNSRecords }}
- name: etc-hosts
hostPath:
path: /etc/hosts
Expand Down
12 changes: 7 additions & 5 deletions upup/pkg/fi/cloudup/template_functions.go
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down