Skip to content

Commit

Permalink
Generate manifests for CoreDNS pod definition and Corefile template
Browse files Browse the repository at this point in the history
For cloud platforms where customers are allowed to bring their own
DNS post cluster install, an in-cluster DNS solution is required
for the installation to be successful.
Adding the manifest containing CoreDNS pod definition and Corefile
template to be used by the MCO instance on the bootstrap node.
  • Loading branch information
sadasu committed Nov 15, 2023
1 parent f8a4eec commit ea46d07
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 0 deletions.
24 changes: 24 additions & 0 deletions manifests/cloud-platform-alt-dns/coredns-corefile.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
. {
errors
health :18080
cache 30
reload
template IN {{`{{ .Cluster.CloudLBRecordType }}`}} {{ .ControllerConfig.DNS.Spec.BaseDomain }} {
match ^api.{{ .ControllerConfig.DNS.Spec.BaseDomain }}
answer "{{`{{"{{ .Name }}"}}`}} 60 in {{`{{"{{ .Type }}"}}`}} {{ if gt (len (.Cluster.APILBIPs )) 0 }}{{ index (.Cluster.APILBIPs) 0 }}{{ end }}"
fallthrough
}
template IN {{`{{ .Cluster.CloudLBEmptyType }}`}} {{ .ControllerConfig.DNS.Spec.BaseDomain }} {
match ^api.{{ .ControllerConfig.DNS.Spec.BaseDomain }}
fallthrough
}
template IN {{`{{ .Cluster.CloudLBRecordType }}`}} {{ .ControllerConfig.DNS.Spec.BaseDomain }} {
match ^api-int.{{ .ControllerConfig.DNS.Spec.BaseDomain }}
answer "{{`{{"{{ .Name }}"}}`}} 60 in {{`{{"{{ .Type }}"}}`}} {{ if gt (len (.Cluster.APIIntLBIPs)) 0 }}{{ index (.Cluster.APIIntLBIPs) 0 }}{{ end }}"
fallthrough
}
template IN {{`{{ .Cluster.CloudLBEmptyType }}`}} {{ .ControllerConfig.DNS.Spec.BaseDomain }} {
match ^api-int.{{ .ControllerConfig.DNS.Spec.BaseDomain }}
fallthrough
}
}
83 changes: 83 additions & 0 deletions manifests/cloud-platform-alt-dns/coredns.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
kind: Pod
apiVersion: v1
metadata:
name: coredns
namespace: openshift-infra
creationTimestamp:
deletionGracePeriodSeconds: 65
labels:
app: {{ cloudPlatformShortName .ControllerConfig }}-infra-coredns
annotations:
target.workload.openshift.io/management: '{"effect": "PreferredDuringScheduling"}'
spec:
volumes:
- name: resource-dir
hostPath:
path: "/etc/kubernetes/static-pod-resources/coredns"
- name: kubeconfig
hostPath:
path: "/etc/kubernetes/kubeconfig"
- name: conf-dir
empty-dir: {}
- name: manifests
hostPath:
path: "/opt/openshift/manifests"
initContainers:
- name: render-config
image: {{ .Images.BaremetalRuntimeCfgBootstrap }}
command:
- runtimecfg
- render
- "/etc/kubernetes/kubeconfig"
- "--cloud-ext-lb-ips"
- "{{- range $index, $ips := .CloudExtLBIPs }}{{ if gt $index 0 }},{{end}}{{$ip}}{{end}}"
- "--cloud-int-lb-ips"
- "{{- range $index, $ips := .CloudIntLBIPs }}{{ if gt $index 0 }},{{end}}{{$ip}}{{end}}"
- "/config"
- "--out-dir"
- "/etc/coredns"
- "--cluster-config"
- "/opt/openshift/manifests/cluster-config.yaml"
resources: {}
volumeMounts:
- name: kubeconfig
mountpath: "/etc/kubernetes/kubeconfig"
- name: resource-dir
mountpath: "/config"
- name: conf-dir
mountpath: "/etc/coredns"
- name: manifests
mountpath: "/opt/openshift/manifests"
imagePullPolicy: IfNotPresent
containers:
- name: coredns
securityContext:
privileged: true
readOnlyRootFilesystem: false
image: {{ .Images.CorednsBootstrap }}
args:
- "--conf"
- "/etc/coredns/Corefile"
resources:
requests:
cpu: 100m
memory: 200Mi
volumeMounts:
- name: conf-dir
mountPath: "/etc/coredns"
livenessProbe:
httpGet:
path: /health
port: 18080
scheme: HTTP
initialDelaySeconds: 60
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 5
terminationMessagePolicy: FallbackToLogsOnError
hostNetwork: true
tolerations:
- operator: Exists
priorityClassName: system-node-critical
status: {}

0 comments on commit ea46d07

Please sign in to comment.