├── mongodb ├── values.yaml ├── templates │ ├── service.yaml │ └── statefulset.yaml └── Chart.yaml ├── manual ├── values.yaml ├── templates │ ├── service.yaml │ └── deployment.yaml └── Chart.yaml └── readme.MD /mongodb/values.yaml: -------------------------------------------------------------------------------- 1 | statefulset: 2 | replicaCount: 1 3 | imageVersion: v1 4 | service: 5 | port: 27017 -------------------------------------------------------------------------------- /manual/values.yaml: -------------------------------------------------------------------------------- 1 | # values.yaml is the file to supply default values to helm charts 2 | # you can always override this at run time 3 | deployment: 4 | replicaCount: 2 5 | imageVersion: alpine 6 | service: 7 | port: 80 -------------------------------------------------------------------------------- /manual/templates/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: nginx 5 | spec: 6 | type: LoadBalancer 7 | selector: 8 | app: nginx 9 | ports: 10 | - protocol: TCP 11 | port: {{ .Values.service.port }} 12 | targetPort: 80 -------------------------------------------------------------------------------- /manual/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | name: nginx 3 | version: 0.0.1 # this is the chart version, make sure you upgrade this version for every change 4 | description: This is to understand HELM through NgInx 5 | appVersion: 1.0.0 #this belongs to our application, make sure you upgrade this everytime your app changes -------------------------------------------------------------------------------- /mongodb/templates/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: mongodb 5 | namespace: roboshop 6 | labels: 7 | app: mongodb 8 | spec: 9 | ports: 10 | - port: {{ .Values.service.port }} 11 | name: mongodb 12 | clusterIP: None #headless service 13 | selector: 14 | name: mongodb 15 | tier: db -------------------------------------------------------------------------------- /mongodb/Chart.yaml: -------------------------------------------------------------------------------- 1 | # This file to supply mandatory metadata like name, apiVersion, etc to Helm 2 | apiVersion: v1 3 | name: roboshop-mongodb 4 | version: 0.0.1 # this is the chart version, make sure you upgrade this version for every change 5 | description: This is to understand How to convert mongodb into Helm 6 | appVersion: 1.0.0 #this belongs to our application, make sure you upgrade this everytime your app changes -------------------------------------------------------------------------------- /manual/templates/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: nginx 5 | labels: 6 | app: nginx 7 | spec: 8 | replicas: {{ .Values.deployment.replicaCount }} 9 | selector: 10 | matchLabels: 11 | app: nginx 12 | template: 13 | metadata: 14 | labels: 15 | app: nginx 16 | spec: 17 | containers: 18 | - name: nginx 19 | image: "nginx:{{ .Values.deployment.imageVersion }}" 20 | ports: 21 | - containerPort: 80 -------------------------------------------------------------------------------- /mongodb/templates/statefulset.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: StatefulSet 3 | metadata: 4 | name: mongodb 5 | namespace: roboshop 6 | spec: 7 | selector: 8 | matchLabels: 9 | name: mongodb # has to match .spec.template.metadata.labels 10 | tier: db 11 | serviceName: "mongodb" 12 | replicas: {{ .Values.statefulset.replicaCount }} # by default is 1 13 | template: 14 | metadata: 15 | labels: 16 | name: mongodb # has to match .spec.template.metadata.labels 17 | tier: db 18 | spec: 19 | containers: 20 | - name: mongodb 21 | image: "techworldwithsiva/mongodb:{{ .Values.statefulset.imageVersion }}" 22 | ports: 23 | - containerPort: 27017 24 | name: mongodb 25 | volumeMounts: 26 | - name: mongodb-volume 27 | mountPath: /data/db 28 | volumeClaimTemplates: 29 | - metadata: 30 | name: mongodb-volume 31 | spec: 32 | accessModes: [ "ReadWriteOnce" ] 33 | storageClassName: "ebs-sc" 34 | resources: 35 | requests: 36 | storage: 1Gi -------------------------------------------------------------------------------- /readme.MD: -------------------------------------------------------------------------------- 1 | ### HELM 2 | 3 | We use **HELM** in real time for 2 purposes. 4 | * Parameterize our application manifest files to supply image version, number of replicas, etc. at runtime. 5 | * As package manager to install the opensource applications into Kubernetes cluster. 6 | 7 | Helm important files are 8 | 9 | * Chart.yaml 10 | * templates folder 11 | * values.yaml 12 | 13 | #### Chart.yaml 14 | 15 | This file is to supply metadata for helm. We need to give apiVersion, chartname, chart version, etc through this file. 16 | **NOTE:** Make sure you increase the chartVersion and appVersion every time we do the change. 17 | 18 | #### templates folder 19 | 20 | Here we keep all the required Kubernetes resource YAML files. We can use placeholders inside the files. 21 | 22 | #### values.yaml 23 | 24 | This file is used to supply the default values to the placeholders of resources files in templates folder. 25 | 26 | Create the above files to convert any Kubernetes manifest into HELM. 27 | 28 | To install Helm chart. make sure you are in the directory where Chart.yaml is there 29 | 30 | ``` 31 | helm install [any-name-you-prefer] . 32 | ``` 33 | 34 | to list the charts running 35 | 36 | ``` 37 | helm list 38 | ``` 39 | 40 | to upgrade 41 | 42 | ``` 43 | helm upgrade [chart-name] . 44 | ``` 45 | 46 | to rollback 47 | 48 | ``` 49 | helm rollback [chart-name] [revision-no] 50 | ``` 51 | 52 | to list all revision numbers 53 | 54 | ``` 55 | helm history [chart-name] 56 | ``` 57 | to delete 58 | 59 | ``` 60 | helm delete/uninstall [chart-name] 61 | ``` 62 | 63 | to supply your own values.yaml 64 | 65 | ``` 66 | helm install [chart-name] . --values=[path-of-your-values.yaml] 67 | ``` 68 | 69 | ### Helm as package manager 70 | 71 | We can use helm as package manager just like yum, apt-get, etc. It can bring the open source charts from internet and install inside kubernetes cluster. 72 | 73 | to add open source repos 74 | 75 | ``` 76 | helm repo add [repo-name] [URL] 77 | ``` 78 | 79 | to search 80 | 81 | ``` 82 | helm search repo [name] 83 | ``` 84 | 85 | --------------------------------------------------------------------------------