Skip to content

Commit bde38a8

Browse files
hossainemruztamalsaha
authored andcommitted
Remove importance of order of rule in RestoreSession (#795)
Tasks: - [x] Remove importance of rule order - [x] Add validator to ensure followings, - [x] There is at most one rule with empty targetHosts field. - [x] No two rule with non-empty targetHosts matches for a host. - [x] If snapshot is specified in a rule then paths is not specified. - [x] Update concept doc to make rules behavior clear Fixes: stashed/stash#790
1 parent 0c150a7 commit bde38a8

File tree

5 files changed

+74
-1
lines changed

5 files changed

+74
-1
lines changed

chart/stash/templates/apiregistration.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,22 @@ spec:
2222
---
2323
apiVersion: apiregistration.k8s.io/v1beta1
2424
kind: APIService
25+
metadata:
26+
name: v1beta1.admission.stash.appscode.com
27+
labels:
28+
{{- include "stash.labels" . | nindent 4 }}
29+
spec:
30+
group: admission.stash.appscode.com
31+
version: v1beta1
32+
service:
33+
namespace: {{ .Release.Namespace }}
34+
name: {{ template "stash.fullname" . }}
35+
caBundle: {{ b64enc $ca.Cert }}
36+
groupPriorityMinimum: {{ .Values.apiserver.groupPriorityMinimum }}
37+
versionPriority: {{ .Values.apiserver.versionPriority }}
38+
---
39+
apiVersion: apiregistration.k8s.io/v1beta1
40+
kind: APIService
2541
metadata:
2642
name: v1alpha1.repositories.stash.appscode.com
2743
labels:

chart/stash/templates/validating-webhook.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,25 @@ webhooks:
7575
{{- if and (ge $major 1) (ge $minor 12) }}
7676
sideEffects: None
7777
{{- end }}
78+
- name: restoresession.admission.stash.appscode.com
79+
clientConfig:
80+
service:
81+
namespace: default
82+
name: kubernetes
83+
path: /apis/admission.stash.appscode.com/v1beta1/restoresessionvalidators
84+
caBundle: {{ b64enc .Values.apiserver.ca }}
85+
rules:
86+
- operations:
87+
- CREATE
88+
- UPDATE
89+
apiGroups:
90+
- stash.appscode.com
91+
apiVersions:
92+
- "*"
93+
resources:
94+
- restoresessions
95+
failurePolicy: Fail
96+
{{- if and (ge $major 1) (ge $minor 12) }}
97+
sideEffects: None
98+
{{- end }}
7899
{{ end }}

deploy/apiservices.yaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,23 @@ spec:
1818
# register as aggregated apiserver
1919
apiVersion: apiregistration.k8s.io/v1beta1
2020
kind: APIService
21+
metadata:
22+
name: v1beta1.admission.stash.appscode.com
23+
labels:
24+
app: stash
25+
spec:
26+
caBundle: ${SERVICE_SERVING_CERT_CA}
27+
group: admission.stash.appscode.com
28+
groupPriorityMinimum: 1000
29+
versionPriority: 15
30+
service:
31+
name: stash-operator
32+
namespace: ${STASH_NAMESPACE}
33+
version: v1beta1
34+
---
35+
# register as aggregated apiserver
36+
apiVersion: apiregistration.k8s.io/v1beta1
37+
kind: APIService
2138
metadata:
2239
name: v1alpha1.repositories.stash.appscode.com
2340
labels:

deploy/stash.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22
set -eou pipefail
33

4-
crds=(restics repositories recoveries backupconfigurations backupsessions)
4+
crds=(restics repositories recoveries backupconfigurations backupsessions backupconfigurationtemplates functions restoresessions tasks)
55

66
echo "checking kubeconfig context"
77
kubectl config current-context || {

deploy/validating-webhook.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,22 @@ webhooks:
6262
- repositories
6363
failurePolicy: Fail
6464
${STASH_WEBHOOK_SIDE_EFFECTS}
65+
- name: restoresession.admission.stash.appscode.com
66+
clientConfig:
67+
service:
68+
namespace: default
69+
name: kubernetes
70+
path: /apis/admission.stash.appscode.com/v1beta1/restoresessionvalidators
71+
caBundle: ${KUBE_CA}
72+
rules:
73+
- operations:
74+
- CREATE
75+
- UPDATE
76+
apiGroups:
77+
- stash.appscode.com
78+
apiVersions:
79+
- "*"
80+
resources:
81+
- restoresessions
82+
failurePolicy: Fail
83+
${STASH_WEBHOOK_SIDE_EFFECTS}

0 commit comments

Comments
 (0)