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

First version of the RateLimit reconciler #6

Merged
merged 7 commits into from
Jan 15, 2021

Conversation

davidor
Copy link
Contributor

@davidor davidor commented Jan 14, 2021

This PR adds the RateLimit CR using operator-sdk create-api .... The attributes of the CR are the ones accepted by the Limitador HTTP API.

This PR also adds an initial version of a controller that allows us to manage the limits in limitador via the RateLimit CR.


limitadorv1alpha1 "github.com/3scale/limitador-operator/api/v1alpha1"
)

const rateLimitFinalizer = "finalizer.ratelimit.limitador.3scale.net"

// Assumes that there's only one Limitador per namespace. We might want to
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@miguelsorianod @eguzki please keep this in mind while reviewing.
I think we'll need to be able to deploy multiple limitadors per namespace, but let's leave that scenario for when the use cases are more clear.

api/v1alpha1/ratelimit_types.go Outdated Show resolved Hide resolved
controllers/ratelimit_controller.go Outdated Show resolved Hide resolved
controllers/ratelimit_controller.go Show resolved Hide resolved
pkg/limitador/client.go Show resolved Hide resolved
@eguzki
Copy link
Contributor

eguzki commented Jan 14, 2021

Generally it looks that it works as expected and does it's work. Just wanted to comment that it does not implement reconciliation pattern:

  • I have desired state A
  • I have existing state B
  • I compare and do all "delta" operations to have existing state A

Anyway, this is not blocking for now. Just a side note.

@davidor
Copy link
Contributor Author

davidor commented Jan 14, 2021

@eguzki Why do you say it does not implement the reconciliation pattern? Is it because the issue about updating the limits discussed in #6 (comment) or is it something else?

@eguzki
Copy link
Contributor

eguzki commented Jan 14, 2021

Just a high level or generic comment of the approach. The last step of the reconciliation loop there is a "createLimit" operation which is unconditional.

@davidor davidor force-pushed the first-version-ratelimit-reconciler branch from ef0a727 to e8b8693 Compare January 14, 2021 18:35
@davidor davidor force-pushed the first-version-ratelimit-reconciler branch from e8b8693 to 2da7e7e Compare January 14, 2021 18:43
@davidor davidor requested a review from eguzki January 14, 2021 18:50
Foo string `json:"foo,omitempty"`
Conditions []string `json:"conditions"`
MaxValue int `json:"max_value"`
Namespace string `json:"namespace"`
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do you need Namespace? Is this is intended to "bind" this rate limit to some Limitador service in another namespace? In that case, I suggest having URL.

Copy link
Contributor

Choose a reason for hiding this comment

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

All k8s objects have a meta property namespace you can use to bind one rate limit object to the limitador service of the same namespace. JFYI.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The naming is confusing, sorry. A limitador namespace doesn't need to be a kubernetes namespace. Limitador also runs outside kubernetes. A limitador namespace is the "context" on which a limit applies, it could be a service, a product, a proxy, a kubernetes namespace or any other thing really. It's meant to be generic to support multiple use cases.

In a future version of Limitador we might want to rename this field so it's less confusing for users running it in Kubernetes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, I see, it is an internal namespace.

@davidor davidor merged commit bfa64bd into main Jan 15, 2021
@davidor davidor deleted the first-version-ratelimit-reconciler branch January 15, 2021 12:06
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.

2 participants