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

Enable configuring PDB from Limitador CR #91

Merged
merged 4 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,25 @@ local-setup: ## Deploy operator in local kind cluster
$(MAKE) docker-build
@echo "Deploying Limitador control plane"
$(KIND) load docker-image ${IMG} --name ${KIND_CLUSTER_NAME}
make deploy-develmode
$(MAKE) deploy-develmode
@echo "Wait for all deployments to be up"
kubectl -n limitador-operator-system wait --timeout=300s --for=condition=Available deployments --all

.PHONY: local-cleanup
local-cleanup: ## Clean up local kind cluster
$(MAKE) kind-delete-cluster

.PHONY: local-redeploy
local-redeploy: export IMG := limitador-operator:dev
local-redeploy: ## re-deploy operator in local kind cluster
$(MAKE) docker-build
@echo "Deploying Limitador control plane"
$(KIND) load docker-image ${IMG} --name ${KIND_CLUSTER_NAME}
make deploy-develmode
adam-cattermole marked this conversation as resolved.
Show resolved Hide resolved
kubectl rollout restart deployment -n limitador-operator-system limitador-operator-controller-manager
@echo "Wait for all deployments to be up"
kubectl -n limitador-operator-system wait --timeout=300s --for=condition=Available deployments --all

##@ Code Style

.PHONY: run-lint
Expand Down
4 changes: 4 additions & 0 deletions api/v1alpha1/limitador_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/go-logr/logr"
"github.com/google/go-cmp/cmp"
corev1 "k8s.io/api/core/v1"
policyv1 "k8s.io/api/policy/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/kuadrant/limitador-operator/pkg/helpers"
Expand Down Expand Up @@ -61,6 +62,9 @@ type LimitadorSpec struct {

// +optional
Limits []RateLimit `json:"limits,omitempty"`

// +optional
PodDisruptionBudget *policyv1.PodDisruptionBudgetSpec `json:"pdb,omitempty"`
adam-cattermole marked this conversation as resolved.
Show resolved Hide resolved
}

//+kubebuilder:object:root=true
Expand Down
12 changes: 9 additions & 3 deletions api/v1alpha1/zz_generated.deepcopy.go

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

11 changes: 11 additions & 0 deletions bundle/manifests/limitador-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,17 @@ spec:
- get
- patch
- update
- apiGroups:
- policy
resources:
- poddisruptionbudgets
verbs:
- create
- delete
- get
- list
- update
- watch
serviceAccountName: limitador-operator-controller-manager
deployments:
- label:
Expand Down
72 changes: 72 additions & 0 deletions bundle/manifests/limitador.kuadrant.io_limitadors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,78 @@ spec:
type: integer
type: object
type: object
pdb:
description: PodDisruptionBudgetSpec is a description of a PodDisruptionBudget.
properties:
maxUnavailable:
anyOf:
- type: integer
- type: string
description: An eviction is allowed if at most "maxUnavailable"
pods selected by "selector" are unavailable after the eviction,
i.e. even in absence of the evicted pod. For example, one can
prevent all voluntary evictions by specifying 0. This is a mutually
exclusive setting with "minAvailable".
x-kubernetes-int-or-string: true
minAvailable:
anyOf:
- type: integer
- type: string
description: An eviction is allowed if at least "minAvailable"
pods selected by "selector" will still be available after the
eviction, i.e. even in the absence of the evicted pod. So for
example you can prevent all voluntary evictions by specifying
"100%".
x-kubernetes-int-or-string: true
selector:
description: Label query over pods whose evictions are managed
by the disruption budget. A null selector will match no pods,
while an empty ({}) selector will select all pods within the
namespace.
properties:
matchExpressions:
description: matchExpressions is a list of label selector
requirements. The requirements are ANDed.
items:
description: A label selector requirement is a selector
that contains values, a key, and an operator that relates
the key and values.
properties:
key:
description: key is the label key that the selector
applies to.
type: string
operator:
description: operator represents a key's relationship
to a set of values. Valid operators are In, NotIn,
Exists and DoesNotExist.
type: string
values:
description: values is an array of string values. If
the operator is In or NotIn, the values array must
be non-empty. If the operator is Exists or DoesNotExist,
the values array must be empty. This array is replaced
during a strategic merge patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of {key,value} pairs. A
single {key,value} in the matchLabels map is equivalent
to an element of matchExpressions, whose key field is "key",
the operator is "In", and the values array contains only
"value". The requirements are ANDed.
type: object
type: object
x-kubernetes-map-type: atomic
type: object
rateLimitHeaders:
description: RateLimitHeadersType defines the valid options for the
--rate-limit-headers arg
Expand Down
72 changes: 72 additions & 0 deletions config/crd/bases/limitador.kuadrant.io_limitadors.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,78 @@ spec:
type: integer
type: object
type: object
pdb:
description: PodDisruptionBudgetSpec is a description of a PodDisruptionBudget.
properties:
maxUnavailable:
anyOf:
- type: integer
- type: string
description: An eviction is allowed if at most "maxUnavailable"
pods selected by "selector" are unavailable after the eviction,
i.e. even in absence of the evicted pod. For example, one can
prevent all voluntary evictions by specifying 0. This is a mutually
exclusive setting with "minAvailable".
x-kubernetes-int-or-string: true
minAvailable:
anyOf:
- type: integer
- type: string
description: An eviction is allowed if at least "minAvailable"
pods selected by "selector" will still be available after the
eviction, i.e. even in the absence of the evicted pod. So for
example you can prevent all voluntary evictions by specifying
"100%".
x-kubernetes-int-or-string: true
selector:
description: Label query over pods whose evictions are managed
by the disruption budget. A null selector will match no pods,
while an empty ({}) selector will select all pods within the
namespace.
properties:
matchExpressions:
description: matchExpressions is a list of label selector
requirements. The requirements are ANDed.
items:
description: A label selector requirement is a selector
that contains values, a key, and an operator that relates
the key and values.
properties:
key:
description: key is the label key that the selector
applies to.
type: string
operator:
description: operator represents a key's relationship
to a set of values. Valid operators are In, NotIn,
Exists and DoesNotExist.
type: string
values:
description: values is an array of string values. If
the operator is In or NotIn, the values array must
be non-empty. If the operator is Exists or DoesNotExist,
the values array must be empty. This array is replaced
during a strategic merge patch.
items:
type: string
type: array
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of {key,value} pairs. A
single {key,value} in the matchLabels map is equivalent
to an element of matchExpressions, whose key field is "key",
the operator is "In", and the values array contains only
"value". The requirements are ANDed.
type: object
type: object
x-kubernetes-map-type: atomic
type: object
rateLimitHeaders:
description: RateLimitHeadersType defines the valid options for the
--rate-limit-headers arg
Expand Down
60 changes: 30 additions & 30 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,35 @@ spec:
securityContext:
runAsNonRoot: true
containers:
- command:
- /manager
args:
- --leader-elect
env:
- name: RELATED_IMAGE_LIMITADOR
value: "quay.io/kuadrant/limitador:latest"
image: controller:latest
name: manager
securityContext:
allowPrivilegeEscalation: false
livenessProbe:
httpGet:
path: /healthz
port: 8081
initialDelaySeconds: 15
periodSeconds: 20
readinessProbe:
httpGet:
path: /readyz
port: 8081
initialDelaySeconds: 5
periodSeconds: 10
resources:
limits:
cpu: 200m
memory: 300Mi
requests:
cpu: 200m
memory: 200Mi
- command:
- /manager
args:
- --leader-elect
env:
- name: RELATED_IMAGE_LIMITADOR
value: "quay.io/kuadrant/limitador:latest"
image: controller:latest
name: manager
securityContext:
allowPrivilegeEscalation: false
livenessProbe:
httpGet:
path: /healthz
port: 8081
initialDelaySeconds: 15
periodSeconds: 20
readinessProbe:
httpGet:
path: /readyz
port: 8081
initialDelaySeconds: 5
periodSeconds: 10
resources:
limits:
cpu: 200m
memory: 300Mi
requests:
cpu: 200m
memory: 200Mi
serviceAccountName: controller-manager
terminationGracePeriodSeconds: 10
11 changes: 11 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,14 @@ rules:
- get
- patch
- update
- apiGroups:
- policy
resources:
- poddisruptionbudgets
verbs:
- create
- delete
- get
- list
- update
- watch
Loading