Skip to content

Commit dfefa09

Browse files
authored
Cleanup and refactor helm chart (kadalu#615)
- Removal of Socat pod from nodeplugin - Refactored helm chart into operator and csi-nodeplugin (sub)charts Updates: kadalu#608 Signed-off-by: Leela Venkaiah G <[email protected]>
1 parent 61589ac commit dfefa09

33 files changed

+228
-179
lines changed

Makefile

+7-1
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,13 @@ test-containers:
3030
gen-manifest:
3131
@echo "Generating manifest files, run the following commands"
3232
@echo
33+
@echo "Install Kadalu Operator followed by CSI Nodeplugin"
34+
@echo
3335
@mkdir -p manifests
3436
@DOCKER_USER=${DOCKER_USER} KADALU_VERSION=${KADALU_VERSION} \
3537
python3 extras/scripts/gen_manifest.py manifests/kadalu-operator.yaml
3638
@echo "kubectl apply -f manifests/kadalu-operator.yaml"
39+
@echo "kubectl apply -f manifests/csi-nodeplugin.yaml"
3740
@DOCKER_USER=${DOCKER_USER} KADALU_VERSION=${KADALU_VERSION} \
3841
K8S_DIST=openshift \
3942
python3 extras/scripts/gen_manifest.py manifests/kadalu-operator-openshift.yaml
@@ -45,6 +48,7 @@ gen-manifest:
4548
@echo 'Run `oc login -u system:admin` to login as admin'
4649
@echo
4750
@echo "oc create -f manifests/kadalu-operator-openshift.yaml"
51+
@echo "oc create -f manifests/csi-nodeplugin-openshift.yaml"
4852

4953
@DOCKER_USER=${DOCKER_USER} KADALU_VERSION=${KADALU_VERSION} \
5054
K8S_DIST=microk8s \
@@ -54,6 +58,7 @@ gen-manifest:
5458
@echo "the following command"
5559
@echo
5660
@echo "kubectl apply -f manifests/kadalu-operator-microk8s.yaml"
61+
@echo "kubectl apply -f manifests/csi-nodeplugin-microk8s.yaml"
5762

5863
@DOCKER_USER=${DOCKER_USER} KADALU_VERSION=${KADALU_VERSION} \
5964
K8S_DIST=rke \
@@ -63,6 +68,7 @@ gen-manifest:
6368
@echo "the following command"
6469
@echo
6570
@echo "kubectl apply -f manifests/kadalu-operator-rke.yaml"
71+
@echo "kubectl apply -f manifests/csi-nodeplugin-rke.yaml"
6672

6773
pylint:
6874
@cp lib/kadalulib.py csi/
@@ -121,7 +127,7 @@ pypi-build:
121127

122128
helm-chart:
123129
@echo "Creating tgz archive of helm chart(Version: ${KADALU_VERSION}).."
124-
cd helm; sed -i -e "s/0.0.0-0/${KADALU_VERSION}/" kadalu/Chart.yaml; tar -czf kadalu-helm-chart.tgz kadalu
130+
cd helm; grep -rln '0.0.0-0' | grep Chart | xargs -I file sed -i -e "s/0.0.0-0/${KADALU_VERSION}/" file; tar -czf kadalu-helm-chart.tgz kadalu
125131

126132
gen-requirements:
127133
@echo "Generating requirements file for all kadalu components and CI"

README.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,20 @@ Where `K8S_DIST` can be one of below values:
6161

6262
If `--set-string` isn't supplied `kubernetes` will be used as default.
6363

64-
NOTE: We are still evolving with Helm chart based development, and happy to get contributions on the same.
64+
For Kadalu Versions >= 0.8.5 helm chart is broken into subcharts, refer below for installation:
65+
```
66+
# Takes values as mentioned above
67+
K8S_DIST=kubernetes
68+
curl -sL https://github.com/kadalu/kadalu/releases/latest/download/kadalu-helm-chart.tgz -o /tmp/kadalu-helm-chart.tgz
69+
70+
# First install operator
71+
helm install operator --namespace kadalu --create-namespace /tmp/kadalu-helm-chart.tgz --set operator.enabled=true --set operator.kubernetesDistro=$K8S_DIST
6572
73+
# Incase of Kadalu upgrade verify pod eviction and no usage of Kadalu PVCs, for fresh installation just proceed after operator deployment
74+
helm install csi-nodeplugin --namespace kadalu /tmp/kadalu-helm-chart.tgz --set csi-nodeplugin.enabled=true --set csi-nodeplugin.kubernetesDistro=$K8S_DIST
75+
```
76+
77+
NOTE: We are still evolving with Helm chart based development, and happy to get contributions on the same.
6678

6779
## Platform supports
6880

extras/scripts/gen_manifest.py

-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ def template(filename, template_file=None, template_args=None):
3131
KADALU_VERSION = os.environ.get("KADALU_VERSION", "latest")
3232
K8S_DIST = os.environ.get("K8S_DIST", "kubernetes")
3333
VERBOSE = os.environ.get("VERBOSE", "no")
34-
DEPLOY_SOCAT = os.environ.get("DEPLOY_SOCAT", "no")
3534
KUBELET_DIR = "/var/lib/kubelet"
3635
if K8S_DIST == "microk8s":
3736
KUBELET_DIR = "/var/snap/microk8s/common/var/lib/kubelet"
@@ -45,7 +44,6 @@ def template(filename, template_file=None, template_args=None):
4544
"k8s_dist": K8S_DIST,
4645
"kubelet_dir": KUBELET_DIR,
4746
"verbose": VERBOSE,
48-
"deploy_socat": DEPLOY_SOCAT,
4947
}
5048

5149
template(sys.argv[1], template_file="operator.yaml.j2", template_args=TEMPLATE_ARGS)

helm/kadalu/.helmignore

-23
This file was deleted.

helm/kadalu/Chart.yaml

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
apiVersion: v2
22
name: kadalu
33
icon: https://kadalu.io/static/css/logo.png
4-
description: kadalu.io Storage Operator and CSI for k8s (with glusterfs)
4+
description: Contains subchart for deploying Kadalu Operator and Kadalu CSI Nodeplugin
55
type: application
66
# Value of 'version' will be replaced with correct version on part of release
77
version: 0.0.0-0
8+
dependencies:
9+
- name: operator
10+
repository: file://charts/operator
11+
condition: operator.enabled
12+
- name: csi-nodeplugin
13+
repository: file://charts/csi-nodeplugin
14+
condition: csi-nodeplugin.enabled
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: v2
2+
name: csi-nodeplugin
3+
icon: https://kadalu.io/static/css/logo.png
4+
description: kadalu.io CSI Nodeplugin
5+
type: application
6+
# Value of 'version' will be replaced with correct version on part of release
7+
version: 0.0.0-0
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
The Kadalu CSI Nodeplugin has been installed. Check its status by running:
2+
kubectl --namespace {{ .Release.Namespace }} get pods
3+
4+
Visit https://kadalu.io/docs/k8s-storage/latest for instructions on how to add storage and create PVs out of it.
5+
6+
Important Notes:
7+
- You can add storage pools with different types using 'KadaluStorage' type.
8+
- The helm chart includes all the RBAC required to create kadalu.io CRD.
9+
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
kind: ClusterRole
3+
apiVersion: rbac.authorization.k8s.io/v1
4+
metadata:
5+
name: kadalu-csi-nodeplugin
6+
rules:
7+
- apiGroups: [""]
8+
resources: ["events"]
9+
verbs: ["get", "list", "watch", "create", "update", "patch"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
kind: ClusterRoleBinding
3+
apiVersion: rbac.authorization.k8s.io/v1
4+
metadata:
5+
name: kadalu-csi-nodeplugin
6+
namespace: {{ .Release.Namespace }}
7+
subjects:
8+
- kind: ServiceAccount
9+
name: kadalu-csi-nodeplugin
10+
namespace: {{ .Release.Namespace }}
11+
roleRef:
12+
kind: ClusterRole
13+
name: kadalu-csi-nodeplugin
14+
apiGroup: rbac.authorization.k8s.io
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
kind: DaemonSet
2+
apiVersion: apps/v1
3+
metadata:
4+
name: kadalu-csi-nodeplugin
5+
namespace: {{ .Release.Namespace }}
6+
labels:
7+
app.kubernetes.io/part-of: kadalu
8+
app.kubernetes.io/component: csi-driver
9+
app.kubernetes.io/name: kadalu-csi-nodeplugin
10+
spec:
11+
selector:
12+
matchLabels:
13+
app.kubernetes.io/part-of: kadalu
14+
app.kubernetes.io/component: csi-driver
15+
app.kubernetes.io/name: kadalu-csi-nodeplugin
16+
template:
17+
metadata:
18+
labels:
19+
app.kubernetes.io/part-of: kadalu
20+
app.kubernetes.io/component: csi-driver
21+
app.kubernetes.io/name: kadalu-csi-nodeplugin
22+
namespace: {{ .Release.Namespace }}
23+
spec:
24+
serviceAccountName: kadalu-csi-nodeplugin
25+
containers:
26+
- name: csi-node-driver-registrar
27+
image: docker.io/raspbernetes/csi-node-driver-registrar:2.0.1
28+
args:
29+
- "--v=5"
30+
- "--csi-address=$(ADDRESS)"
31+
- "--kubelet-registration-path=$(DRIVER_REG_SOCK_PATH)"
32+
lifecycle:
33+
preStop:
34+
exec:
35+
command: ["/bin/sh", "-c", "rm -rf /registration/kadalu /registration/kadalu-reg.sock"]
36+
env:
37+
- name: ADDRESS
38+
value: /plugin/csi.sock
39+
- name: DRIVER_REG_SOCK_PATH
40+
{{- if (eq .Values.kubernetesDistro "microk8s") }}
41+
value: /var/snap/microk8s/common/var/lib/kubelet/plugins_registry/kadalu/csi.sock
42+
{{- else }}
43+
value: /var/lib/kubelet/plugins_registry/kadalu/csi.sock
44+
{{- end }}
45+
- name: KUBE_NODE_NAME
46+
valueFrom:
47+
fieldRef:
48+
fieldPath: spec.nodeName
49+
volumeMounts:
50+
- name: plugin-dir
51+
mountPath: /plugin
52+
- name: registration-dir
53+
mountPath: /registration
54+
- name: kadalu-nodeplugin
55+
securityContext:
56+
privileged: true
57+
capabilities:
58+
add: ["SYS_ADMIN"]
59+
allowPrivilegeEscalation: true
60+
image: docker.io/kadalu/kadalu-csi:{{- if eq .Chart.Version "0.0.0-0" }}devel{{- else}}{{.Chart.Version}}{{- end }}
61+
env:
62+
- name: NODE_ID
63+
valueFrom:
64+
fieldRef:
65+
fieldPath: spec.nodeName
66+
- name: CSI_ENDPOINT
67+
value: unix://plugin/csi.sock
68+
- name: KADALU_VERSION
69+
value: "{{- if eq .Chart.Version "0.0.0-0" }}devel{{- else}}{{.Chart.Version}}{{- end }}"
70+
- name: K8S_DIST
71+
value: "{{ .Values.kubernetesDistro }}"
72+
- name: VERBOSE
73+
value: "{{ .Values.verbose }}"
74+
- name: CSI_ROLE
75+
value: "nodeplugin"
76+
volumeMounts:
77+
- name: plugin-dir
78+
mountPath: /plugin
79+
- name: pods-mount-dir
80+
{{- if (eq .Values.kubernetesDistro "microk8s") }}
81+
mountPath: /var/snap/microk8s/common/var/lib/kubelet/pods
82+
{{- else }}
83+
mountPath: /var/lib/kubelet/pods
84+
{{- end }}
85+
mountPropagation: "Bidirectional"
86+
- name: glusterfsd-volfilesdir
87+
mountPath: "/var/lib/gluster"
88+
- name: gluster-dev
89+
mountPath: "/dev"
90+
- name: varlog
91+
mountPath: /var/log/gluster
92+
- name: kadalu-logging
93+
image: docker.io/library/busybox
94+
command: ["/bin/sh"]
95+
args: ["-c", "while true; do logcnt=$(/bin/ls /var/log/gluster/ | wc -l); if [ ${logcnt} -gt 0 ]; then break; fi; sleep 5; done; tail -f /var/log/gluster/*.log"]
96+
volumeMounts:
97+
- name: varlog
98+
mountPath: "/var/log/gluster"
99+
volumes:
100+
- name: plugin-dir
101+
hostPath:
102+
{{- if (eq .Values.kubernetesDistro "microk8s") }}
103+
path: /var/snap/microk8s/common/var/lib/kubelet/plugins_registry/kadalu
104+
{{- else }}
105+
path: /var/lib/kubelet/plugins_registry/kadalu
106+
{{- end }}
107+
type: DirectoryOrCreate
108+
- name: pods-mount-dir
109+
hostPath:
110+
{{- if (eq .Values.kubernetesDistro "microk8s") }}
111+
path: /var/snap/microk8s/common/var/lib/kubelet/pods
112+
{{- else }}
113+
path: /var/lib/kubelet/pods
114+
{{- end }}
115+
type: Directory
116+
- name: registration-dir
117+
hostPath:
118+
{{- if (eq .Values.kubernetesDistro "microk8s") }}
119+
path: /var/snap/microk8s/common/var/lib/kubelet/plugins_registry/
120+
{{- else }}
121+
path: /var/lib/kubelet/plugins_registry/
122+
{{- end }}
123+
type: Directory
124+
- name: glusterfsd-volfilesdir
125+
configMap:
126+
name: "kadalu-info"
127+
- name: gluster-dev
128+
hostPath:
129+
path: "/dev"
130+
- name: varlog
131+
emptyDir: {}
132+
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: v2
2+
name: operator
3+
icon: https://kadalu.io/static/css/logo.png
4+
description: kadalu.io Storage Operator and CSI for k8s (with glusterfs)
5+
type: application
6+
# Value of 'version' will be replaced with correct version on part of release
7+
version: 0.0.0-0

helm/kadalu/templates/deployment.yaml helm/kadalu/charts/operator/templates/deployment.yaml

-2
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,3 @@ spec:
5252
value: "{{ .Values.kubernetesDistro }}"
5353
- name: VERBOSE
5454
value: "{{ .Values.verbose }}"
55-
- name: DEPLOY_SOCAT
56-
value: "{{ .Values.deploy_socat }}"

helm/kadalu/templates/_helpers.tpl

-62
This file was deleted.

0 commit comments

Comments
 (0)