Azure / azure-cli

Azure Command-Line Interface
MIT License
4.01k stars 2.98k forks source link

Support for replacment of $tokens in yaml files of Visual Studio (Code) like envsubst in Unix #15983

Open V4A001 opened 3 years ago

V4A001 commented 3 years ago

Is your feature request related to a problem? Please describe. I have a file .azcli and that works fine. However, I cannot replace values easily in yaml files I want to load in Kubernetes. envsubst < load-balancer-service.yaml | kubectl apply -f -

Describe the solution you'd like Replacement of values by use of tokens $static_ip

Describe alternatives you've considered Now I enter values in yaml files, but hard to maintain.

Additional context Deploying through azure cli a kubernetes cluster.

yonzhan commented 3 years ago

Could you please share more details about this issue? Which CLI command has problem?

V4A001 commented 3 years ago

It holds for all yaml files in Visual Studio Code. Can be that my knowledge is insufficient. I am not running those yaml-files in a ci/cd devops situation by the way. I believe the cluster is only created once and then through Helm charts the cluster is maintained. Which can be through a ci/cd devops integration. So now I am working locally on Visual Studio code with Azcli to define my cluster with a .azcl file.

I give you an example in which I run azcli in bash mode through the command palette. My k8 cluster needs a static loadbalancer so I define it in a yaml file:

`apiVersion: v1 kind: Service metadata: annotations: service.beta.kubernetes.io/azure-load-balancer-resource-group: myname name: azure-load-balancer spec: loadBalancerIP: xx.xx.xxx type: LoadBalancer ports:

In this file I need to add manually. That works. However, before applying the file to k8 cluster I would like to insert the ip and ip resource group name dynamically.

`apiVersion: v1 kind: Service metadata: annotations: service.beta.kubernetes.io/azure-load-balancer-resource-group: $static_ip_resourcegroup name: azure-load-balancer spec: loadBalancerIP: $static_ip type: LoadBalancer ports:

So I apply: `echo $static_ip_resourcegroup echo $static_ip_name

static_ip=$(az network public-ip show --resource-group $static_ip_resourcegroup --name $static_ip_name --query ipAddress --output tsv) echo $static_ip

kubectl apply -f "load-balancer-service.yaml" kubectl describe service azure-load-balancer`

I would however dynamically add the parameters into the yaml file like that can be done in unix (which I do not have; have Windows machine):

envsubst < load-balancer-service.yaml | kubectl apply -f -

ghost commented 3 years ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Azure/aks-pm.

Issue Details
**Is your feature request related to a problem? Please describe.** I have a file .azcli and that works fine. However, I cannot replace values easily in yaml files I want to load in Kubernetes. envsubst < load-balancer-service.yaml | kubectl apply -f - **Describe the solution you'd like** Replacement of values by use of tokens $static_ip **Describe alternatives you've considered** Now I enter values in yaml files, but hard to maintain. **Additional context** Deploying through azure cli a kubernetes cluster.
Author: V4A001
Assignees: -
Labels: `AKS`, `Service Attention`
Milestone: -