Skip to content

Commit

Permalink
fix: convert the object-bucket-claim Job into a Helm hook (#1479)
Browse files Browse the repository at this point in the history
* fix: convert the `object-bucket-claim` Job into a Helm hook

* chore: rename the Job to avoid collisions with older non-hook versions
  • Loading branch information
asekretenko authored Feb 15, 2024
1 parent 94fc720 commit 74d1f0e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 16 deletions.
4 changes: 2 additions & 2 deletions stable/object-bucket-claim/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ description: A Helm chart for ObjectBucketClaim to be consumed by other applicat
home: https://github.com/mesosphere/charts
keywords:
- kommander
version: 0.1.8
appVersion: "0.1.7"
version: 0.1.9
appVersion: "0.1.9"
maintainers:
- name: cwyl02
- name: takirala
2 changes: 0 additions & 2 deletions stable/object-bucket-claim/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ dkp:
# generateBucketName: ceph-bkt
storageClassName: s3-provider-sc
priorityClassName: dkp-critical-priority
ttlSecondsAfterFinished: 100

labels: {}
additionalConfig:
Expand All @@ -50,7 +49,6 @@ their default values. (`$app` is `velero`|`loki`|`your-app` in the example above
| `dkp.$app.additionalConfig.maxObjects` | Limit of number of S3 objects this bucket can hold | "" |
| `dkp.$app.additionalConfig.maxSize` | Limit of the storage this S3 bucket can use from the S3 storage provider | "" |
| `dkp.$app.priorityClassName` | Priority class to set on pods | "" |
| `dkp.$app.ttlSecondsAfterFinished` | Number of seconds to clean up the Job after it has finished | "" |

Specify each parameter using the `--set key=value[,key=value]` argument to
`helm install`.
34 changes: 23 additions & 11 deletions stable/object-bucket-claim/templates/object-bucket-claim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,20 @@ spec:
apiVersion: v1
kind: ServiceAccount
metadata:
name: check-{{ $config.bucketName }}
name: object-bucket-claims-check-{{ $config.bucketName }}
annotations:
helm.sh/hook: post-install, post-upgrade
helm.sh/hook-weight: "-5"
helm.sh/hook-delete-policy: before-hook-creation
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: check-{{ $config.bucketName }}
name: object-bucket-claims-check-{{ $config.bucketName }}
annotations:
helm.sh/hook: post-install, post-upgrade
helm.sh/hook-weight: "-5"
helm.sh/hook-delete-policy: before-hook-creation
rules:
- apiGroups: [""]
resources: ["secrets"]
Expand All @@ -48,30 +56,34 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: check-{{ $config.bucketName }}
name: object-bucket-claims-check-{{ $config.bucketName }}
annotations:
helm.sh/hook: post-install, post-upgrade
helm.sh/hook-weight: "-4"
helm.sh/hook-delete-policy: before-hook-creation
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: check-{{ $config.bucketName }}
name: object-bucket-claims-check-{{ $config.bucketName }}
subjects:
- kind: ServiceAccount
name: check-{{ $config.bucketName }}
name: object-bucket-claims-check-{{ $config.bucketName }}
namespace: {{ $.Release.Namespace }}
---
apiVersion: batch/v1
kind: Job
metadata:
name: check-{{ $config.bucketName }}
name: object-bucket-claims-check-{{ $config.bucketName }}
annotations:
helm.sh/hook: post-install, post-upgrade
helm.sh/hook-delete-policy: before-hook-creation
spec:
backoffLimit: 12
{{- if $config.ttlSecondsAfterFinished }}
ttlSecondsAfterFinished: {{ $config.ttlSecondsAfterFinished }}
{{- end }}
template:
metadata:
name: check-{{ $config.bucketName }}
name: object-bucket-claims-check-{{ $config.bucketName }}
spec:
serviceAccountName: check-{{ $config.bucketName }}
serviceAccountName: object-bucket-claims-check-{{ $config.bucketName }}
restartPolicy: OnFailure
{{- if $config.priorityClassName }}
priorityClassName: "{{ $config.priorityClassName }}"
Expand Down
1 change: 0 additions & 1 deletion stable/object-bucket-claim/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ dkp:
# labels: {}
# priorityClassName: dkp-critical-priority
# # it is required to set ttl for jobs to avoid immutable errors during upgrades if certain spec fields change
# ttlSecondsAfterFinished: 100
# additionalConfig:
# # maxObjects: "1000"
# # in string format like "2G", minimum is "4K"
Expand Down

0 comments on commit 74d1f0e

Please sign in to comment.