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

Limitador Service Settings #19

Merged
merged 10 commits into from
Jun 16, 2022
Merged

Limitador Service Settings #19

merged 10 commits into from
Jun 16, 2022

Conversation

didierofrivia
Copy link
Member

@didierofrivia didierofrivia commented Jun 1, 2022

Closes #20

This PR introduces a couple of changes that aim to fix the hardcoded values taken for creating/discovering Limitador Services. The Limitador Operator is meant to have the "ownership" of the Limitador Instance (the actual service), which means it will have the source of truth regarding the Service params, and it's the place to define those.

On the Limitador controller

  • It calculates the ServiceURL within the Status out of a new Spec.Listener type and Limitador.Name
  • Spec.Listener is marked as optional and when it's not present, the values are retrieved from default const
...
name: limitador-1
namespace: default
spec:
  listener:
     http:
       port: 8001
     grpc:
       port: 8000
       tls:   // Possible future implementation
          enabled: true

status:
   //generated by the controller
   service-url: http://limitador-1.default.svc.cluster.local:8001

On the RateLimit controller

  • It defines a new LimitadorRef within the RateLimit spec
  • marked as optional too, will get the values out of default const (as before)
  • Will use this Limitador namespacedName to fetch its Status.ServiceURL
...
name: ratelimit-1
spec:
  limitador-ref:
     name: limitador-1
     namespace: default

@didierofrivia didierofrivia force-pushed the service-settings branch 2 times, most recently from f42564c to 03ff076 Compare June 7, 2022 13:29
@didierofrivia didierofrivia changed the title Service Settings Limitador Service Settings Jun 7, 2022
@didierofrivia didierofrivia marked this pull request as ready for review June 7, 2022 14:59
@didierofrivia didierofrivia requested a review from eguzki June 7, 2022 15:25
api/v1alpha1/limitador_types.go Outdated Show resolved Hide resolved
api/v1alpha1/limitador_types.go Show resolved Hide resolved
api/v1alpha1/ratelimit_types.go Show resolved Hide resolved
* Created NamespacedName type just to add serialization details
* It gets the URL from Limitador.Status
* It retrieves the right Limitador from its Spec or Default
* Listener instead of Service, to be aligned with other projects
* Defining a TransferProtocol for Ports, allowing for future TLS
  features
* Getting the name of the Limitador Obj for the Service Name
Copy link
Contributor

@eguzki eguzki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor issues.

Code looks good.

@@ -62,6 +64,11 @@ type RateLimitList struct {
Items []RateLimit `json:"items"`
}

type NamespacedName struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// Simple enough now, we could implement a thorough check like with RateLimit with ObservedGeneration in the future
builtServiceUrl := buildServiceUrl(limitadorObj)
if builtServiceUrl != limitadorObj.Status.ServiceURL {
logger.V(1).Info("Updating the Status", "Name", limitadorObj.Name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need, already includes the name

@didierofrivia didierofrivia merged commit 40272d9 into main Jun 16, 2022
@didierofrivia didierofrivia deleted the service-settings branch June 16, 2022 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Limitador Service Settings
2 participants