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

Add flag to support ClusterIP exposed CoreDNS #1788

Merged
merged 2 commits into from
Dec 19, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions controllers/mocks/assistant_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions controllers/providers/assistant/assistant.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@ Generated by GoLic, for more details see: https://github.com/AbsaOSS/golic
import (
"time"

corev1 "k8s.io/api/core/v1"
externaldns "sigs.k8s.io/external-dns/endpoint"
)

type Assistant interface {
// GetCoreDNSService returns the CoreDNS Service
GetCoreDNSService() (*corev1.Service, error)
// CoreDNSExposedIPs retrieves list of exposed IP by CoreDNS
CoreDNSExposedIPs() ([]string, error)
// GetExternalTargets retrieves slice of targets from external clusters
Expand Down
24 changes: 22 additions & 2 deletions controllers/providers/assistant/gslb.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ func NewGslbAssistant(client client.Client, k8gbNamespace string, edgeDNSServers
}
}

// CoreDNSExposedIPs retrieves list of IP's exposed by CoreDNS
func (r *Gslb) CoreDNSExposedIPs() ([]string, error) {
// GetCoreDNSService returns the CoreDNS Service
func (r *Gslb) GetCoreDNSService() (*corev1.Service, error) {
bewing marked this conversation as resolved.
Show resolved Hide resolved
serviceList := &corev1.ServiceList{}
sel, err := labels.Parse(coreDNSServiceLabel)
if err != nil {
Expand Down Expand Up @@ -88,7 +88,27 @@ func (r *Gslb) CoreDNSExposedIPs() ([]string, error) {
return nil, err
}
coreDNSService := &serviceList.Items[0]
return coreDNSService, nil
}

// CoreDNSExposedIPs retrieves list of IP's exposed by CoreDNS
func (r *Gslb) CoreDNSExposedIPs() ([]string, error) {
coreDNSService, err := r.GetCoreDNSService()
if err != nil {
return nil, err
}
if coreDNSService.Spec.Type == "ClusterIP" {
if len(coreDNSService.Spec.ClusterIPs) == 0 {
errMessage := "no ClusterIPs found"
log.Warn().
Str("serviceName", coreDNSService.Name).
Msg(errMessage)
err := coreerrors.New(errMessage)
return nil, err
}
return coreDNSService.Spec.ClusterIPs, nil
}
// LoadBalancer / ExternalName / NodePort service
var lb corev1.LoadBalancerIngress
if len(coreDNSService.Status.LoadBalancer.Ingress) == 0 {
errMessage := "no LoadBalancer ExternalIPs are found"
Expand Down
Loading