Skip to content

Commit db39958

Browse files
Merge pull request #5427 from cybertron/disable-internal-dns
OPNET-678: Allow disabling internal DNS records
2 parents 4a3b43b + 54daa4f commit db39958

27 files changed

+1063
-16
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ require (
3737
github.com/onsi/gomega v1.36.2
3838
github.com/opencontainers/go-digest v1.0.0
3939
github.com/openshift-eng/openshift-tests-extension v0.0.0-20250916161632-d81c09058835
40-
github.com/openshift/api v0.0.0-20251104141128-d13e8c65d30f
40+
github.com/openshift/api v0.0.0-20251119073004-138912d4ee99
4141
github.com/openshift/client-go v0.0.0-20251015124057-db0dee36e235
4242
github.com/openshift/library-go v0.0.0-20251015151611-6fc7a74b67c5
4343
github.com/openshift/runtime-utils v0.0.0-20230921210328-7bdb5b9c177b

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,8 +609,8 @@ github.com/opencontainers/selinux v1.12.0 h1:6n5JV4Cf+4y0KNXW48TLj5DwfXpvWlxXplU
609609
github.com/opencontainers/selinux v1.12.0/go.mod h1:BTPX+bjVbWGXw7ZZWUbdENt8w0htPSrlgOOysQaU62U=
610610
github.com/openshift-eng/openshift-tests-extension v0.0.0-20250916161632-d81c09058835 h1:rkqIIfdYYkasXbF2XKVgh/3f1mhjSQK9By8WtVMgYo8=
611611
github.com/openshift-eng/openshift-tests-extension v0.0.0-20250916161632-d81c09058835/go.mod h1:6gkP5f2HL0meusT0Aim8icAspcD1cG055xxBZ9yC68M=
612-
github.com/openshift/api v0.0.0-20251104141128-d13e8c65d30f h1:xiSyW0ZZ0XWBiZ2ko7e/jI6N0m2DuwZqsSO4NHh/4T8=
613-
github.com/openshift/api v0.0.0-20251104141128-d13e8c65d30f/go.mod h1:d5uzF0YN2nQQFA0jIEWzzOZ+edmo6wzlGLvx5Fhz4uY=
612+
github.com/openshift/api v0.0.0-20251119073004-138912d4ee99 h1:VGkPn3iO7ZapVYtUd7Lj1tE2ZwRfOOUVFzoA/sWlWDc=
613+
github.com/openshift/api v0.0.0-20251119073004-138912d4ee99/go.mod h1:d5uzF0YN2nQQFA0jIEWzzOZ+edmo6wzlGLvx5Fhz4uY=
614614
github.com/openshift/client-go v0.0.0-20251015124057-db0dee36e235 h1:9JBeIXmnHlpXTQPi7LPmu1jdxznBhAE7bb1K+3D8gxY=
615615
github.com/openshift/client-go v0.0.0-20251015124057-db0dee36e235/go.mod h1:L49W6pfrZkfOE5iC1PqEkuLkXG4W0BX4w8b+L2Bv7fM=
616616
github.com/openshift/kubernetes v1.30.1-0.20251028145634-9e794b89909a h1:uaeiYAYOVlXChnGxvsziVTkzaSlBV7h8Y2U2Bc81UKM=

pkg/controller/template/render.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,7 @@ func renderTemplate(config RenderConfig, path string, b []byte) ([]byte, error)
387387
funcs["urlHost"] = urlHost
388388
funcs["urlPort"] = urlPort
389389
funcs["isOpenShiftManagedDefaultLB"] = isOpenShiftManagedDefaultLB
390+
funcs["dnsRecordsType"] = dnsRecordsType
390391
funcs["cloudPlatformAPIIntLoadBalancerIPs"] = cloudPlatformAPIIntLoadBalancerIPs
391392
funcs["cloudPlatformAPILoadBalancerIPs"] = cloudPlatformAPILoadBalancerIPs
392393
funcs["cloudPlatformIngressLoadBalancerIPs"] = cloudPlatformIngressLoadBalancerIPs
@@ -723,6 +724,33 @@ func isOpenShiftManagedDefaultLB(cfg RenderConfig) bool {
723724
return false
724725
}
725726

727+
func dnsRecordsType(cfg RenderConfig) configv1.DNSRecordsType {
728+
if cfg.Infra.Status.PlatformStatus != nil {
729+
switch cfg.Infra.Status.PlatformStatus.Type {
730+
case configv1.BareMetalPlatformType:
731+
if cfg.Infra.Status.PlatformStatus.BareMetal != nil {
732+
return cfg.Infra.Status.PlatformStatus.BareMetal.DNSRecordsType
733+
}
734+
case configv1.NutanixPlatformType:
735+
if cfg.Infra.Status.PlatformStatus.Nutanix != nil {
736+
return cfg.Infra.Status.PlatformStatus.Nutanix.DNSRecordsType
737+
}
738+
case configv1.OpenStackPlatformType:
739+
if cfg.Infra.Status.PlatformStatus.OpenStack != nil {
740+
return cfg.Infra.Status.PlatformStatus.OpenStack.DNSRecordsType
741+
}
742+
case configv1.VSpherePlatformType:
743+
// I'm intentionally not handling VSphere UPI because this should never
744+
// be called on UPI, and even if it is the field is meaningless in that
745+
// context and falling through to the default is fine.
746+
if cfg.Infra.Status.PlatformStatus.VSphere != nil {
747+
return cfg.Infra.Status.PlatformStatus.VSphere.DNSRecordsType
748+
}
749+
}
750+
}
751+
return "Internal"
752+
}
753+
726754
// cloudPlatformLoadBalancerIPs provides a generic method to obtain API, API-Int and Ingrerss Load Balancer IPs
727755
func cloudPlatformLoadBalancerIPs(cfg RenderConfig, lbType LoadBalancerType) (interface{}, error) {
728756
if cfg.Infra.Status.PlatformStatus != nil {

templates/common/on-prem/files/coredns-corefile.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ contents:
1111
}
1212
cache 30
1313
reload
14+
{{ if ne (dnsRecordsType .) "External" }}
1415
template IN {{`{{ .Cluster.IngressVIPRecordType }}`}} {{ .DNS.Spec.BaseDomain }} {
1516
match .*[.]apps.{{ .DNS.Spec.BaseDomain }}
1617
answer "{{`{{"{{ .Name }}"}}`}} 60 in {{`{{"{{ .Type }}"}}`}} {{ if gt (len (onPremPlatformIngressIPs .)) 0 }}{{ index (onPremPlatformIngressIPs .) 0 }}{{ end }}"
@@ -41,6 +42,7 @@ contents:
4142
{{ if gt (len (onPremPlatformAPIServerInternalIPs .)) 1 }}answer "{{`{{"{{ .Name }}"}}`}} 60 in {{`{{"{{ .Type }}"}}`}} {{ index (onPremPlatformAPIServerInternalIPs .) 1 }}"{{ end }}
4243
fallthrough
4344
}
45+
{{ end }}
4446
hosts {
4547
{{`{{- range .Cluster.NodeAddresses }}
4648
{{ .Address }} {{ .Name }} {{ .Name }}.{{ $.Cluster.Name }}.{{ $.Cluster.Domain }}

vendor/github.com/openshift/api/config/v1/types_infrastructure.go

Lines changed: 96 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/openshift/api/config/v1/types_node.go

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)