Skip to content

Commit d21591c

Browse files
authored
Merge pull request #695 from snyk/fix/pvc-conflict
fix: introduce pvc.create flag in Helm chart
2 parents be7e06f + 4bef084 commit d21591c

File tree

8 files changed

+27
-6
lines changed

8 files changed

+27
-6
lines changed

snyk-monitor/README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,20 @@ helm upgrade --install snyk-monitor snyk-charts/snyk-monitor \
140140

141141
By default, `snyk-monitor` uses an emptyDir for temporary storage. If you prefer to have a PVC that uses a statically or
142142
dynamically provisioned PV that you have created, then set the following value
143-
* `pvc.enabled` `true`
143+
* `pvc.enabled`=`true`
144+
145+
If you would also like to create the PVC (if not using an existing one) then set the following value
146+
* `pvc.create`=`true`
144147

145148
The PVC's name defaults to `snyk-monitor-pvc`. If you prefer to override this, then use the following value:
146149
* `pvc.name`
147150

151+
For example, run the following for first-time setup:
152+
`--set pvc.enabled=true --pvc.create=true`
153+
154+
And run the following for subsequent upgrades:
155+
`--set pvc.enabled=true`
156+
148157
## PodSecurityPolicies
149158
**This should not be used when installing on OpenShift.**
150159

snyk-monitor/templates/pvc.yaml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
# We create a PVC only if the default PVC name has not changed.
2-
# If the name has changed, it means our users want to use their own pre-provisioned PVC.
3-
# In such cases it would be an error to create a PVC as it would result in a conflict - the PVC already exists.
4-
{{- if .Values.pvc.enabled }}{{- if eq .Values.pvc.name "snyk-monitor-pvc" }}
1+
# We create a PVC only if requested.
2+
{{- if .Values.pvc.enabled }}{{- if .Values.pvc.create }}
53
kind: PersistentVolumeClaim
64
apiVersion: v1
75
metadata:

snyk-monitor/values.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,12 @@ clusterName: ""
3737
# This value controls how much disk storage _at most_ may be allocated for the snyk-monitor. Unless overridden by the `pvc` value, the snyk-monitor mounts an emptyDir for storage.
3838
temporaryStorageSize: 50Gi # Applies to PVC too
3939

40-
# Change to true to use a PVC instead of emptyDir for local storage
40+
# Change "enabled" to true to use a PVC instead of emptyDir for local storage.
41+
# Change "create" to true if you want to create the PVC (useful for first time run).
4142
pvc:
4243
enabled: false
4344
name: snyk-monitor-pvc
45+
create: false
4446
## snyk-monitor data Persistent Volume Storage Class
4547
## If defined, storageClassName: <storageClass>
4648
## If set to "-", storageClassName: "", which disables dynamic provisioning

snyk-operator/deploy/olm-catalog/snyk-operator/0.0.0/snyk-operator.v0.0.0.clusterserviceversion.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ metadata:
2323
"temporaryStorageSize": "50Gi",
2424
"pvc": {
2525
"enabled": false,
26+
"create": false,
2627
"name": "snyk-monitor-pvc",
2728
"storageClassName": null
2829
},
@@ -121,6 +122,12 @@ spec:
121122
path: pvc.enabled
122123
x-descriptors:
123124
- "urn:alm:descriptor:com.tectonic.ui:booleanSwitch"
125+
- description: >-
126+
True to create the PVC, false to reference it (in cases it already exists).
127+
displayName: Create PVC
128+
path: pvc.create
129+
x-descriptors:
130+
- "urn:alm:descriptor:com.tectonic.ui:booleanSwitch"
124131
- description: >-
125132
The name of the PVC, when enabled.
126133
displayName: PVC name

snyk-operator/deploy/olm-catalog/snyk-operator/0.0.0/snykmonitors.charts.helm.k8s.io.crd.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ spec:
5050
properties:
5151
enabled:
5252
type: boolean
53+
create:
54+
type: boolean
5355
name:
5456
type: string
5557
storageClassName:

test/fixtures/operator/custom-resource-k8s.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ spec:
88
temporaryStorageSize: 20Gi
99
pvc:
1010
enabled: true
11+
create: true

test/fixtures/operator/custom-resource.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ spec:
88
temporaryStorageSize: 20Gi
99
pvc:
1010
enabled: true
11+
create: true

test/setup/deployers/helm.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ async function deployKubernetesMonitor(
3333
'--set nodeSelector."kubernetes\\.io/os"=linux ' +
3434
'--set psp.enabled=true ' +
3535
'--set pvc.enabled=true ' +
36+
'--set pvc.create=true ' +
3637
'--set log_level="INFO"'
3738
);
3839
console.log(`Deployed ${imageOptions.nameAndTag} with pull policy ${imageOptions.pullPolicy}`);

0 commit comments

Comments
 (0)