Ingredient for deploying Kubernetes configs
npm install @azbake/ingredient-kubernetessource of the ingredient (see Limitations). Serve-time token replacement inside the configurations is supported.
source field will specify the Kubernetes configuration. This field accepts a path to a file, a url to a file or a path to a directory that contains multiple Kubernetes configuration files.
kubeconfig. Since this varies by environment, there's no point in hardcoding the actual value there. To solve this, the value of the kubeconfig parameter is typically an expression which calls coreutils.variable() to get the value of a Bake Variable.
current-context field in the kubeconfig file must be set, as this is what's used in the non-interactive serving of the ingredient. There is therefore no benefit to including more than one context (or cluster or user or namespace) in a kubeconfig. If you want to deploy to multiple namespaces, the easiest way to do so is with multiple kubeconfigs and therefore either multiple ingredients calling coreutils.variable() for different variables, or multiple calls to Bake Serve from ADO.
delayms` parameter is available to introduce a delay between deployments of ingredients.
Additionally, certain transient error conditions or errors received when post-deployment startup routines aren't complete before dependent K8s resources are deployed can be handled through the use of a `retryErrors` parameter.
$3
This happens on-disk. This means it is ineffective against URL-specified configurations. It also means that it can only happen once during a serve. The original, non-token replaced versions of the files are not kept. The easiest way to use different values for a token in different scenarios is to make multiple calls to Bake Serve from ADO. This will ensure the container serving the recipe is destroyed and started anew for each set of token values.
Example Recipe
~~~yaml
name: My Package
shortName: mpkg
version: "0.0.1"
resourceGroup: false
variables:
someToken: I will lose out to the below value of 'someToken'
ingredients:
- "@azbake/ingredient-kubernetes@~0"
recipe:
k8s:
properties:
type: "@azbake/ingredient-kubernetes"
source: subdir
tokens:
someToken: I take precedence over the above value of 'someToken'
someOtherToken: some value
parameters:
kubeconfig : ["coreutils.variable('b64KubeConfigContent')"]
testDeployment: true #set this to true and after the source has been applied, it will get deleted (good for deployment testing)
deleteDeployment: false # not required, and if set to true it will execute a kubectl delete instead of a kubectl apply on the subdir (ignoring anything not found)
kubectlFlags: "--server-side --force-conflicts" # optionally specify additional flags for kubectl command
delayms: 10000 # not required, and if set then it will delay for the specified number of milliseconds after deploying the ingredient
retryErrors: true # not required, and if set will retry errors with expoential backoff (10s, 30s, 70s) before failing. Defaults to false if not set.
~~~
Limitations
* Token replacement will not happen against URLs specified as the source of the ingredient.
Testing
If you just want to deploy and then delete some resources for testing, provide a value of true for the testDeployment` parameter of the ingredient.