Skip to content

Commit

Permalink
feat: add KongUpstreamPolicy controller
Browse files Browse the repository at this point in the history
  • Loading branch information
czeslavo committed Oct 25, 2023
1 parent 4efc818 commit 2f1c410
Show file tree
Hide file tree
Showing 13 changed files with 563 additions and 290 deletions.
1 change: 1 addition & 0 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ resources:
- bases/configuration.konghq.com_kongingresses.yaml
- bases/configuration.konghq.com_kongplugins.yaml
- bases/configuration.konghq.com_ingressclassparameterses.yaml
- bases/configuration.konghq.com_kongupstreampolicies.yaml
#+kubebuilder:scaffold:crdkustomizeresource

patchesStrategicMerge:
Expand Down
16 changes: 16 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,22 @@ rules:
- get
- patch
- update
- apiGroups:
- configuration.konghq.com
resources:
- kongupstreampolicies
verbs:
- get
- list
- watch
- apiGroups:
- configuration.konghq.com
resources:
- kongupstreampolicies/status
verbs:
- get
- patch
- update
- apiGroups:
- configuration.konghq.com
resources:
Expand Down
1 change: 1 addition & 0 deletions docs/cli-arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
| `--enable-controller-ingress-class-networkingv1` | `bool` | Enable the networking.k8s.io/v1 IngressClass controller. | `true` |
| `--enable-controller-ingress-class-parameters` | `bool` | Enable the IngressClassParameters controller. | `true` |
| `--enable-controller-ingress-networkingv1` | `bool` | Enable the networking.k8s.io/v1 Ingress controller. | `true` |
| `--enable-controller-kong-upstream-policy` | `bool` | Enable the KongUpstreamPolicy controller. | `true` |
| `--enable-controller-kongclusterplugin` | `bool` | Enable the KongClusterPlugin controller. | `true` |
| `--enable-controller-kongconsumer` | `bool` | Enable the KongConsumer controller. . | `true` |
| `--enable-controller-kongingress` | `bool` | Enable the KongIngress controller. | `true` |
Expand Down
12 changes: 12 additions & 0 deletions hack/generators/controllers/networking/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,18 @@ var inputControllersNeeded = &typesNeeded{
AcceptsIngressClassNameSpec: false,
RBACVerbs: []string{"get", "list", "watch"},
},
typeNeeded{
Group: "configuration.konghq.com",
Version: "v1beta1",
Kind: "KongUpstreamPolicy",
PackageImportAlias: "kongv1beta1",
PackageAlias: "KongV1beta1",
Package: kongv1,
Plural: "kongupstreampolicies",
CacheType: "KongUpstreamPolicy",
NeedsStatusPermissions: true,
RBACVerbs: []string{"get", "list", "watch"},
},
typeNeeded{
Group: "configuration.konghq.com",
Version: "v1",
Expand Down
85 changes: 85 additions & 0 deletions internal/controllers/configuration/zz_generated_controllers.go

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

2 changes: 2 additions & 0 deletions internal/manager/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ type Config struct {
KongPluginEnabled bool
KongConsumerEnabled bool
ServiceEnabled bool
KongUpstreamPolicyEnabled bool

// Admission Webhook server config
AdmissionServer admission.ServerConfig
Expand Down Expand Up @@ -228,6 +229,7 @@ func (c *Config) FlagSet() *pflag.FlagSet {
flagSet.BoolVar(&c.KongPluginEnabled, "enable-controller-kongplugin", true, "Enable the KongPlugin controller.")
flagSet.BoolVar(&c.KongConsumerEnabled, "enable-controller-kongconsumer", true, "Enable the KongConsumer controller. ")
flagSet.BoolVar(&c.ServiceEnabled, "enable-controller-service", true, "Enable the Service controller.")
flagSet.BoolVar(&c.KongUpstreamPolicyEnabled, "enable-controller-kong-upstream-policy", true, "Enable the KongUpstreamPolicy controller.")

// Admission Webhook server config
flagSet.StringVar(&c.AdmissionServer.ListenAddr, "admission-webhook-listen", "off",
Expand Down
10 changes: 10 additions & 0 deletions internal/manager/controllerdef.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,16 @@ func setupControllers(
// StatusQueue: kubernetesStatusQueue,
},
},
{
Enabled: c.KongUpstreamPolicyEnabled,
Controller: &configuration.KongV1beta1KongUpstreamPolicyReconciler{
Client: mgr.GetClient(),
Log: ctrl.LoggerFrom(ctx).WithName("controllers").WithName("KongUpstreamPolicy"),
Scheme: mgr.GetScheme(),
DataplaneClient: dataplaneClient,
CacheSyncTimeout: c.CacheSyncTimeout,
},
},
// ---------------------------------------------------------------------------
// Gateway API Controllers - Beta APIs
// ---------------------------------------------------------------------------
Expand Down
Loading

0 comments on commit 2f1c410

Please sign in to comment.