diff --git a/05-create-helm-charts/07-flow-control/iechart1/Chart.yaml b/05-create-helm-charts/07-flow-control/iechart1/Chart.yaml new file mode 100644 index 0000000..8f9ad58 --- /dev/null +++ b/05-create-helm-charts/07-flow-control/iechart1/Chart.yaml @@ -0,0 +1,8 @@ +# place the below content inside the Chart.yaml +apiVersion: v2 +type: application +name: iec1 +version: "0.1.0" # recomended to follow version as "MAJOR-Version.MINOR-Version.PATCH-Version" always +description: "A Helm chart to deploy all required kubernetes resources" +appVersion: "1.0.0" # your application version / release version +# save the file with the above data diff --git a/05-create-helm-charts/07-flow-control/iechart1/templates/deployment.yaml b/05-create-helm-charts/07-flow-control/iechart1/templates/deployment.yaml new file mode 100644 index 0000000..3d25ca5 --- /dev/null +++ b/05-create-helm-charts/07-flow-control/iechart1/templates/deployment.yaml @@ -0,0 +1,25 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-app +spec: +{{- if eq .Values.iecapp.env "prod" }} + replicas: 4 +{{- else if eq .Values.iecapp.env "qa" }} + replicas: 2 +{{- else }} + replicas: 1 +{{- end }} + selector: + matchLabels: + app: iec + template: + metadata: + labels: + app: iec + spec: + containers: + - name: sampleapp + image: {{ .Values.image.repo }}:{{ .Values.image.tag }} + ports: + - containerPort: 8080 diff --git a/05-create-helm-charts/07-flow-control/iechart1/values.yaml b/05-create-helm-charts/07-flow-control/iechart1/values.yaml new file mode 100644 index 0000000..7ce71fc --- /dev/null +++ b/05-create-helm-charts/07-flow-control/iechart1/values.yaml @@ -0,0 +1,5 @@ +iecapp: + env: qa +image: + repo: docker.io/lerndevops/samples + tag: pyapp-v2 diff --git a/05-create-helm-charts/07-flow-control/if-else.md b/05-create-helm-charts/07-flow-control/if-else.md index b7d5aec..0b8a8f9 100644 --- a/05-create-helm-charts/07-flow-control/if-else.md +++ b/05-create-helm-charts/07-flow-control/if-else.md @@ -7,4 +7,32 @@ {{ else }} # Default case {{ end }} -``` \ No newline at end of file +``` + +#### examin the ntchart1 from [github repo](https://github.com/lerndevops/helm-charts/tree/main/05-create-helm-charts/06-named-templates/ntchart1) + +```sh +# get the chart to local +cd $HOME ; git clone https://github.com/lerndevops/helm-charts +cd $HOME/helm-charts/05-create-helm-charts/07-flow-control/iechart1 +cat templates/deployment.yaml +``` +```yaml +{{/* define template for common Labels */}} +{{- define "nt.labels"}} + app: sapp +{{- end }} + +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ .Release.Name }}-app + labels: + {{- template "nt.labels" }} +``` +```sh +# dry run the chart and observe the output rendered properly + +cd $HOME/helm-charts/05-create-helm-charts/06-named-templates/ntchart1 +helm install ntchart1-rel . --dry-run +```