Skip to content
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

Add a post-install hook to restart cvmfs csi pods #419

Merged
merged 2 commits into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions galaxy/templates/configmap-cvmfs-fix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-configmap-cvmfs-fix
labels:
{{- include "galaxy.labels" . | nindent 4 }}
data:
cvmfs-fix.sh: |
sleep 10;
while [ "$(kubectl get pods -n {{ .Release.Namespace }} -l 'app=cvmfscis' -l 'component=nodeplugin' -o custom-columns=STATUS:.status.phase --no-headers)" != "Running" ]; do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the app label correct? Shouldn't it be cvmfscsi instead?
Also, will this work if there are multiple nodes and get pods returns multiple lines for running pods?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both good catches. Should be fixed now.

echo "Waiting on nodeplugin pod to enter 'Running' status.";
sleep 1;
done && \
echo "Deleting nodeplugin pods..."
kubectl get pods -n {{ .Release.Namespace }} -l 'app=cvmfscis' -l 'component=nodeplugin' -o name | xargs kubectl -n {{ .Release.Namespace }} delete && \
echo "Deleted nodeplugin pods."
35 changes: 35 additions & 0 deletions galaxy/templates/hook-cvmfs-fix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: batch/v1
kind: Job
metadata:
name: "{{ .Release.Name }}-post-install-cvmfs-fix-job"
labels:
{{- include "galaxy.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": post-install
"helm.sh/hook-weight": "10"
"helm.sh/hook-delete-policy": hook-succeeded
spec:
ttlSecondsAfterFinished: 120
template:
metadata:
name: "{{ .Release.Name }}-post-install-cvmfs-fix-job"
labels:
{{- include "galaxy.labels" . | nindent 8 }}
spec:
serviceAccountName: {{ include "galaxy.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.securityContext | nindent 8 }}
restartPolicy: Never
containers:
- name: post-install-kubectl
image: bitnami/kubectl
command:
- "sh"
- "/script/cvmfs-fix.sh"
volumeMounts:
- name: kubectl-script
mountPath: "/script"
volumes:
- name: kubectl-script
configMap:
name: "{{ .Release.Name }}-configmap-cvmfs-fix"
2 changes: 1 addition & 1 deletion galaxy/templates/rbac-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ metadata:
rules:
- apiGroups: [""]
resources: ["pods", "pods/log"]
verbs: ["get", "list", "watch"]
verbs: ["get", "list", "watch", "delete"]
- apiGroups: ["batch", "extensions"]
resources: ["jobs"]
verbs: ["get", "list", "watch", "create", "update", "patch", "delete"]
Expand Down