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 0b8a8f9..8f027ca 100644 --- a/05-create-helm-charts/07-flow-control/if-else.md +++ b/05-create-helm-charts/07-flow-control/if-else.md @@ -8,31 +8,59 @@ # Default case {{ end }} ``` - -#### examin the ntchart1 from [github repo](https://github.com/lerndevops/helm-charts/tree/main/05-create-helm-charts/06-named-templates/ntchart1) +## logic flow control functions +* [Logic and Flow Control Functions](https://helm.sh/docs/chart_template_guide/function_list/#logic-and-flow-control-functions) +* Helm includes numerous logic and control flow functions including and, coalesce, default, empty, eq, fail, ge, gt, le, lt, ne, not, and or. +--- +## if-else eq +#### examin the iechart1 from [github repo](iechart1/) ```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 +cat values.yaml # observe the values +cat templates/deployment.yaml # observe if else condition used for replicas ``` ```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 +cd $HOME/helm-charts/05-create-helm-charts/07-flow-control/iechart1 +helm install iec1-rel . --dry-run +``` +```yaml +# output as below + +NAME: iec1-rel +LAST DEPLOYED: Tue Oct 10 20:14:17 2023 +NAMESPACE: default +STATUS: pending-install +REVISION: 1 +TEST SUITE: None +HOOKS: +MANIFEST: +--- +# Source: iec1/templates/deployment.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: iec1-rel-app +spec: + replicas: 2 + selector: + matchLabels: + app: iec + template: + metadata: + labels: + app: iec + spec: + containers: + - name: sampleapp + image: docker.io/lerndevops/samples:pyapp-v2 + ports: + - containerPort: 8080 ``` +--- \ No newline at end of file