Skip to content

Commit

Permalink
apiext: remove crd label restriction
Browse files Browse the repository at this point in the history
To limit the scope of CRD's being pulled into the Manager cache
a resitrction was put on the default labels. This works in most cases
when users are using the default crds provided.

However, in some cases users have their own conventions on labels
so if the label was modified or removed then the CRD Patching would
not work.

This removes the cache option and instead relies upon the
`getAmbassadorioPredicate` for filtering out events for non
getambassadorio crds that we do not care about as seen in
`pkg/apiext/internal/controller/crd/predicate.go`

We also did this to limit the scope of checked CRD's when checking
CRD readiness. This has been removed and we instead check to ensure
we only look at the `getambassador.io` group.

Signed-off-by: Lance Austin <[email protected]>
  • Loading branch information
Lance Austin authored and LanceEa committed Jan 31, 2024
1 parent 086914f commit 53a1631
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions pkg/apiext/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"github.com/emissary-ingress/emissary/v3/pkg/apiext/path"
corev1 "k8s.io/api/core/v1"
apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"
Expand Down Expand Up @@ -272,18 +271,14 @@ func (s *WebhookServer) areCRDsReady(ctx context.Context) bool {
}

crdList := &apiextv1.CustomResourceDefinitionList{}
options := []client.ListOption{
client.MatchingLabels{"app.kubernetes.io/part-of": "emissary-apiext"},
}

err := s.k8sClient.List(ctx, crdList, options...)
err := s.k8sClient.List(ctx, crdList)
if err != nil {
s.logger.Error("ready check unable to list getambassadorio crds", zap.Error(err))
return false
}

for _, item := range crdList.Items {
if len(item.Spec.Versions) < 2 {
if item.Spec.Group != "getambassador.io" || len(item.Spec.Versions) < 2 {
continue
}

Expand All @@ -302,9 +297,6 @@ func (s *WebhookServer) areCRDsReady(ctx context.Context) bool {
func createCacheOptions(secretNamespace string) cache.Options {
return cache.Options{
ByObject: map[client.Object]cache.ByObject{
&apiextv1.CustomResourceDefinition{}: {
Label: labels.SelectorFromSet(labels.Set{"app.kubernetes.io/part-of": "emissary-apiext"}),
},
&corev1.Secret{}: {
Namespaces: map[string]cache.Config{
secretNamespace: {},
Expand Down

0 comments on commit 53a1631

Please sign in to comment.