@@ -484,6 +484,116 @@ spec:
484
484
{{- end }}
485
485
486
486
{{- end }}
487
+ {{- if $.Values.st2.packs.volumes.enabled }}
488
+ ---
489
+ apiVersion : batch/v1
490
+ kind : Job
491
+ metadata :
492
+ name : {{ $.Release.Name }}-job-st2canary-for-writable-packs-volumes
493
+ labels : {{- include "stackstorm-ha.labels" (list $ "st2canary") | nindent 4 }}
494
+ annotations :
495
+ helm.sh/hook : pre-install, pre-upgrade, pre-rollback
496
+ helm.sh/hook-weight : " -5" # fairly high priority
497
+ helm.sh/hook-delete-policy : hook-succeeded
498
+ {{- if $.Values.st2canary.annotations }}
499
+ {{- toYaml $.Values.st2canary.annotations | nindent 4 }}
500
+ {{- end }}
501
+ spec :
502
+ template :
503
+ metadata :
504
+ name : job-st2canary-for-writable-packs-volumes
505
+ labels : {{- include "stackstorm-ha.labels" (list $ "st2canary") | nindent 8 }}
506
+ annotations :
507
+ {{- if $.Values.st2canary.annotations }}
508
+ {{- toYaml $.Values.st2canary.annotations | nindent 8 }}
509
+ {{- end }}
510
+ spec :
511
+ imagePullSecrets :
512
+ {{- if $.Values.image.pullSecret }}
513
+ - name : {{ $.Values.image.pullSecret }}
514
+ {{- end }}
515
+ initContainers : []
516
+ containers :
517
+ - name : st2canary-for-writable-packs-volumes
518
+ image : ' {{ template "stackstorm-ha.imageRepository" $ }}/st2actionrunner:{{ tpl $.Values.image.tag $ }}'
519
+ # image: busybox:1.28
520
+ imagePullPolicy : {{ $.Values.image.pullPolicy }}
521
+ {{- with $.Values.securityContext }}
522
+ securityContext : {{- toYaml . | nindent 10 }}
523
+ {{- end }}
524
+ # TODO: maybe use kubectl to assert the volumes have RWX mode
525
+ # If volume is a persistentVolumeClaim, then:
526
+ # the PVC must only have ReadWriteMany in spec.accessModes
527
+ # If volume is something else, then validating through metadata is iffy.
528
+ # azureFile, cephfs, csi, glusterfs, nfs, pvc, quobyte, need at least:
529
+ # readOnly: false
530
+ # ephemeral volumes could also work, ... but that config is even deeper.
531
+ command :
532
+ - ' sh'
533
+ - ' -ec'
534
+ - |
535
+ echo Testing write permissions for packs volumes.
536
+ echo If this passes, the pod will automatically be deleted.
537
+ echo If this fails, inspect the pod for errors in kubernetes,
538
+ echo and then delete this st2canary pod manually.
539
+ echo
540
+ echo Testing write permissions on packs volume...
541
+ touch /opt/stackstorm/packs/.write-test
542
+ rm /opt/stackstorm/packs/.write-test
543
+ echo
544
+ echo Testing write permissions on virtualenvs volume...
545
+ touch /opt/stackstorm/virtualenvs/.write-test
546
+ rm /opt/stackstorm/virtualenvs/.write-test
547
+ echo
548
+ {{- if $.Values.st2.packs.volumes.configs }}
549
+ echo Testing write permissions on configs volume...
550
+ touch /opt/stackstorm/configs/.write-test
551
+ rm /opt/stackstorm/configs/.write-test
552
+ echo
553
+ {{- end }}
554
+ echo DONE
555
+ volumeMounts :
556
+ {{- include "stackstorm-ha.packs-volume-mounts" $ | nindent 8 }}
557
+ {{/* do not include the pack-configs-volume-mount helper here */}}
558
+ - name : st2-pack-configs-vol
559
+ mountPath : /opt/stackstorm/configs/
560
+ readOnly : false
561
+ {{- range $.Values.st2canary.extra_volumes }}
562
+ - name : {{ required "Each volume must have a 'name' in st2canary.extra_volumes" .name }}
563
+ {{- tpl (required "Each volume must have a 'mount' definition in st2canary.extra_volumes" .mount | toYaml) $ | nindent 10 }}
564
+ {{- end }}
565
+ resources :
566
+ {{- toYaml $.Values.st2canary.resources | nindent 10 }}
567
+ volumes :
568
+ {{- include "stackstorm-ha.packs-volumes" $ | nindent 8 }}
569
+ {{- if $.Values.st2.packs.volumes.configs }}
570
+ {{/* do not include the pack-configs-volume helper here */}}
571
+ - name : st2-pack-configs-vol
572
+ {{- toYaml $.Values.st2.packs.volumes.configs | nindent 10 }}
573
+ {{- end }}
574
+ {{- range $.Values.st2canary.extra_volumes }}
575
+ - name : {{ required "Each volume must have a 'name' in st2canary.extra_volumes" .name }}
576
+ {{- tpl (required "Each volume must have a 'volume' definition in st2canary.extra_volumes" .volume | toYaml) $ | nindent 10 }}
577
+ {{- end }}
578
+ {{- if $.Values.dnsPolicy }}
579
+ dnsPolicy : {{ $.Values.dnsPolicy }}
580
+ {{- end }}
581
+ {{- with $.Values.dnsConfig }}
582
+ dnsConfig : {{- toYaml . | nindent 8 }}
583
+ {{- end }}
584
+ {{- with $.Values.podSecurityContext }}
585
+ securityContext : {{- toYaml . | nindent 8 }}
586
+ {{- end }}
587
+ {{- with $.Values.st2canary.nodeSelector }}
588
+ nodeSelector : {{- toYaml . | nindent 8 }}
589
+ {{- end }}
590
+ {{- with $.Values.st2canary.affinity }}
591
+ affinity : {{- toYaml . | nindent 8 }}
592
+ {{- end }}
593
+ {{- with $.Values.st2canary.tolerations }}
594
+ tolerations : {{- toYaml . | nindent 8 }}
595
+ {{- end }}
596
+ {{- end }}
487
597
{{- range .Values.jobs.extra_hooks -}}
488
598
{{- $name := print "extra-helm-hook" (include "stackstorm-ha.hyphenPrefix" (required "You must name each entry in jobs.extra_hooks." .name)) }}
489
599
{{- if not ($.Values.jobs.skip | has $name) }}
0 commit comments