Skip to content

Commit

Permalink
Updated ACSA Scenario for fixes (#2754)
Browse files Browse the repository at this point in the history
* initial test deployment

* path update

* yaml rename

* swapping out github links for main azure-arc repo

* Update acsa-deploy.yaml

* Update container name to use mcr
  • Loading branch information
ldabas-msft authored Oct 11, 2024
1 parent 282fb0f commit be7dbaa
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 795 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ function Add-AzureStorageAccountSecret {
kubectl create secret generic -n $Namespace $SecretName --from-literal=azurestorageaccountkey="$secretValue" --from-literal=azurestorageaccountname="$StorageAccount"
}

#Begin ESA Installation.
#Begin ACSA Installation.
#Documentation: https://aepreviews.ms/docs/edge-storage-accelerator/how-to-install-edge-storage-accelerator/
# Create a storage account
# Echo the container and account name
Expand Down Expand Up @@ -374,54 +374,34 @@ if ($maxUserInstances -lt 1024) {
Write-Host "Installing Open Service Mesh (OSM)..."
az k8s-extension create --resource-group "$env:resourceGroup" --cluster-name "$env:arcClusterName" --cluster-type connectedClusters --extension-type Microsoft.openservicemesh --scope cluster --name osm
Write-Host "Open Service Mesh (OSM) installed successfully."
# Disable ACStor for single-node cluster
Write-Host "Disabling ACStor for single-node cluster..."
# Create the config.json file
$acstorConfig = @{
"feature.diskStorageClass" = "local-path"
"acstorController.enabled" = $false
}

$acstorConfigJson = $acstorConfig | ConvertTo-Json -Depth 100
Set-Content -Path "config.json" -Value $acstorConfigJson
Write-Host "ACStor disabled for single-node cluster."
Write-Host "Checking if Edge Storage Accelerator Arc Extension is installed..."
$extensionExists = az k8s-extension show --resource-group "$env:resourceGroup" --cluster-name "$env:arcClusterName" --cluster-type connectedClusters --name hydraext --query "extensionType" --output tsv
if ($extensionExists -eq "microsoft.edgestorageaccelerator") {
Write-Host "Edge Storage Accelerator Arc Extension is already installed."
} else {
Write-Host "Installing Edge Storage Accelerator Arc Extension..."
az k8s-extension create --resource-group "$env:resourceGroup" --cluster-name "$env:arcClusterName" --cluster-type connectedClusters --name hydraext --extension-type microsoft.edgestorageaccelerator --config-file "config.json"
Write-Host "Edge Storage Accelerator Arc Extension installed successfully."
}

# Create Kubernetes secret for Azure Storage account
Write-Host "Creating Kubernetes secret for Azure Storage account..."
$secretName = "$env:storageAccountName-secret"
Add-AzureStorageAccountSecret -ResourceGroup $env:resourceGroup -StorageAccount $env:storageAccountName -Namespace "default" -SecretName "esa-secret"
Write-Host "Kubernetes secret created successfully."
Write-Host "Downloading pv.yaml file..."
$pvYamlUrl = "https://raw.githubusercontent.com/microsoft/azure_arc/main/azure_edge_iot_ops_jumpstart/esa_fault_detection/yaml/pv.yaml"

$pvYamlPath = "pv.yaml"
Invoke-WebRequest -Uri $pvYamlUrl -OutFile $pvYamlPath
# Update the secret name and container name in the pv.yaml file
#$pvYamlContent = Get-Content -Path $pvYamlPath -Raw
#$pvYamlContent = $pvYamlContent -replace '\${CONTAINER_NAME}-secret', $secretName
#$pvYamlContent = $pvYamlContent -replace '\${CONTAINER_NAME}', $env:storageContainer
#Set-Content -Path $pvYamlPath -Value $pvYamlContent
# Apply the pv.yaml file using kubectl
Write-Host "Applying pv.yaml configuration..."
kubectl apply -f $pvYamlPath
Write-Host "pv.yaml configuration applied successfully."
Write-Host "Downloading esa-deploy.yaml file..."
$esadeployYamlUrl = "https://raw.githubusercontent.com/microsoft/azure_arc/main/azure_edge_iot_ops_jumpstart/esa_fault_detection/yaml/esa-deploy.yaml"
$esadeployYamlPath = "esa-deploy.yaml"
Invoke-WebRequest -Uri $esadeployYamlUrl -OutFile $esadeployYamlPath
# Apply the p-deploy.yaml file using kubectl
Write-Host "Applying esadeploy.yaml configuration..."
kubectl apply -f $esadeployYamlPath
Write-Host "esa-deploy.yaml configuration applied successfully."
$uniqueSuffix = (New-Guid).Guid.Substring(0,6)
$extensionName = "acsa-$uniqueSuffix"
Write-Output "Extension Name: $extensionName"

az k8s-extension create --resource-group $env:resourceGroup --cluster-name $env:arcClusterName --cluster-type connectedClusters --name $extensionName --extension-type microsoft.arc.containerstorage --config feature.diskStorageClass="default,local-path" --config edgeStorageConfiguration.create=true


$principalID = az k8s-extension list --cluster-name $env:arcClusterName --resource-group $env:resourceGroup --cluster-type connectedClusters --query "[?extensionType=='microsoft.arc.containerstorage'].identity.principalId | [0]" -o tsv

az role assignment create --assignee-object-id $principalID --assignee-principal-type ServicePrincipal --role "Storage Blob Data Owner" --scope "/subscriptions/$Env:subscriptionId/resourceGroups/$env:resourceGroup/providers/Microsoft.Storage/storageAccounts/$env:storageAccountName"


$acsadeployYamlUrl = "https://raw.githubusercontent.com/microsoft/azure_arc/main/azure_edge_iot_ops_jumpstart/acsa_fault_detection/yaml/acsa-deploy.yaml"
$acsadeployYamlPath = "acsa-deploy.yaml"
Invoke-WebRequest -Uri $acsadeployYamlUrl -OutFile $acsadeployYamlPath

# Replace {STORAGEACCOUNT} with the actual storage account name
$yamlContent = Get-Content $acsadeployYamlPath -Raw
$yamlContent = $yamlContent.Replace("{STORAGEACCOUNT}", $env:storageAccountName)
Set-Content -Path $acsadeployYamlPath -Value $yamlContent


# Apply the acsa-deploy.yaml file using kubectl
Write-Host "Applying acsa-deploy.yaml configuration..."
kubectl apply -f $acsadeployYamlPath
Write-Host "acsa-deploy.yaml configuration applied successfully."

# Stop the PowerShell process monitoring Kubernetes pods

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"parameters": {
"vmName": {
"type": "string",
"defaultValue": "ESA-Demo",
"defaultValue": "ACSA-Demo",
"metadata": {
"description": "The name of you Virtual Machine."
}
Expand Down Expand Up @@ -56,7 +56,7 @@
},
"bastionHostName": {
"type": "string",
"defaultValue": "ESA-Demo-Bastion",
"defaultValue": "ACSA-Demo-Bastion",
"metadata": {
"description": "the Azure Bastion host name"
}
Expand Down Expand Up @@ -120,7 +120,7 @@
},
"virtualNetworkName": {
"type": "string",
"defaultValue": "ESA-Demo-VNET",
"defaultValue": "ACSA-Demo-VNET",
"metadata": {
"description": "Name of the VNET"
}
Expand All @@ -134,7 +134,7 @@
},
"networkSecurityGroupName": {
"type": "string",
"defaultValue": "ESA-Demo-NSG",
"defaultValue": "ACSA-Demo-NSG",
"metadata": {
"description": "Name of the Network Security Group"
}
Expand All @@ -154,7 +154,7 @@
}
},
"variables": {
"templateBaseUrl": "[concat('https://raw.githubusercontent.com/', parameters('githubAccount'), '/azure_arc/', parameters('githubBranch'), '/azure_edge_iot_ops_jumpstart/esa_fault_detection/')]",
"templateBaseUrl": "[concat('https://raw.githubusercontent.com/', parameters('githubAccount'), '/azure_arc/', parameters('githubBranch'), '/azure_edge_iot_ops_jumpstart/acsa_fault_detection/')]",
"vmName": "[concat(parameters('vmName'))]",
"publicIpAddressName": "[concat(parameters('vmName'), '-PIP' )]",
"networkInterfaceName": "[concat(parameters('vmName'),'-NIC')]",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,58 +1,66 @@
apiVersion: v1
kind: PersistentVolumeClaim
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: esa-pvc
namespace: default
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 5Gi
storageClassName: esa
volumeMode: Filesystem
volumeName: esa-pv
status:
accessModes:
- ReadWriteMany
capacity:
storage: 5Gi
### Create a name for your PVC ###
name: acsa-pvc
### Use a namespace that matched your intended consuming pod, or "default" ###
namespace: default
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 10Gi
storageClassName: cloud-backed-sc
---
apiVersion: "arccontainerstorage.azure.net/v1"
kind: EdgeSubvolume
metadata:
name: faultdata
spec:
edgevolume: acsa-pvc
path: faultdata # If you change this path, line 33 in deploymentExample.yaml must be updated. Don't use a preceding slash.
auth:
authType: MANAGED_IDENTITY
storageaccountendpoint: "https://{STORAGEACCOUNT}.blob.core.windows.net/"
container: fault-detection
ingestPolicy: edgeingestpolicy-default # Optional: See the following instructions if you want to update the ingestPolicy with your own configuration
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: esa-webserver
name: acsa-webserver
spec:
replicas: 1
selector:
matchLabels:
app: esa-webserver
app: acsa-webserver
template:
metadata:
labels:
app: esa-webserver
app: acsa-webserver
spec:
containers:
- name: esa-webserver
image: jumpstartprod.azurecr.io/esa-webserver:latest
- name: acsa-webserver
image: mcr.microsoft.com/jumpstart/scenarios/acsa_ai_webserver:1.0.0
ports:
- containerPort: 8000
env:
- name: RTSP_URL
value: rtsp://virtual-rtsp:8554/stream
- name: LOCAL_STORAGE
value: /app/esa_storage
value: /app/acsa_storage/faultdata
volumeMounts:
### This name must match the volumes.name attribute below ###
- name: blob
### This mountPath is where the PVC will be attached to the pod's filesystem ###
mountPath: "/app/esa_storage"
mountPath: "/app/acsa_storage"
volumes:
### User-defined 'name' that will be used to link the volumeMounts. This name must match volumeMounts.name as specified above. ###
- name: blob
persistentVolumeClaim:
### This claimName must refer to the PVC resource 'name' as defined in the PVC config. This name will match what your PVC resource was actually named. ###
claimName: esa-pvc
claimName: acsa-pvc


---
Expand Down Expand Up @@ -89,7 +97,8 @@ spec:
mountPath: /samples
containers:
- name: virtual-rtsp
image: "agoraarmbladev.azurecr.io/kerberos/virtual-rtsp:latest"
### chnage to dockerhub image link
image: "kerberos/virtual-rtsp"
imagePullPolicy: Always
ports:
- containerPort: 8554
Expand Down Expand Up @@ -122,14 +131,14 @@ spec:
apiVersion: v1
kind: Service
metadata:
name: esa-webserver-svc
name: acsa-webserver-svc
labels:
app: esa-webserver
app: acsa-webserver
spec:
type: LoadBalancer
ports:
- port: 8000
targetPort: 8000
protocol: TCP
selector:
app: esa-webserver
app: acsa-webserver

This file was deleted.

This file was deleted.

Loading

0 comments on commit be7dbaa

Please sign in to comment.