From b230eb310e9f27e53d8dfba3fbaa9581a797795d Mon Sep 17 00:00:00 2001 From: Sheogorath <sheogorath@shivering-isles.com> Date: Thu, 28 Dec 2023 15:45:03 +0100 Subject: [PATCH] fix(longhorn): Workaround for share-manager problems --- infrastructure/longhorn/hotfix-7183.yaml | 70 ++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 infrastructure/longhorn/hotfix-7183.yaml diff --git a/infrastructure/longhorn/hotfix-7183.yaml b/infrastructure/longhorn/hotfix-7183.yaml new file mode 100644 index 000000000..1e6a96c98 --- /dev/null +++ b/infrastructure/longhorn/hotfix-7183.yaml @@ -0,0 +1,70 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: longhorn-hotfix-7183 +spec: + jobTemplate: + spec: + template: + spec: + serviceAccountName: longhorn-hotfix-7183 + containers: + - image: docker.io/bitnami/kubectl:1.28 + name: longhorn-hotfix + resources: + requests: + cpu: 10m + memory: 128Mi + limits: + cpu: "1" + memory: 256Mi + command: + - /bin/bash + args: + - -c + - | + for i in $(kubectl get lhsm -n longhorn-system --no-headers -o custom-columns=NAME:metadata.name); do + if kubectl get pods --no-headers -n longhorn-system "share-manager-$i" | grep -v Running; then + kubectl patch lhsm -n longhorn-system --type=merge --subresource status --patch 'status: {state: error}' $i + fi + done + restartPolicy: OnFailure + schedule: '*/5 * * * *' +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: longhorn-hotfix-7183 +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: longhorn-hotfix-7183 +rules: +- apiGroups: + - "" + resources: + - pods + verbs: + - get +- apiGroups: + - "longhorn.io" + resources: + - sharemanagers + - sharemanagers/status + verbs: + - patch + - get + - list +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: longhorn-hotfix-7183 +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: Role + name: longhorn-hotfix-7183 +subjects: +- kind: ServiceAccount + name: longhorn-hotfix-7183 -- GitLab