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

[v1.15 - Author backport] envoy: enable k8s secret watch even if only CEC is enabled #31451

Merged
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
6 changes: 6 additions & 0 deletions pkg/k8s/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ func GetObjNamespaceName(obj NamespaceNameGetter) string {
return ns + "/" + obj.GetName()
}

// EnvoyConfigConfiguration is the required configuration for GetServiceAndEndpointListOptionsModifier
type EnvoyConfigConfiguration interface {
// K8sEnvoyConfigEnabled returns true if CiliumEnvoyConfig feature is enabled in Cilium
K8sEnvoyConfigEnabled() bool
}

// IngressConfiguration is the required configuration for GetServiceAndEndpointListOptionsModifier
type IngressConfiguration interface {
// K8sIngressControllerEnabled returns true if ingress controller feature is enabled in Cilium
Expand Down
9 changes: 5 additions & 4 deletions pkg/k8s/watchers/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ type K8sWatcher struct {
// networkPoliciesInitOnce is used to guarantee only one call to NetworkPoliciesInit is
// executed.
networkPoliciesInitOnce sync.Once
//networkPoliciesStoreSet is closed once the networkpolicyStore is set.
// networkPoliciesStoreSet is closed once the networkpolicyStore is set.
networkPoliciesStoreSet chan struct{}
networkpolicyStore cache.Store

Expand Down Expand Up @@ -481,9 +481,9 @@ func (k *K8sWatcher) resourceGroups() (beforeNodeInitGroups, afterNodeInitGroups
k8sGroups = append(k8sGroups, k8sAPIGroupNetworkingV1Core)
}

if k.cfg.K8sIngressControllerEnabled() || k.cfg.K8sGatewayAPIEnabled() {
// While Ingress controller is part of operator, we need to watch
// TLS secrets in pre-defined namespace for populating Envoy xDS SDS cache.
if k.cfg.K8sEnvoyConfigEnabled() || k.cfg.K8sIngressControllerEnabled() || k.cfg.K8sGatewayAPIEnabled() {
// Watch K8s TLS secrets in pre-defined namespace(s) for populating Envoy xDS SDS cache.
// Used by Ingress Controller, Gateway API and/or plain CiliumEnvoyConfig.
k8sGroups = append(k8sGroups, resources.K8sAPIGroupSecretV1Core)
}

Expand Down Expand Up @@ -543,6 +543,7 @@ func (k *K8sWatcher) InitK8sSubsystem(ctx context.Context, cachesSynced chan str

// WatcherConfiguration is the required configuration for enableK8sWatchers
type WatcherConfiguration interface {
utils.EnvoyConfigConfiguration
utils.IngressConfiguration
utils.GatewayAPIConfiguration
utils.PolicyConfiguration
Expand Down
4 changes: 4 additions & 0 deletions pkg/k8s/watchers/watcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ var emptyResources = agentK8s.Resources{}

type fakeWatcherConfiguration struct{}

func (f *fakeWatcherConfiguration) K8sEnvoyConfigEnabled() bool {
return false
}

func (f *fakeWatcherConfiguration) K8sIngressControllerEnabled() bool {
return false
}
Expand Down
5 changes: 5 additions & 0 deletions pkg/option/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2703,6 +2703,11 @@ func (c *DaemonConfig) K8sNetworkPolicyEnabled() bool {
return c.EnableK8sNetworkPolicy
}

// K8sEnvoyConfigEnabled returns true if CiliumEnvoyConfig feature is enabled in Cilium
func (c *DaemonConfig) K8sEnvoyConfigEnabled() bool {
return c.EnableEnvoyConfig
}

// K8sIngressControllerEnabled returns true if ingress controller feature is enabled in Cilium
func (c *DaemonConfig) K8sIngressControllerEnabled() bool {
return c.EnableIngressController
Expand Down
Loading