Can I use templating to modify a Helm Deploy actio...
# 🤖|ask-kapa
s
@microscopic-river-74022 Can I use templating to modify a Helm Deploy action
m
Please stand by @swift-island-27000 as I search the knowledge base. I normally take about 15 seconds or so. :wave:
---------------------- Yes, you can use templating to modify a Helm Deploy action in Garden. This can be done by using the
values
field in the action configuration. This field allows you to provide parameters to the Helm chart you're using. The values you provide will create a new YAML and pass it to Helm when rendering/deploying the chart. This is particularly useful when you want to template in the values. Here's an example of how you can use templating in a Helm Deploy action:
Copy code
yaml
kind: Deploy
type: helm
name: helm-deploy
...
spec:
  values:
    some:
      key: some-value
In this example,
some.key
is set to
some-value
. This value will be passed to Helm when rendering/deploying the chart. You can also use conditional objects with
$if
,
$then
, and
$else
keys to conditionally set values. Here's an example:
Copy code
yaml
kind: Deploy
spec:
  command:
    $if: ${this.mode == "sync"}
    $then: [npm, run, watch]
    $else: [npm, start]
In this example,
spec.command
is set to
[npm, run, watch]
when the action is in sync mode, otherwise to
[npm, start]
. For more complex cases, you can use the
jsonEncode
templating function to set non-primitive values like maps and arrays. Sources: - Providing values to the Helm chart () - If/else conditional objects () -
kubernetes
Deploy action type example with shared manifests
() ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
message has been deleted
s
@microscopic-river-74022 what about the name
m
Let me check the knowledge base for you again. One moment! :books:
---------------------- In Garden, the
name
field is used in various contexts and its usage varies depending on the specific configuration key. Here are some examples: 1. For a Helm Deploy action, the
spec.chart.name
field represents a valid Helm chart name or URI. This is the same as you'd input to
helm install
. It's required if the action doesn't contain the Helm chart itself. For example:
Copy code
yaml
    spec:
      ...
      chart:
        ...
        name: "ingress-nginx"
Source () 2. In the general configuration keys for a Helm Deploy action, the
name
field is a valid name for the action. It must be unique across all actions of the same kind in your project. This is a required field. Source () 3. In the
spec.defaultTarget.name
,
spec.sync.overrides**].target.name
,
spec.localMode.target.name
, and
spec.sync.paths[].target.name
fields, the
name
represents the name of the resource, of the specified
kind
. If specified, you must also specify
kind
. This is not a required field. [Source 1** (), Source 2 (), Source 3 (), Source 4 () 4. In the
spec.portForwards**].name
field, the
name
is an identifier to describe the port forward. This is not a required field. [Source** ()
5. In the template context
${actions.deploy.<action-name>.name}
, the
name
represents the name of the action. Source () 6. In the Kubernetes Deploy action, the
spec.manifests**].metadata.name
field represents the name of the resource. This is a required field. [Source** () 7. In the Helm-pod Test action, the
spec.chart.name
field represents a valid Helm chart name or URI. This is the same as you'd input to
helm install
. It's required if the action doesn't contain the Helm chart itself. For example:
Copy code
yaml
    spec:
      ...
      chart:
        ...
        name: "ingress-nginx"
Source () Please refer to the specific context in the Garden documentation for more details on how to use the
name
field. ---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------
message has been deleted