Skip to content

Automation script Section addition #73

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions auto-lab.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@
NAME="n4a-auto-lab.sh"
VERSION="1"
LOG_FILE="n4a-autolab.log" # not used yet, but will be soon
export LOCATION=centralus # can be changed to your location
export MY_LOCATION=centralus # can be changed to your location

# On OS X, you can pull your username. You can also set it yourself for use in the script:
# export OWNER=<your name>
export OWNER=$(whoami)
export MY_NAME=$(whoami)

#-------------------------------------------------------------------------
# Sourced files
Expand Down
22 changes: 11 additions & 11 deletions functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,19 @@ padding $LGTH
# Removing this lock at the start makes things run smoother.
# If you changed the username for Owner you may need to edit this path.

rm -rf /Users/${OWNER}/.kube/config.lock
rm -rf /Users/${MY_NAME}/.kube/config.lock
# Workaround on OS X for permissions for kubectl
export KUBECONFIG="~/.kube/config"

# Set some system variables for use in the script.
# you should be logged into azure cli before running this script

export MY_RESOURCEGROUP=${OWNER}-n4a-workshop
export MY_RESOURCEGROUP=${MY_NAME}-n4a-workshop
export MY_AZURE_PUBLIC_IP_NAME=n4a-publicIP # we chose this to standardize names for the workshop
export MY_PUBLICIP=$(curl -s ipinfo.io/ip)
export MY_SUBSCRIPTIONID=$(az account show --query id -o tsv)

if [[ -z "$OWNER" || -z "$MY_RESOURCEGROUP" || -z "$MY_PUBLICIP" || -z "$MY_SUBSCRIPTIONID" ]]; then
if [[ -z "$MY_NAME" || -z "$MY_RESOURCEGROUP" || -z "$MY_PUBLICIP" || -z "$MY_SUBSCRIPTIONID" ]]; then
cfail
exit 1
else
Expand All @@ -88,9 +88,9 @@ fi
YELLOW='\033[01;33m'
ENDCOLOR='\033[00;00m'

echo -e "\t${YELLOW}OWNER:${ENDCOLOR} $OWNER"
echo -e "\t${YELLOW}MY_NAME:${ENDCOLOR} $MY_NAME"
echo -e "\t${YELLOW}MY_RESOURCEGROUP:${ENDCOLOR} $MY_RESOURCEGROUP"
echo -e "\t${YELLOW}LOCATION:${ENDCOLOR} $LOCATION"
echo -e "\t${YELLOW}MY_LOCATION:${ENDCOLOR} $MY_LOCATION"
echo -e "\t${YELLOW}MY_PUBLICIP:${ENDCOLOR} $MY_PUBLICIP"
echo -e "\t${YELLOW}MY_SUBSCRIPTIONID:${ENDCOLOR} $MY_SUBSCRIPTIONID"

Expand All @@ -117,7 +117,7 @@ LGTH=${#MESSAGE}
echo -ne $MESSAGE
padding $LGTH

CREATE_RESOURCE_GROUP=`az group create --name $MY_RESOURCEGROUP --location $LOCATION --tags owner="$OWNER"`
CREATE_RESOURCE_GROUP=`az group create --name $MY_RESOURCEGROUP --location $MY_LOCATION --tags owner="$MY_NAME"`

if [[ -z "$CREATE_RESOURCE_GROUP" ]]; then
cfail
Expand Down Expand Up @@ -210,7 +210,7 @@ LGTH=${#MESSAGE}
echo -ne $MESSAGE
padding $LGTH

CREATE_PUBLIC_IP=`az network public-ip create --name $MY_AZURE_PUBLIC_IP_NAME --resource-group $MY_RESOURCEGROUP --allocation-method Static --sku Standard --location $LOCATION --tags owner="$OWNER" --zone 1`
CREATE_PUBLIC_IP=`az network public-ip create --name $MY_AZURE_PUBLIC_IP_NAME --resource-group $MY_RESOURCEGROUP --allocation-method Static --sku Standard --location $MY_LOCATION --tags owner="$MY_NAME" --zone 1`

export MY_AZURE_PUBLIC_IP=$(az network public-ip show --resource-group $MY_RESOURCEGROUP --name $MY_AZURE_PUBLIC_IP_NAME --query ipAddress --output tsv)

Expand Down Expand Up @@ -400,7 +400,7 @@ function create_aks_cluster1(){
# Set some variables to use with this part of the lab setup
export MY_AKS1=n4a-aks1
export MY_AKS2=n4a-aks2
export MY_NAME=${OWNER:-$(whoami)}
export MY_NAME=${MY_NAME:-$(whoami)}
export K8S_VERSION=1.29
export MY_SUBNET1=$(az network vnet subnet show -g $MY_RESOURCEGROUP -n aks1-subnet --vnet-name n4a-vnet --only-show-errors --query id -o tsv)
export MY_SUBNET2=$(az network vnet subnet show -g $MY_RESOURCEGROUP -n aks2-subnet --vnet-name n4a-vnet --only-show-errors --query id -o tsv)
Expand Down Expand Up @@ -710,7 +710,7 @@ kubectl describe gc nginx-configuration -n nginx-ingress > /dev/null 2>&1 &
kubectl apply -f labs/lab4/redis-leader-ts.yaml > /dev/null 2>&1 &
kubectl apply -f labs/lab4/redis-follower-ts.yaml > /dev/null 2>&1 &
kubectl apply -f labs/lab4/nodeport-static-redis.yaml > /dev/null 2>&1 &
rm -rf /Users/${OWNER}/.kube/config.lock
rm -rf /Users/${MY_NAME}/.kube/config.lock

echo -ne $MESSAGE
padding $LGTH
Expand Down Expand Up @@ -817,9 +817,9 @@ export MY_N4A_ID=$MY_N4A_ID
export MY_LOG_ANALYTICS_ID=$MY_LOG_ANALYTICS_ID
export AKS1_NIC=$AKS1_NIC
export AKS2_NIC=$AKS2_NIC
export OWNER=$OWNER
export MY_NAME=$MY_NAME
export MY_RESOURCEGROUP=$MY_RESOURCEGROUP
export LOCATION=$LOCATION
export MY_LOCATION=$MY_LOCATION
export MY_PUBLICIP=$MY_PUBLICIP
export MY_SUBSCRIPTIONID=$MY_SUBSCRIPTIONID
export MY_AZURE_PUBLIC_IP=$MY_AZURE_PUBLIC_IP
Expand Down
73 changes: 38 additions & 35 deletions labs/lab1/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ By the end of the lab you will be able to:
az extension add --name nginx
```

1. Create a new Azure Resource Group called `<name>-workshop` , where `<name>` is your last name (or any unique value). This would hold all the Azure resources that you would create for this workshop.
1. Create a new Azure Resource Group called `<name>-n4a-workshop` , where `<name>` is your last name (or any unique value). This would hold all the Azure resources that you would create for this workshop.

Check out the available [Datacenter regions](https://azure.microsoft.com/en-us/explore/global-infrastructure/geographies/#geographies) and decide on a region that is closest to you and meets your needs.

Expand All @@ -64,10 +64,13 @@ By the end of the lab you will be able to:
I am located in Chicago, Illinois so I will opt to use `Central US` as my Azure location.

```bash
az group create --name <name>-workshop --location <MY_Location>
az group create --name <name>-n4a-workshop --location <My_Location>

## example
az group create --name s.dutta-workshop --location centralus
export MY_NAME=$(whoami)
export MY_LOCATION=centralus

az group create --name ${MY_NAME}-n4a-workshop --location ${MY_LOCATION}
```

1. Make sure the new Azure Resource Group has been created by running below command.
Expand Down Expand Up @@ -97,7 +100,7 @@ aks2-subnet | 172.16.20.0/23 | AKS Cluster #2

```bash
## Set environment variables
export MY_RESOURCEGROUP=s.dutta-workshop
export MY_RESOURCEGROUP=${MY_NAME}-n4a-workshop
export MY_PUBLICIP=$(curl ipinfo.io/ip)
```

Expand All @@ -119,11 +122,11 @@ aks2-subnet | 172.16.20.0/23 | AKS Cluster #2
},
"enableDdosProtection": false,
"etag": "W/\"be1dfac2-9879-4a22-abe4-717badebb0ec\"",
"id": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/s.dutta-workshop/providers/Microsoft.Network/virtualNetworks/n4a-vnet",
"id": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/sh.dutta-n4a-workshop/providers/Microsoft.Network/virtualNetworks/n4a-vnet",
"location": "centralus",
"name": "n4a-vnet",
"provisioningState": "Succeeded",
"resourceGroup": "s.dutta-workshop",
"resourceGroup": "sh.dutta-n4a-workshop",
"resourceGuid": "xxxx-xxxx-xxxx-xxxx-xxxx",
"subnets": [],
"type": "Microsoft.Network/virtualNetworks",
Expand Down Expand Up @@ -193,12 +196,12 @@ aks2-subnet | 172.16.20.0/23 | AKS Cluster #2
"destinationPortRanges": [],
"direction": "Inbound",
"etag": "W/\"7a178961-d3b8-4562-8493-4fcd7752e37b\"",
"id": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/s.dutta-workshop/providers/Microsoft.Network/networkSecurityGroups/n4a-nsg/securityRules/HTTP",
"id": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/sh.dutta-n4a-workshop/providers/Microsoft.Network/networkSecurityGroups/n4a-nsg/securityRules/HTTP",
"name": "HTTP",
"priority": 320,
"protocol": "Tcp",
"provisioningState": "Succeeded",
"resourceGroup": "s.dutta-workshop",
"resourceGroup": "sh.dutta-n4a-workshop",
"sourceAddressPrefix": "<MY_PUBLICIP>",
"sourceAddressPrefixes": [],
"sourcePortRange": "*",
Expand All @@ -216,12 +219,12 @@ aks2-subnet | 172.16.20.0/23 | AKS Cluster #2
"destinationPortRanges": [],
"direction": "Inbound",
"etag": "W/\"dc717c9f-3790-45ba-b7aa-e5e39c11142d\"",
"id": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/s.dutta-workshop/providers/Microsoft.Network/networkSecurityGroups/n4a-nsg/securityRules/HTTPS",
"id": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/sh.dutta-n4a-workshop/providers/Microsoft.Network/networkSecurityGroups/n4a-nsg/securityRules/HTTPS",
"name": "HTTPS",
"priority": 300,
"protocol": "Tcp",
"provisioningState": "Succeeded",
"resourceGroup": "s.dutta-workshop",
"resourceGroup": "sh.dutta-n4a-workshop",
"sourceAddressPrefix": "<MY_PUBLICIP>",
"sourceAddressPrefixes": [],
"sourcePortRange": "*",
Expand Down Expand Up @@ -254,25 +257,25 @@ aks2-subnet | 172.16.20.0/23 | AKS Cluster #2
"Microsoft.Network/virtualNetworks/subnets/join/action"
],
"etag": "W/\"a615708f-145c-4568-a7b1-29b262f04065\"",
"id": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/s.dutta-workshop/providers/Microsoft.Network/virtualNetworks/n4a-vnet/subnets/n4a-subnet/delegations/0",
"id": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/sh.dutta-n4a-workshop/providers/Microsoft.Network/virtualNetworks/n4a-vnet/subnets/n4a-subnet/delegations/0",
"name": "0",
"provisioningState": "Succeeded",
"resourceGroup": "s.dutta-workshop",
"resourceGroup": "sh.dutta-n4a-workshop",
"serviceName": "NGINX.NGINXPLUS/nginxDeployments",
"type": "Microsoft.Network/virtualNetworks/subnets/delegations"
}
],
"etag": "W/\"a615708f-145c-4568-a7b1-29b262f04065\"",
"id": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/s.dutta-workshop/providers/Microsoft.Network/virtualNetworks/n4a-vnet/subnets/n4a-subnet",
"id": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/sh.dutta-n4a-workshop/providers/Microsoft.Network/virtualNetworks/n4a-vnet/subnets/n4a-subnet",
"name": "n4a-subnet",
"networkSecurityGroup": {
"id": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/s.dutta-workshop/providers/Microsoft.Network/networkSecurityGroups/n4a-nsg",
"resourceGroup": "s.dutta-workshop"
"id": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/sh.dutta-n4a-workshop/providers/Microsoft.Network/networkSecurityGroups/n4a-nsg",
"resourceGroup": "sh.dutta-n4a-workshop"
},
"privateEndpointNetworkPolicies": "Disabled",
"privateLinkServiceNetworkPolicies": "Enabled",
"provisioningState": "Succeeded",
"resourceGroup": "s.dutta-workshop",
"resourceGroup": "sh.dutta-n4a-workshop",
"type": "Microsoft.Network/virtualNetworks/subnets"
}
```
Expand Down Expand Up @@ -334,7 +337,7 @@ Your completed Vnet/Subnets should look similar to this:
"protectionMode": "VirtualNetworkInherited"
},
"etag": "W/\"cbeb62f5-3ecc-404f-919d-bdea24c7b9f3\"",
"id": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/s.dutta-workshop/providers/Microsoft.Network/publicIPAddresses/n4a-publicIP",
"id": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/sh.dutta-n4a-workshop/providers/Microsoft.Network/publicIPAddresses/n4a-publicIP",
"idleTimeoutInMinutes": 4,
"ipAddress": "<AZURE_ASSIGNED_PUBLICIP>",
"ipTags": [],
Expand All @@ -343,7 +346,7 @@ Your completed Vnet/Subnets should look similar to this:
"provisioningState": "Succeeded",
"publicIPAddressVersion": "IPv4",
"publicIPAllocationMethod": "Static",
"resourceGroup": "s.dutta-workshop",
"resourceGroup": "sh.dutta-n4a-workshop",
"resourceGuid": "xxxx-xxxx-xxxx-xxxx-xxxx",
"sku": {
"name": "Standard",
Expand All @@ -368,11 +371,11 @@ Your completed Vnet/Subnets should look similar to this:
##Sample Output##
{
"clientId": "xxxx-xxxx-xxxx-xxxx-xxxx",
"id": "/subscriptions/<SUBSCRIPTION_ID>/resourcegroups/s.dutta-workshop/providers/Microsoft.ManagedIdentity/userAssignedIdentities/n4a-useridentity",
"id": "/subscriptions/<SUBSCRIPTION_ID>/resourcegroups/sh.dutta-n4a-workshop/providers/Microsoft.ManagedIdentity/userAssignedIdentities/n4a-useridentity",
"location": "centralus",
"name": "n4a-useridentity",
"principalId": "xxxx-xxxx-xxxx-xxxx-xxxx",
"resourceGroup": "s.dutta-workshop",
"resourceGroup": "sh.dutta-n4a-workshop",
"systemData": null,
"tags": {},
"tenantId": "xxxx-xxxx-xxxx-xxxx-xxxx",
Expand All @@ -390,7 +393,7 @@ Your completed Vnet/Subnets should look similar to this:

```bash
## Set environment variables
export MY_RESOURCEGROUP=s.dutta-workshop
export MY_RESOURCEGROUP=${MY_NAME}-n4a-workshop
export MY_SUBSCRIPTIONID=$(az account show --query id -o tsv)
```

Expand All @@ -406,13 +409,13 @@ Your completed Vnet/Subnets should look similar to this:
```bash
##Sample Output##
{
"id": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/s.dutta-workshop/providers/Nginx.NginxPlus/nginxDeployments/nginx4a",
"id": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/sh.dutta-n4a-workshop/providers/Nginx.NginxPlus/nginxDeployments/nginx4a",
"identity": {
"principalId": "xxxx-xxxx-xxxx-xxxx-xxxx",
"tenantId": "xxxx-xxxx-xxxx-xxxx-xxxx",
"type": "SystemAssigned, UserAssigned",
"userAssignedIdentities": {
"/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/s.dutta-workshop/providers/Microsoft.ManagedIdentity/userAssignedIdentities/n4a-useridentity": {
"/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/sh.dutta-n4a-workshop/providers/Microsoft.ManagedIdentity/userAssignedIdentities/n4a-useridentity": {
"clientId": "xxxx-xxxx-xxxx-xxxx-xxxx",
"principalId": "xxxx-xxxx-xxxx-xxxx-xxxx"
}
Expand All @@ -426,18 +429,18 @@ Your completed Vnet/Subnets should look similar to this:
},
"enableDiagnosticsSupport": false,
"ipAddress": "<AZURE_ASSIGNED_PUBLICIP>",
"managedResourceGroup": "NGX_s.dutta-workshop_nginx4a_centralus",
"managedResourceGroup": "NGX_sh.dutta-n4a-workshop_nginx4a_centralus",
"networkProfile": {
"frontEndIPConfiguration": {
"publicIPAddresses": [
{
"id": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/s.dutta-workshop/providers/Microsoft.Network/publicIPAddresses/n4a-publicIP",
"resourceGroup": "s.dutta-workshop"
"id": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/sh.dutta-n4a-workshop/providers/Microsoft.Network/publicIPAddresses/n4a-publicIP",
"resourceGroup": "sh.dutta-n4a-workshop"
}
]
},
"networkInterfaceConfiguration": {
"subnetId": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/s.dutta-workshop/providers/Microsoft.Network/virtualNetworks/n4a-vnet/subnets/n4a-subnet"
"subnetId": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/sh.dutta-n4a-workshop/providers/Microsoft.Network/virtualNetworks/n4a-vnet/subnets/n4a-subnet"
}
},
"nginxVersion": "1.25.1 (nginx-plus-r30-p2)",
Expand All @@ -447,7 +450,7 @@ Your completed Vnet/Subnets should look similar to this:
},
"userProfile": {}
},
"resourceGroup": "s.dutta-workshop",
"resourceGroup": "sh.dutta-n4a-workshop",
"sku": {
"name": "standard_Monthly"
},
Expand Down Expand Up @@ -487,14 +490,14 @@ In this section you will create a Log Analytics resource that would collect Ngin
"features": {
"enableLogAccessUsingOnlyResourcePermissions": true
},
"id": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/s.dutta-workshop/providers/Microsoft.OperationalInsights/workspaces/n4a-loganalytics",
"id": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/sh.dutta-n4a-workshop/providers/Microsoft.OperationalInsights/workspaces/n4a-loganalytics",
"location": "centralus",
"modifiedDate": "2024-04-29T16:05:07.3687572Z",
"name": "n4a-loganalytics",
"provisioningState": "Succeeded",
"publicNetworkAccessForIngestion": "Enabled",
"publicNetworkAccessForQuery": "Enabled",
"resourceGroup": "s.dutta-workshop",
"resourceGroup": "sh.dutta-n4a-workshop",
"retentionInDays": 30,
"sku": {
"lastSkuUpdate": "2024-04-17T20:42:48.2028783Z",
Expand Down Expand Up @@ -523,13 +526,13 @@ In this section you will create a Log Analytics resource that would collect Ngin
```bash
##Sample Output##
{
"id": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/s.dutta-workshop/providers/Nginx.NginxPlus/nginxDeployments/nginx4a",
"id": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/sh.dutta-n4a-workshop/providers/Nginx.NginxPlus/nginxDeployments/nginx4a",
"identity": {
"principalId": "xxxx-xxxx-xxxx-xxxx-xxxx",
"tenantId": "xxxx-xxxx-xxxx-xxxx-xxxx",
"type": "SystemAssigned, UserAssigned",
"userAssignedIdentities": {
"/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/s.dutta-workshop/providers/Microsoft.ManagedIdentity/userAssignedIdentities/n4a-useridentity": {
"/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/sh.dutta-n4a-workshop/providers/Microsoft.ManagedIdentity/userAssignedIdentities/n4a-useridentity": {
"clientId": "xxxx-xxxx-xxxx-xxxx-xxxx",
"principalId": "xxxx-xxxx-xxxx-xxxx-xxxx"
}
Expand Down Expand Up @@ -579,7 +582,7 @@ In this section you will create a Log Analytics resource that would collect Ngin
```bash
##Sample Output##
{
"id": "/subscriptions/<SUBSCRIPTION_ID>/resourcegroups/s.dutta-workshop/providers/nginx.nginxplus/nginxdeployments/nginx4a/providers/microsoft.insights/diagnosticSettings/n4a-nginxlogs",
"id": "/subscriptions/<SUBSCRIPTION_ID>/resourcegroups/sh.dutta-n4a-workshop/providers/nginx.nginxplus/nginxdeployments/nginx4a/providers/microsoft.insights/diagnosticSettings/n4a-nginxlogs",
"logs": [
{
"category": "NginxLogs",
Expand All @@ -592,9 +595,9 @@ In this section you will create a Log Analytics resource that would collect Ngin
],
"metrics": [],
"name": "n4a-nginxlogs",
"resourceGroup": "s.dutta-workshop",
"resourceGroup": "sh.dutta-n4a-workshop",
"type": "Microsoft.Insights/diagnosticSettings",
"workspaceId": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/s.dutta-workshop/providers/Microsoft.OperationalInsights/workspaces/n4a-loganalytics"
"workspaceId": "/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/sh.dutta-n4a-workshop/providers/Microsoft.OperationalInsights/workspaces/n4a-loganalytics"
}
```

Expand Down
Loading