Last active
October 19, 2021 20:24
-
-
Save engineererr/82d2e565b7879c6cb774c117492310c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: <container_group_name> | |
apiVersion: '2018-10-01' | |
location: '<location>' | |
tags: {} | |
properties: | |
containers: | |
- name: <container_name> | |
properties: | |
image: pihole/pihole:latest | |
ports: | |
- protocol: UDP | |
port: 53 | |
- protocol: UDP | |
port: 67 | |
- protocol: TCP | |
port: 80 | |
- protocol: TCP | |
port: 443 | |
environmentVariables: | |
- name: TZ | |
value: Asia/Kolkata | |
- name: WEBPASSWORD | |
value: <custom_large_string> | |
resources: | |
requests: | |
memoryInGB: 1 | |
cpu: 1 | |
volumeMounts: | |
- name: pihole | |
mountPath: /etc/pihole/ | |
readOnly: false | |
- name: dnsmasq | |
mountPath: /etc/dnsmasq.d/ | |
readOnly: false | |
restartPolicy: Always | |
ipAddress: | |
ports: | |
- protocol: UDP | |
port: 53 | |
- protocol: UDP | |
port: 67 | |
- protocol: TCP | |
port: 80 | |
- protocol: TCP | |
port: 443 | |
type: public | |
dnsNameLabel: <custom_dnsname> | |
osType: Linux | |
volumes: | |
- name: pihole | |
azureFile: | |
shareName: etc-pihole | |
readOnly: false | |
storageAccountName: <storage_name> | |
storageAccountKey: <value of $STORAGE_KEY> | |
- name: dnsmasq | |
azureFile: | |
shareName: etc-dnsmasq | |
readOnly: false | |
storageAccountName: <storage_name> | |
storageAccountKey: <value of $STORAGE_KEY> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Source: https://dev.to/ganesshkumar/pi-hole-in-azure-container-instances-4abf | |
# Download Azure CLI optionally | |
#Invoke-WebRequest -Uri https://aka.ms/installazurecliwindows -OutFile .\AzureCLI.msi; Start-Process msiexec.exe -Wait -ArgumentList '/I AzureCLI.msi /quiet'; rm .\AzureCLI.msi | |
cd $PSScriptRoot | |
$subscriptionId = "1231321332144" # shown after logging in with 'az login' | |
$rgName = "rg-pi-hole" | |
$location = "WestEurope" # use 'az account list-locations' to list all locations | |
$storageName = "piholestorage" | |
$containerGroupName = "pi-hole-container-group" | |
$containerName = "pi-hole-container" | |
$yamlOriginalFileName = "deploy-pi-hole-original.yaml" | |
$yamlModifiedFileName = "deploy-pi-hole.yaml" | |
$customDnsName = "pihole" | |
$webPassword = "superSecretLongAndCrazyPass22..334" | |
az login | |
az account set --subscription $subscriptionId | |
az group create --name $rgName --location $location | |
az storage account create --resource-group $rgName --name $storageName --location $location --sku Standard_LRS | |
az storage share create --account-name $storageName --name etc-pihole | |
az storage share create --account-name $storageName --name etc-dnsmasq | |
$STORAGE_KEY=$(az storage account keys list --resource-group $rgName --account-name $storageName --query "[0].value" --output tsv) | |
# prepare yaml file | |
$stringsToReplace = @( | |
@("<location>", $location), | |
@("<container_group_name>", $containerGroupName), | |
@("<container_name>", $containerName), | |
@("<custom_large_string>", $webPassword), | |
@("<custom_dnsname>", $customDnsName), | |
@('<value of $STORAGE_KEY>', $STORAGE_KEY), | |
@('<storage_name>', $storageName) | |
) | |
Copy-Item -Path $yamlOriginalFileName -Destination $yamlModifiedFileName | |
# Replacing all placeholder in the yaml file | |
foreach($replace in $stringsToReplace){ | |
(Get-Content $yamlModifiedFileName).replace($replace[0], $replace[1]) | Set-Content $yamlModifiedFileName | |
} | |
az container create --resource-group $rgName --file $yamlModifiedFileName | |
az container show --resource-group $rgName --name $containerGroupName --query ipAddress.ip --output tsv |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment