-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathGetting Started with Microsoft AKS AzPowershell.ps1
38 lines (26 loc) · 1.46 KB
/
Getting Started with Microsoft AKS AzPowershell.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#Local Az PowerShell creating AKS cluster
$ResourceGroupName = "CadeAKS"
$ClusterName = "CadeAKSCluster"
$ClusterLocation = "eastus"
$NodeCount = "3"
#Web Browser will open to authenticate against your subscription
Connect-AzAccount
#Create a New resource group
New-AzResourceGroup -Name $ResourceGroupName -Location $ClusterLocation
#Create the AKS cluster, GenerateSshKey is used here to authenticate to the cluster from the local machine.
New-AzAksCluster -ResourceGroupName $ResourceGroupName -Name $ClusterName -NodeCount $NodeCount -GenerateSshKey -KubernetesVersion 1.19.7
New-AzAksCluster -ResourceGroupName $ResourceGroupName -Name $ClusterName -NodeCount $NodeCount -SshKeyValue 'C:\\Users\micha\\.ssh\\id_rsa'
#This will install Kubectl but i am not sure if this is needed if you already have kubectl on your system will have to test that.
Install-AzAksKubectl
#Now we need to add our AKS context so we can connect
Import-AzAksCredential -ResourceGroupName $ResourceGroupName -Name $ClusterName -Force
#Confirm that you have access to your cluster
kubectl get nodes
#If you have multiple contexts and you want to list them
kubectl config get-contexts
#change name below to the context you wish to jump to
kubectl config use-context NAME
kubectl create namespace kasten-io
#To Delete your cluster run the following command
Remove-AzResourceGroup -Name $ResourceGroupName -force
Remove-Item C:\Users\micha\.ssh\id_rsa