├── README.md ├── solution └── webapp1 │ ├── .helmignore │ ├── Chart.yaml │ ├── templates │ ├── NOTES.txt │ ├── configmap.yaml │ ├── deployment.yaml │ └── service.yaml │ ├── values-dev.yaml │ ├── values-prod.yaml │ └── values.yaml └── templates-original ├── configmap.yaml ├── deployment.yaml └── service.yaml /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Create the helmchart 3 | ``` 4 | helm create webapp1 5 | ``` 6 | 7 | 8 | # Follow along with the video 9 | - Create the files per the video, copying and pasting from templates-original 10 | - you can also use the files in the solution folder 11 | 12 | # Install the first one 13 | ``` 14 | helm install mywebapp-release webapp1/ --values webapp1/values.yaml 15 | ``` 16 | 17 | # Upgrade after templating 18 | ``` 19 | helm upgrade mywebapp-release webapp1/ --values mywebapp/values.yaml 20 | ``` 21 | 22 | # Accessing it 23 | ``` 24 | minikube tunnel 25 | ``` 26 | 27 | # Create dev/prod 28 | ``` 29 | k create namespace dev 30 | k create namespace prod 31 | helm install mywebapp-release-dev webapp1/ --values webapp1/values.yaml -f webapp1/values-dev.yaml -n dev 32 | helm install mywebapp-release-prod webapp1/ --values webapp1/values.yaml -f webapp1/values-prod.yaml -n prod 33 | helm ls --all-namespaces 34 | ``` 35 | -------------------------------------------------------------------------------- /solution/webapp1/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *.orig 18 | *~ 19 | # Various IDEs 20 | .project 21 | .idea/ 22 | *.tmproj 23 | .vscode/ 24 | -------------------------------------------------------------------------------- /solution/webapp1/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | name: webapp 3 | description: A Helm chart for Kubernetes 4 | 5 | # A chart can be either an 'application' or a 'library' chart. 6 | # 7 | # Application charts are a collection of templates that can be packaged into versioned archives 8 | # to be deployed. 9 | # 10 | # Library charts provide useful utilities or functions for the chart developer. They're included as 11 | # a dependency of application charts to inject those utilities and functions into the rendering 12 | # pipeline. Library charts do not define any templates and therefore cannot be deployed. 13 | type: application 14 | 15 | # This is the chart version. This version number should be incremented each time you make changes 16 | # to the chart and its templates, including the app version. 17 | # Versions are expected to follow Semantic Versioning (https://semver.org/) 18 | version: 0.1.0 19 | 20 | # This is the version number of the application being deployed. This version number should be 21 | # incremented each time you make changes to the application. Versions are not expected to 22 | # follow Semantic Versioning. They should reflect the version the application is using. 23 | # It is recommended to use it with quotes. 24 | appVersion: "1.16.0" 25 | -------------------------------------------------------------------------------- /solution/webapp1/templates/NOTES.txt: -------------------------------------------------------------------------------- 1 | servicename=$(k get service -l "app={{ .Values.appName }}" -o jsonpath="{.items[0].metadata.name}") 2 | kubectl --namespace {{ .Values.namespace}} port-forward service/{{ .Values.appName }} 8888:80 -------------------------------------------------------------------------------- /solution/webapp1/templates/configmap.yaml: -------------------------------------------------------------------------------- 1 | kind: ConfigMap 2 | apiVersion: v1 3 | metadata: 4 | name: {{ .Values.configmap.name }} 5 | namespace: {{ .Values.namespace }} 6 | data: 7 | BG_COLOR: '#12181b' 8 | FONT_COLOR: '#FFFFFF' 9 | CUSTOM_HEADER: {{ .Values.configmap.data.CUSTOM_HEADER }} -------------------------------------------------------------------------------- /solution/webapp1/templates/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: {{ .Values.appName }} 5 | namespace: {{ .Values.namespace }} 6 | labels: 7 | app: {{ .Values.appName }} 8 | spec: 9 | replicas: 5 10 | selector: 11 | matchLabels: 12 | app: {{ .Values.appName }} 13 | tier: frontend 14 | template: 15 | metadata: 16 | labels: 17 | app: {{ .Values.appName }} 18 | tier: frontend 19 | spec: # Pod spec 20 | containers: 21 | - name: mycontainer 22 | image: "{{ .Values.image.name }}:{{ .Values.image.tag }}" 23 | ports: 24 | - containerPort: 80 25 | envFrom: 26 | - configMapRef: 27 | name: {{ .Values.configmap.name }} 28 | resources: 29 | requests: 30 | memory: "16Mi" 31 | cpu: "50m" # 50 milli cores (1/20 CPU) 32 | limits: 33 | memory: "128Mi" # 128 mebibytes 34 | cpu: "100m" 35 | -------------------------------------------------------------------------------- /solution/webapp1/templates/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ .Values.appName }} 5 | namespace: {{ .Values.namespace }} 6 | labels: 7 | app: {{ .Values.appName }} 8 | spec: 9 | ports: 10 | - port: 80 11 | protocol: TCP 12 | name: flask 13 | selector: 14 | app: {{ .Values.appName }} 15 | tier: frontend 16 | type: LoadBalancer -------------------------------------------------------------------------------- /solution/webapp1/values-dev.yaml: -------------------------------------------------------------------------------- 1 | namespace: dev 2 | 3 | configmap: 4 | data: 5 | CUSTOM_HEADER: 'This is on the DEV environment!' 6 | -------------------------------------------------------------------------------- /solution/webapp1/values-prod.yaml: -------------------------------------------------------------------------------- 1 | namespace: prod 2 | 3 | configmap: 4 | data: 5 | CUSTOM_HEADER: 'This is on the PROD environment!' 6 | -------------------------------------------------------------------------------- /solution/webapp1/values.yaml: -------------------------------------------------------------------------------- 1 | 2 | 3 | appName: myhelmapp 4 | 5 | port: 80 6 | 7 | namespace: default 8 | 9 | configmap: 10 | name: myhelmapp-configmap-v1 11 | data: 12 | CUSTOM_HEADER: 'This app was deployed with helm!' 13 | 14 | image: 15 | name: devopsjourney1/mywebapp 16 | tag: latest -------------------------------------------------------------------------------- /templates-original/configmap.yaml: -------------------------------------------------------------------------------- 1 | kind: ConfigMap 2 | apiVersion: v1 3 | metadata: 4 | name: myconfigmapv1.0 5 | namespace: default 6 | data: 7 | BG_COLOR: '#12181b' 8 | FONT_COLOR: '#FFFFFF' 9 | CUSTOM_HEADER: 'Customized with a configmap!' -------------------------------------------------------------------------------- /templates-original/deployment.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: mydeployment 5 | namespace: default 6 | labels: 7 | app: mywebapp 8 | spec: 9 | replicas: 5 10 | selector: 11 | matchLabels: 12 | app: mywebapp 13 | tier: frontend 14 | template: 15 | metadata: 16 | labels: 17 | app: mywebapp 18 | tier: frontend 19 | spec: # Pod spec 20 | containers: 21 | - name: mycontainer 22 | image: devopsjourney1/mywebapp:latest 23 | ports: 24 | - containerPort: 80 25 | envFrom: 26 | - configMapRef: 27 | name: myconfigmapv1.0 28 | resources: 29 | requests: 30 | memory: "16Mi" 31 | cpu: "50m" # 50 milli cores (1/20 CPU) 32 | limits: 33 | memory: "128Mi" # 128 mebibytes 34 | cpu: "100m" 35 | -------------------------------------------------------------------------------- /templates-original/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: mywebapp 5 | namespace: default 6 | labels: 7 | app: mywebapp 8 | spec: 9 | ports: 10 | - port: 80 11 | protocol: TCP 12 | name: flask 13 | selector: 14 | app: mywebapp 15 | tier: frontend 16 | type: NodePort --------------------------------------------------------------------------------