Skip to content

Commit

Permalink
remove openshift routes impl (Kuadrant#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
eguzki authored Apr 4, 2022
1 parent 7d09080 commit 04ea8fa
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 999 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
* [Overview](#overview)
* [CustomResourceDefinitions](#customresourcedefinitions)
* [Getting started](#getting-started)
* [Openshift Routes](/doc/openshift-routes.md)
* [Contributing](#contributing)
* [Licensing](#licensing)

Expand Down
34 changes: 0 additions & 34 deletions config/deploy/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -350,40 +350,6 @@ rules:
- patch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
creationTimestamp: null
labels:
app: kuadrant
name: kuadrant-manager-role
namespace: kuadrant-system
rules:
- apiGroups:
- route.openshift.io
resources:
- routes
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- route.openshift.io
resources:
- routes/custom-host
verbs:
- create
- apiGroups:
- route.openshift.io
resources:
- routes/status
verbs:
- get
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
Expand Down
33 changes: 0 additions & 33 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,36 +96,3 @@ rules:
- patch
- update
- watch

---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
creationTimestamp: null
name: manager-role
namespace: placeholder
rules:
- apiGroups:
- route.openshift.io
resources:
- routes
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- route.openshift.io
resources:
- routes/custom-host
verbs:
- create
- apiGroups:
- route.openshift.io
resources:
- routes/status
verbs:
- get
6 changes: 3 additions & 3 deletions controllers/apim/httproute_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
"sigs.k8s.io/controller-runtime/pkg/builder"
gatewayapi_v1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"

"github.com/kuadrant/kuadrant-controller/pkg/common"
"github.com/kuadrant/kuadrant-controller/pkg/log"
"github.com/kuadrant/kuadrant-controller/pkg/mappers"
"github.com/kuadrant/kuadrant-controller/pkg/reconcilers"
)

Expand Down Expand Up @@ -55,7 +55,7 @@ func (r *HTTPRouteReconciler) Reconcile(eventCtx context.Context, req ctrl.Reque

// TODO(rahulanand16nov): handle HTTPRoute deletion for AuthPolicy
// check if this httproute has to be protected or not.
_, present := httproute.GetAnnotations()[mappers.KuadrantAuthProviderAnnotation]
_, present := httproute.GetAnnotations()[common.KuadrantAuthProviderAnnotation]
if !present {
for _, parentRef := range httproute.Spec.ParentRefs {
gwNamespace := httproute.Namespace // consider gateway local if namespace is not given
Expand Down Expand Up @@ -100,7 +100,7 @@ func (r *HTTPRouteReconciler) reconcileAuthPolicy(ctx context.Context, logger lo
logger.Info("Reconciling AuthorizationPolicy")

// annotation presence is already checked.
providerName := hr.GetAnnotations()[mappers.KuadrantAuthProviderAnnotation]
providerName := hr.GetAnnotations()[common.KuadrantAuthProviderAnnotation]

// pre-convert hostnames to string slice
hosts := HostnamesToStrings(hr.Spec.Hostnames)
Expand Down
21 changes: 10 additions & 11 deletions controllers/apim/ratelimitpolicy_mapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/predicate"

apimv1alpha1 "github.com/kuadrant/kuadrant-controller/apis/apim/v1alpha1"
"github.com/kuadrant/kuadrant-controller/pkg/mappers"
)

const (
Expand All @@ -32,33 +31,33 @@ const (
func RoutingPredicate() predicate.Predicate {
return predicate.Funcs{
CreateFunc: func(e event.CreateEvent) bool {
if rlpName, toRateLimit := e.Object.GetAnnotations()[mappers.KuadrantRateLimitPolicyAnnotation]; toRateLimit {
if rlpName, toRateLimit := e.Object.GetAnnotations()[common.KuadrantRateLimitPolicyAnnotation]; toRateLimit {
SignalAttach(e.Object, rlpName)
return true
}
_, toProtect := e.Object.GetAnnotations()[mappers.KuadrantAuthProviderAnnotation]
_, toProtect := e.Object.GetAnnotations()[common.KuadrantAuthProviderAnnotation]
return toProtect
},
UpdateFunc: func(e event.UpdateEvent) bool {
_, toRateLimitOld := e.ObjectOld.GetAnnotations()[mappers.KuadrantRateLimitPolicyAnnotation]
_, toRateLimitNew := e.ObjectNew.GetAnnotations()[mappers.KuadrantRateLimitPolicyAnnotation]
_, toRateLimitOld := e.ObjectOld.GetAnnotations()[common.KuadrantRateLimitPolicyAnnotation]
_, toRateLimitNew := e.ObjectNew.GetAnnotations()[common.KuadrantRateLimitPolicyAnnotation]
if toRateLimitNew || toRateLimitOld {
SignalUpdate(e.ObjectOld, e.ObjectNew)
return true
}

_, toProtectOld := e.ObjectOld.GetAnnotations()[mappers.KuadrantAuthProviderAnnotation]
_, toProtectNew := e.ObjectNew.GetAnnotations()[mappers.KuadrantAuthProviderAnnotation]
_, toProtectOld := e.ObjectOld.GetAnnotations()[common.KuadrantAuthProviderAnnotation]
_, toProtectNew := e.ObjectNew.GetAnnotations()[common.KuadrantAuthProviderAnnotation]
return toProtectOld || toProtectNew
},
DeleteFunc: func(e event.DeleteEvent) bool {
// If the object had the Kuadrant label, we need to handle its deletion
if rlpName, toRateLimit := e.Object.GetAnnotations()[mappers.KuadrantRateLimitPolicyAnnotation]; toRateLimit {
if rlpName, toRateLimit := e.Object.GetAnnotations()[common.KuadrantRateLimitPolicyAnnotation]; toRateLimit {
SignalDetach(e.Object, rlpName)
return true
}

_, toProtect := e.Object.GetAnnotations()[mappers.KuadrantAuthProviderAnnotation]
_, toProtect := e.Object.GetAnnotations()[common.KuadrantAuthProviderAnnotation]
return toProtect
},
}
Expand All @@ -79,8 +78,8 @@ func SignalDetach(obj client.Object, rlpToDetach string) {
}

func SignalUpdate(oldObj, newObj client.Object) {
oldRlpName, toRateLimitOld := oldObj.GetAnnotations()[mappers.KuadrantRateLimitPolicyAnnotation]
newRlpName, toRateLimitNew := newObj.GetAnnotations()[mappers.KuadrantRateLimitPolicyAnnotation]
oldRlpName, toRateLimitOld := oldObj.GetAnnotations()[common.KuadrantRateLimitPolicyAnnotation]
newRlpName, toRateLimitNew := newObj.GetAnnotations()[common.KuadrantRateLimitPolicyAnnotation]

// case when rlp name is added (same as create event)
if !toRateLimitOld && toRateLimitNew {
Expand Down
5 changes: 2 additions & 3 deletions controllers/apim/virtualservice_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"github.com/go-logr/logr"
"github.com/kuadrant/kuadrant-controller/pkg/common"
"github.com/kuadrant/kuadrant-controller/pkg/log"
"github.com/kuadrant/kuadrant-controller/pkg/mappers"
"github.com/kuadrant/kuadrant-controller/pkg/reconcilers"
)

Expand Down Expand Up @@ -57,7 +56,7 @@ func (r *VirtualServiceReconciler) Reconcile(eventCtx context.Context, req ctrl.
}
// TODO(rahulanand16nov): handle VirtualService deletion for AuthPolicy
// check if this virtualservice is to be protected or not.
_, present := virtualService.GetAnnotations()[mappers.KuadrantAuthProviderAnnotation]
_, present := virtualService.GetAnnotations()[common.KuadrantAuthProviderAnnotation]
if !present {
for _, gateway := range virtualService.Spec.Gateways {
gwKey := common.NamespacedNameToObjectKey(gateway, virtualService.Namespace)
Expand Down Expand Up @@ -87,7 +86,7 @@ func (r *VirtualServiceReconciler) reconcileAuthPolicy(ctx context.Context, logg
logger.Info("Reconciling AuthorizationPolicy")

// annotation presence is already checked.
providerName := vs.GetAnnotations()[mappers.KuadrantAuthProviderAnnotation]
providerName := vs.GetAnnotations()[common.KuadrantAuthProviderAnnotation]

// TODO(rahulanand16nov): update following to match HTTPRoute controller
// fill out the rules
Expand Down
Loading

0 comments on commit 04ea8fa

Please sign in to comment.