-
Notifications
You must be signed in to change notification settings - Fork 2.4k
[rollout-operator] - Add support for webhooks #3859
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
base: main
Are you sure you want to change the base?
Changes from 19 commits
5d83013
f410577
f525e88
885f487
b8f657e
c3a5a8c
f6aff8e
f09ad49
ed61f60
23b854a
0bbf9e8
8d8a353
7f1c21e
cee571b
6256cdb
6e7824e
060c2e5
935896c
18f39ee
e42288a
81f0877
21edd58
08b81f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
metadata: | ||
name: replicatemplates.rollout-operator.grafana.com | ||
spec: | ||
group: rollout-operator.grafana.com | ||
versions: | ||
- name: v1 | ||
served: true | ||
storage: true | ||
additionalPrinterColumns: | ||
- description: Status replicas | ||
jsonPath: .status.replicas | ||
name: StatusReplicas | ||
type: string | ||
- description: Spec replicas | ||
jsonPath: .spec.replicas | ||
name: SpecReplicas | ||
type: string | ||
schema: | ||
openAPIV3Schema: | ||
type: object | ||
properties: | ||
spec: | ||
type: object | ||
properties: | ||
replicas: | ||
type: integer | ||
default: 1 | ||
minimum: 0 | ||
labelSelector: | ||
type: string | ||
status: | ||
type: object | ||
properties: | ||
replicas: | ||
type: integer | ||
subresources: | ||
status: { } | ||
scale: | ||
specReplicasPath: .spec.replicas | ||
statusReplicasPath: .status.replicas | ||
labelSelectorPath: .spec.labelSelector | ||
scope: Namespaced | ||
names: | ||
plural: replicatemplates | ||
singular: replicatemplate | ||
kind: ReplicaTemplate | ||
categories: | ||
# Include in "kubectl get all" output | ||
- all |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
apiVersion: apiextensions.k8s.io/v1 | ||
kind: CustomResourceDefinition | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that this is in the crds directory so it can not be templated. See https://helm.sh/docs/chart_best_practices/custom_resource_definitions/ |
||
metadata: | ||
name: zoneawarepoddisruptionbudgets.rollout-operator.grafana.com | ||
spec: | ||
group: rollout-operator.grafana.com | ||
versions: | ||
- name: v1 | ||
served: true | ||
storage: true | ||
schema: | ||
openAPIV3Schema: | ||
type: object | ||
properties: | ||
spec: | ||
type: object | ||
required: | ||
- selector | ||
properties: | ||
maxUnavailable: | ||
type: integer | ||
description: The number of pods that can be unavailable within a zone or partition. | ||
minimum: 0 | ||
maxUnavailablePercentage: | ||
type: integer | ||
description: Calculate the maxUnavailable value as a percentage of the StatefulSet's spec.Replica count. This option is not supported when using podNamePartitionRegex. | ||
minimum: 0 | ||
maximum: 100 | ||
selector: | ||
type: object | ||
description: A selector for finding pods and statefulsets that this ZoneAwarePodDisruptionBudget applies to. | ||
required: | ||
- matchLabels | ||
properties: | ||
matchLabels: | ||
type: object | ||
additionalProperties: | ||
type: string | ||
podNamePartitionRegex: | ||
type: string | ||
description: A regular expression for returning a partition name given a pod name. This field is optional and should only be used when the ZoneAwarePodDisruptionBudget is to be scoped to a partition, such as a multi-zone ingester deployment with ingest_storage_enabled. Enabling this changes the ZPDB functionality such that minAvailability is applied across ALL zones for a given partition. When not enabled, the minAvailability is applied to pods within the eviction zone assuming there are no disruptions in the other zones. | ||
podNameRegexGroup: | ||
type: integer | ||
minimum: 1 | ||
description: The regular expression group number that contains the partition name. This field is only required when the podNamePartitionRegex field is set and has more then one subexpression grouping. The default value is 1. | ||
subresources: | ||
status: {} | ||
scope: Namespaced | ||
names: | ||
kind: ZoneAwarePodDisruptionBudget | ||
plural: zoneawarepoddisruptionbudgets | ||
singular: zoneawarepoddisruptionbudget | ||
shortNames: | ||
- zdpb |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{{- if .Values.webhooks.enabled -}} | ||
apiVersion: admissionregistration.k8s.io/v1 | ||
kind: ValidatingWebhookConfiguration | ||
metadata: | ||
name: no-downscale-{{ .Release.Namespace }} | ||
labels: | ||
grafana.com/inject-rollout-operator-ca: "true" | ||
grafana.com/namespace: {{ .Release.Namespace | quote }} | ||
{{- include "rollout-operator.labels" . | nindent 4 }} | ||
webhooks: | ||
- name: no-downscale-{{ .Release.Namespace }}.grafana.com | ||
clientConfig: | ||
service: | ||
namespace: {{ .Release.Namespace | quote }} | ||
name: {{ include "rollout-operator.fullname" . }} | ||
path: /admission/no-downscale | ||
port: 443 | ||
rules: | ||
- operations: | ||
- UPDATE | ||
apiGroups: | ||
- apps | ||
apiVersions: | ||
- v1 | ||
resources: | ||
- statefulsets | ||
- statefulsets/scale | ||
scope: Namespaced | ||
admissionReviewVersions: | ||
- v1 | ||
namespaceSelector: | ||
matchLabels: | ||
kubernetes.io/metadata.name: {{ .Release.Namespace | quote }} | ||
sideEffects: None | ||
failurePolicy: {{.Values.webhooks.failurePolicy}} | ||
{{- end -}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{{- if .Values.webhooks.enabled -}} | ||
apiVersion: admissionregistration.k8s.io/v1 | ||
kind: ValidatingWebhookConfiguration | ||
metadata: | ||
name: pod-eviction-{{ .Release.Namespace }} | ||
labels: | ||
grafana.com/inject-rollout-operator-ca: "true" | ||
grafana.com/namespace: {{ .Release.Namespace | quote }} | ||
{{- include "rollout-operator.labels" . | nindent 4 }} | ||
webhooks: | ||
- name: pod-eviction-{{ .Release.Namespace }}.grafana.com | ||
clientConfig: | ||
service: | ||
namespace: {{ .Release.Namespace | quote }} | ||
name: {{ include "rollout-operator.fullname" . }} | ||
path: /admission/pod-eviction | ||
port: 443 | ||
rules: | ||
- operations: | ||
- CREATE | ||
apiGroups: | ||
- "" | ||
apiVersions: | ||
- v1 | ||
resources: | ||
- pods/eviction | ||
scope: Namespaced | ||
admissionReviewVersions: | ||
- v1 | ||
namespaceSelector: | ||
matchLabels: | ||
kubernetes.io/metadata.name: {{ .Release.Namespace | quote }} | ||
sideEffects: None | ||
failurePolicy: {{.Values.webhooks.failurePolicy}} | ||
{{- end -}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{{- if .Values.webhooks.enabled -}} | ||
apiVersion: admissionregistration.k8s.io/v1 | ||
kind: MutatingWebhookConfiguration | ||
metadata: | ||
name: prepare-downscale-{{ .Release.Namespace }} | ||
labels: | ||
grafana.com/inject-rollout-operator-ca: "true" | ||
grafana.com/namespace: {{ .Release.Namespace | quote }} | ||
{{- include "rollout-operator.labels" . | nindent 4 }} | ||
webhooks: | ||
- name: prepare-downscale-{{ .Release.Namespace }}.grafana.com | ||
clientConfig: | ||
service: | ||
namespace: {{ .Release.Namespace | quote }} | ||
name: {{ include "rollout-operator.fullname" . }} | ||
path: /admission/prepare-downscale | ||
port: 443 | ||
rules: | ||
- operations: | ||
- UPDATE | ||
apiGroups: | ||
- apps | ||
apiVersions: | ||
- v1 | ||
resources: | ||
- statefulsets | ||
- statefulsets/scale | ||
scope: Namespaced | ||
admissionReviewVersions: | ||
- v1 | ||
namespaceSelector: | ||
matchLabels: | ||
kubernetes.io/metadata.name: {{ .Release.Namespace | quote }} | ||
sideEffects: NoneOnDryRun | ||
matchPolicy: Equivalent | ||
timeoutSeconds: 10 | ||
failurePolicy: {{.Values.webhooks.failurePolicy}} | ||
{{- end -}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,11 @@ rules: | |
- statefulsets/status | ||
verbs: | ||
- update | ||
- apiGroups: | ||
- rollout-operator.grafana.com | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that his group name is hard coded to match the CRD spec.group |
||
resources: | ||
- zoneawarepoddisruptionbudgets | ||
verbs: | ||
- get | ||
- list | ||
- watch |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{{- if .Values.webhooks.enabled -}} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: {{ include "rollout-operator.fullname" . }}-webhook-clusterrolebinding | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: {{ include "rollout-operator.fullname" . }}-webhook-clusterrole | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ include "rollout-operator.serviceAccountName" . }} | ||
namespace: {{ .Release.Namespace | quote }} | ||
{{- end -}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{{- if .Values.webhooks.enabled -}} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: {{ include "rollout-operator.fullname" . }}-webhook-clusterrole | ||
rules: | ||
- apiGroups: | ||
- admissionregistration.k8s.io | ||
resources: | ||
- validatingwebhookconfigurations | ||
- mutatingwebhookconfigurations | ||
verbs: | ||
- list | ||
- patch | ||
- watch | ||
{{- end -}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{{- if .Values.webhooks.enabled -}} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: RoleBinding | ||
metadata: | ||
name: {{ include "rollout-operator.fullname" . }}-webhook-rolebinding | ||
namespace: {{ .Release.Namespace | quote }} | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: Role | ||
name: {{ include "rollout-operator.fullname" . }}-webhook-role | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ include "rollout-operator.serviceAccountName" . }} | ||
namespace: {{ .Release.Namespace | quote }} | ||
{{- end -}} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{{- if .Values.webhooks.enabled -}} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: {{ include "rollout-operator.fullname" . }}-webhook-role | ||
namespace: {{ .Release.Namespace | quote }} | ||
rules: | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- secrets | ||
verbs: | ||
- update | ||
- get | ||
resourceNames: | ||
- {{ .Values.webhooks.selfSignedCertSecretName }} | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- secrets | ||
verbs: | ||
- create | ||
{{- end -}} |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This app version will need to be bumped once the new rollout-operator is merged/published (grafana/rollout-operator#253)