mode: 0644
path: "/etc/kubernetes/static-pod-resources/coredns/Corefile.tmpl"
contents:
  inline: |
    {{ if .Infra -}}
    {{ if .Infra.Status -}}
    {{ if .Infra.Status.PlatformStatus -}}
    {{ if .Infra.Status.PlatformStatus.VSphere -}}
    {{ if .Infra.Status.PlatformStatus.VSphere.APIServerInternalIP -}}
    . {
        errors
        health :18080
        mdns {{ .Infra.Status.EtcdDiscoveryDomain }} 0 {{`{{.Cluster.Name}}`}} {{`{{.NonVirtualIP}}`}}
        forward . {{`{{- range $upstream := .DNSUpstreams}} {{$upstream}}{{- end}}`}}
        cache 30
        reload
        hosts {
            {{ .Infra.Status.PlatformStatus.VSphere.APIServerInternalIP }} api-int.{{ .Infra.Status.EtcdDiscoveryDomain }}
            {{ .Infra.Status.PlatformStatus.VSphere.APIServerInternalIP }} api.{{ .Infra.Status.EtcdDiscoveryDomain }}
            fallthrough
        }
        template IN A {{ .Infra.Status.EtcdDiscoveryDomain }} {
            match .*.apps.{{ .Infra.Status.EtcdDiscoveryDomain }}
            answer "{{`{{"{{ .Name }}"}}`}} 60 in a {{ .Infra.Status.PlatformStatus.VSphere.IngressIP }}"
            fallthrough
        }
    }
    {{ end -}}
    {{ end -}}
    {{ end -}}
    {{ end -}}
    {{ end -}}
