From 774a7764d397f3bcddea7e67a5948ed79f55e28f Mon Sep 17 00:00:00 2001 From: Ari Sosnovsky Date: Tue, 21 Feb 2023 22:22:23 +0000 Subject: [PATCH] added longhorn --- bin/start-minikube.sh | 4 +- k8s/argocd/templates/app-longhorn.yaml | 100 ++++++++++++++++++ .../{self-app.yaml => app-self.yaml} | 5 - ...plicationset.yaml => appset-services.yaml} | 0 .../{projects.yaml => project-services.yaml} | 0 .../{repo.yaml => secret-repo-main.yaml} | 0 6 files changed, 101 insertions(+), 8 deletions(-) create mode 100644 k8s/argocd/templates/app-longhorn.yaml rename k8s/argocd/templates/{self-app.yaml => app-self.yaml} (85%) rename k8s/argocd/templates/{applicationset.yaml => appset-services.yaml} (100%) rename k8s/argocd/templates/{projects.yaml => project-services.yaml} (100%) rename k8s/argocd/templates/{repo.yaml => secret-repo-main.yaml} (100%) diff --git a/bin/start-minikube.sh b/bin/start-minikube.sh index c71a643..554b39a 100644 --- a/bin/start-minikube.sh +++ b/bin/start-minikube.sh @@ -2,6 +2,4 @@ set -e -minikube start -minikube addons enable ingress -minikube addons enable dashboard \ No newline at end of file +minikube start \ No newline at end of file diff --git a/k8s/argocd/templates/app-longhorn.yaml b/k8s/argocd/templates/app-longhorn.yaml new file mode 100644 index 0000000..45af41e --- /dev/null +++ b/k8s/argocd/templates/app-longhorn.yaml @@ -0,0 +1,100 @@ +{{- if .Values.selfapp.enabled -}} +--- +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: longhorn + namespace: "{{ .Release.Namespace }}" +spec: + project: default + source: + chart: longhorn + repoURL: https://charts.longhorn.io + targetRevision: v1.4.0 + helm: + releaseName: longhorn + destination: + server: "https://kubernetes.default.svc" + namespace: longhorn + syncPolicy: + syncOptions: + - CreateNamespace=true +--- +# source: https://raw.githubusercontent.com/longhorn/longhorn/v1.4.0/deploy/prerequisite/longhorn-iscsi-installation.yaml +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: longhorn-iscsi-installation + namespace: "{{ .Release.Namespace }}" + labels: + app: longhorn-iscsi-installation + annotations: + command: &cmd OS=$(grep -E "^ID_LIKE=" /etc/os-release | cut -d '=' -f 2); if [[ -z "${OS}" ]]; then OS=$(grep -E "^ID=" /etc/os-release | cut -d '=' -f 2); fi; if [[ "${OS}" == *"debian"* ]]; then sudo apt-get update -q -y && sudo apt-get install -q -y open-iscsi && sudo systemctl -q enable iscsid && sudo systemctl start iscsid && sudo modprobe iscsi_tcp; elif [[ "${OS}" == *"suse"* ]]; then sudo zypper --gpg-auto-import-keys -q refresh && sudo zypper --gpg-auto-import-keys -q install -y open-iscsi && sudo systemctl -q enable iscsid && sudo systemctl start iscsid && sudo modprobe iscsi_tcp; else sudo yum makecache -q -y && sudo yum --setopt=tsflags=noscripts install -q -y iscsi-initiator-utils && echo "InitiatorName=$(/sbin/iscsi-iname)" > /etc/iscsi/initiatorname.iscsi && sudo systemctl -q enable iscsid && sudo systemctl start iscsid && sudo modprobe iscsi_tcp; fi && if [ $? -eq 0 ]; then echo "iscsi install successfully"; else echo "iscsi install failed error code $?"; fi +spec: + selector: + matchLabels: + app: longhorn-iscsi-installation + template: + metadata: + labels: + app: longhorn-iscsi-installation + spec: + hostNetwork: true + hostPID: true + initContainers: + - name: iscsi-installation + command: + - nsenter + - --mount=/proc/1/ns/mnt + - -- + - bash + - -c + - *cmd + image: alpine:3.12 + securityContext: + privileged: true + containers: + - name: sleep + image: k8s.gcr.io/pause:3.1 + updateStrategy: + type: RollingUpdate +--- +# source: https://raw.githubusercontent.com/longhorn/longhorn/v1.4.0/deploy/prerequisite/longhorn-nfs-installation.yaml +apiVersion: apps/v1 +kind: DaemonSet +metadata: + name: longhorn-nfs-installation + namespace: "{{ .Release.Namespace }}" + labels: + app: longhorn-nfs-installation + annotations: + command: &cmd OS=$(grep -E "^ID_LIKE=" /etc/os-release | cut -d '=' -f 2); if [[ -z "${OS}" ]]; then OS=$(grep -E "^ID=" /etc/os-release | cut -d '=' -f 2); fi; if [[ "${OS}" == *"debian"* ]]; then sudo apt-get update -q -y && sudo apt-get install -q -y nfs-common && sudo modprobe nfs; elif [[ "${OS}" == *"suse"* ]]; then sudo zypper --gpg-auto-import-keys -q refresh && sudo zypper --gpg-auto-import-keys -q install -y nfs-client && sudo modprobe nfs; else sudo yum makecache -q -y && sudo yum --setopt=tsflags=noscripts install -q -y nfs-utils && sudo modprobe nfs; fi && if [ $? -eq 0 ]; then echo "nfs install successfully"; else echo "nfs install failed error code $?"; fi +spec: + selector: + matchLabels: + app: longhorn-nfs-installation + template: + metadata: + labels: + app: longhorn-nfs-installation + spec: + hostNetwork: true + hostPID: true + initContainers: + - name: nfs-installation + command: + - nsenter + - --mount=/proc/1/ns/mnt + - -- + - bash + - -c + - *cmd + image: alpine:3.12 + securityContext: + privileged: true + containers: + - name: sleep + image: k8s.gcr.io/pause:3.1 + updateStrategy: + type: RollingUpdate +{{- end -}} \ No newline at end of file diff --git a/k8s/argocd/templates/self-app.yaml b/k8s/argocd/templates/app-self.yaml similarity index 85% rename from k8s/argocd/templates/self-app.yaml rename to k8s/argocd/templates/app-self.yaml index c879cba..912955e 100644 --- a/k8s/argocd/templates/self-app.yaml +++ b/k8s/argocd/templates/app-self.yaml @@ -20,9 +20,4 @@ spec: destination: server: https://kubernetes.default.svc namespace: "{{ .Release.Namespace }}" - # syncPolicy: - # automated: - # prune: false - # selfHeal: true - # allowEmpty: true {{- end -}} \ No newline at end of file diff --git a/k8s/argocd/templates/applicationset.yaml b/k8s/argocd/templates/appset-services.yaml similarity index 100% rename from k8s/argocd/templates/applicationset.yaml rename to k8s/argocd/templates/appset-services.yaml diff --git a/k8s/argocd/templates/projects.yaml b/k8s/argocd/templates/project-services.yaml similarity index 100% rename from k8s/argocd/templates/projects.yaml rename to k8s/argocd/templates/project-services.yaml diff --git a/k8s/argocd/templates/repo.yaml b/k8s/argocd/templates/secret-repo-main.yaml similarity index 100% rename from k8s/argocd/templates/repo.yaml rename to k8s/argocd/templates/secret-repo-main.yaml