-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AKS Service Target: Adds optional support for text templating in k8s manifests #2455
Conversation
I think we are going to need to come up with something here sooner rather than later. Looking at your test, it feels like a even if the substitution had succeeded, the resulting k8s manifest that we would apply would be "wrong" according to the user, since we'd end up corrupting the scripts that are stored in the config-map (by evaluating their environment references before sending the data to the API Server). I wonder how disruptive making this behavior opt-in would be. I think long term we might want to support something like using |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash:
pwsh:
WindowsPowerShell install
MSI install
Standalone Binary
MSIContainer
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
Background Our initial AKS implementation created an azd resource in the target k8s namespace with all the azd environment key/value pairs. These values could then be easily referenced by other resources. With the change in templating in #2455 the new recommended approach would be for apps to create their own config maps as needed and reference azd secrets via templating. This brings azd to a more cloud native state where we aren't creating any resources that haven't been explicitly defined. If users still wanted a config map that contains all azd resources the templating system allows ranging over maps which can be used to achieve the same goal. Breaking Change If users were relying on this automatic secret generation then this would be considered a breaking change for them and users will now need to manually create any config maps that their apps/services need.
Resolves #2367
This addresses an issue where a configmap or other k8s resource can contain script files that fails parsing by the
envsubst
library.The specific issue that failed in this example was the
envsubst
attempting to replace${BASH_REMATCH[1]}
in a config map. This is likely a bug in the library since it was throwing anMissingClosingBrace
error.Background
k8s manifests DO NOT support any default templating language out of the box. To support environment variables you would read directly from a configmap / secret to reference those values.
Helm is a very popular package manager for k8s and supports a robust templating language. The templating language uses Go text templating language as its foundation with some additional features built on top.
Kustomize is another very popular way to provide customization on top of k8s manifests without templates.
It previously supported a vars feature that has now been deprecated and replaced by replacements.
Breaking Change
This commit would be considered a breaking change for AKS support. Prior to this update simple environment substitution was being performed on all
*.yaml
manifest files.Blind replacement of any bash style variable could have unintended consequences and cause runtime error when variables are not available within azd environment.
Now, devs must opt-in by renaming there manifests to
*.tmpl.yaml
and have access to Go text templating within their manifests.This feature would be considered an incremental journey towards a fully featured templating & packaging system like Helm since the syntax is the same. The templating syntax used here is the same as used in Helm)
In addition to the opt-in text templates k8s devs still have the ability to directly pull values from config maps / secrets as needed.
The template root node has the following shape:
This also requires changes to the Todo AKS template available @ #2460