Skip to content

Commit 495bbb8

Browse files
committedAug 17, 2023
Create aks.ps1
1 parent c12fa49 commit 495bbb8

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed
 

‎AKS/aks.ps1

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
Set-Location ~/desktop/AKS
2+
#choco upgrade kubernetes-cli -y
3+
#az bicep upgrade
4+
Clear-Host
5+
# Parameters
6+
$RG="AKSRG"
7+
$Region="eastus"
8+
$ClusterName=""
9+
$tenant=""
10+
$winpw=""
11+
12+
# Login and create RG
13+
az login --tenant $Tenant
14+
az account set -s "Azure Data Demos"
15+
az group create -l $Region -n $RG
16+
17+
# Azure CLI - I ran this before
18+
az aks create -g $RG -n $ClusterName --generate-ssh-keys `
19+
--network-plugin azure `
20+
--windows-admin-username azure --windows-admin-password $winpw
21+
22+
# Add a Windows Node
23+
az aks nodepool add --resource-group $RG --cluster-name $ClusterName `
24+
--os-type Windows --name npwind --node-count 1
25+
26+
#az aks create -g $RG -n AKS-AZCLI-SMALL --node-count 2
27+
28+
#az aks create --generate-ssh-keys -g $RG -n AKS-AZCLI-LARGE `
29+
# --node-count 4 --node-vm-size Standard_d16_v4
30+
31+
az aks list -o table
32+
33+
# And look in Portal
34+
Start-Process https://portal.azure.com/#view/HubsExtension/BrowseResource/resourceType/Microsoft.ContainerService%2FmanagedClusters
35+
36+
# PowerShell and az module
37+
# Connect-AzAccount -Subscription (az account show --query id -o tsv) -Tenant $tenant
38+
39+
Get-AzAksVersion -Location $Region | Select-Object OrchestratorVersion
40+
41+
#New-AzAksCluster -ResourceGroupName $RG `
42+
# -Name AKS-PS `
43+
# -NodeCount 4 `
44+
# -NodeVmSize Standard_d16_v4 `
45+
# -KubernetesVersion 1.26.6
46+
47+
Get-AzAksCluster -ResourceGroupName $RG | Select-Object Name
48+
49+
# ARM Templates
50+
code aks-arm.json
51+
52+
az bicep decompile --file aks-arm.json --force
53+
code aks-arm.bicep
54+
55+
#az Deployment group create -f aks-arm.bicep `
56+
# -g $RG `
57+
# --parameters sshRSAPublicKey=$SSH clusterName=AKS-ARM-BICEP agentCount=1
58+
59+
# Communicating with our cluster
60+
az aks get-credentials -g $RG -n $ClusterName
61+
62+
kubectl cluster-info
63+
kubectl get nodes -o wide
64+
65+
kubectl create deployment nginx --image=nginx
66+
67+
code nginx.yaml
68+
kubectl apply -f nginx.yaml
69+
70+
kubectl get service nginx -w
71+
$SERVICEIP=(kubectl get service nginx -o jsonpath='{ .status.loadBalancer.ingress[0].ip }')
72+
kubectl get pods
73+
Start-Process http://$SERVICEIP
74+
75+
code windows-app.yaml
76+
kubectl apply -f windows-app.yaml
77+
78+
kubectl get pods -o wide
79+
80+
# Move imperative nginx to linux node:
81+
# nodeSelector:
82+
# "kubernetes.io/os": linux
83+
kubectl edit deployment nginx
84+
85+
kubectl get pods -o wide -w
86+
87+
kubectl describe pod -l app=sample
88+
89+
# az group delete --resource-group $RG --yes

0 commit comments

Comments
 (0)
Please sign in to comment.