Managing Kubernetes Resources Using Helm Second Edition by Andrew Block | Austin Dewey

Managing Kubernetes Resources Using Helm Second Edition by Andrew Block | Austin Dewey

Author:Andrew Block | Austin Dewey
Language: eng
Format: epub
Publisher: Packt Publishing Pvt Ltd
Published: 2022-09-09T00:00:00+00:00


There are occasions where portions of a template would need to be included or excluded based on some sort of condition. In this situation, an if/else action can be used. Here is a basic example for conditionally determining whether to include a readiness probe as part of a deployment resource:

{{- if .Values.readinessProbe.enabled }} readinessProbe: httpGet: path: /healthz port: 8080 scheme: HTTP initialDelaySeconds: 30 periodSeconds: 10 {{- end }}

The readinessProbe section will only be included when the condition evaluates to true. However, it is important to note that the condition is actually a pipeline where multiple statements can be chained together to aid in the creation of complex conditionals. The logic behind the if/else action can also be interpreted as follows:

{{ if PIPELINE }} # Do something {{ else if OTHER PIPELINE }} # Do something else {{ else }} # Default case {{ end }}

The conditional statements and their associated if/else action should look familiar to anyone with prior programming experience. But what is the logic behind determining whether a pipeline is true or false?

A pipeline fails to evaluate to true when the following is returned:

A false Boolean

A numeric 0

An empty string

nil (whether it be empty or null)

An empty collection



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.