Refactor Gossip usage in addon templates

This commit is contained in:
Ciprian Hacman 2022-12-23 08:04:13 +02:00
parent 362601cd66
commit b08d53a131
3 changed files with 16 additions and 13 deletions

View File

@ -76,8 +76,8 @@ data:
fallthrough in-addr.arpa ip6.arpa
ttl 30
}
{{- if GossipDomains }}
hosts /rootfs/etc/hosts {{ join " " GossipDomains }} {
{{- if GossipName }}
hosts /rootfs/etc/hosts k8s.local {
ttl 30
fallthrough
}
@ -167,7 +167,7 @@ spec:
- name: config-volume
mountPath: /etc/coredns
readOnly: true
{{- if GossipDomains }}
{{- if GossipName }}
- name: etc-hosts
mountPath: /rootfs/etc/hosts
readOnly: true
@ -209,7 +209,7 @@ spec:
- name: config-volume
configMap:
name: coredns
{{- if GossipDomains }}
{{- if GossipName }}
- name: etc-hosts
hostPath:
path: /etc/hosts

View File

@ -141,7 +141,7 @@ rules:
- list
- watch
- patch
{{- if GossipDomains }}
{{- if GossipEnabled }}
- apiGroups:
- ""
resources:
@ -213,7 +213,7 @@ rules:
- leases
verbs:
- create
{{- if GossipDomains }}
{{- if GossipEnabled }}
- apiGroups:
- ""
resources:

View File

@ -124,14 +124,17 @@ func (tf *TemplateFunctions) AddTo(dest template.FuncMap, secretStore fi.SecretS
return cluster.Spec.KubeDNS
}
dest["GossipDomains"] = func() []string {
var names []string
if dns.IsGossipClusterName(cluster.Name) {
names = append(names, "k8s.local")
dest["GossipEnabled"] = func() bool {
if cluster.IsGossip() {
return true
}
return names
return false
}
dest["GossipName"] = func() bool {
if dns.IsGossipClusterName(cluster.Name) {
return true
}
return false
}
dest["NodeLocalDNSClusterIP"] = func() string {