To deploy an application to AKS I have to:
- Deploy my application to Azure Container Registry
- Create Azure Kubernetes Service
- Create files: service.yml and deployment.yml
- Connect to AKS using commands:
- Execute commands in the command line:
kubectl apply -f deployment.yml kubectl apply -f service.yml
Is it possible to skip connecting to AKS and executing commands above to simplify the deployment process somehow?
2
Answers
The az aks get-credentials command lets you get the access credentials for an AKS cluster and merges these credentials into the
kubeconfig
file, which can be used to configure access to a cluster without using commands such asaz login
oraz aks get-credentials
.Instead of generating the file every single time you can save the generated/updated
kubeconfig
file into your local machine or for example an Azure Keyvault secret, in case you’re running a pipeline.Please note that the
kubeconfig
file supports multiple clusters, users, and authentication mechanisms. More details about it can be found in Configure Access to Multiple Clusters and in configure access to a cluster. See also Kubeconfig File Explained With Practical Examples.You can use bicep kuberentes provider, which convert your
aks resource
tobicep resources
, and you can deploy the aks workload much like az deployment, you do not need to involve thekubectl command
, it is helpful in automatically scenario.Here is the sample, you need vscode + bicep extension
https://learn.microsoft.com/en-us/azure/aks/learn/quick-kubernetes-deploy-bicep-extensibility-kubernetes-provider?tabs=azure-cli