Skip to content

Instantly share code, notes, and snippets.

@alexeldeib
Last active May 29, 2024 23:37
Show Gist options
  • Save alexeldeib/43726d574f5e9019dab013127c91d5fe to your computer and use it in GitHub Desktop.
Save alexeldeib/43726d574f5e9019dab013127c91d5fe to your computer and use it in GitHub Desktop.
Talos Kubernetes cluster on Azure

Talos on Azure

Prepare

Clone the repo and build the vhd.

curl -O -L https://github.com/talos-systems/talos/releases/download/v0.2.0-alpha.2/osctl-linux-amd64
mv osctl-linux-amd64 osctl
chmod +x osctl
git clone [email protected]:talos-systems/talos.git
cd talos
GO111MODULE=on go get
make ci
make talos-azure

Environment variables (optional)

Set some environment variables for convenient use later.

STORAGE_ACCOUNT=${STORAGE_ACCOUNT:-mytalosvhd}
GROUP=${GROUP:-talos}
LOCATION=${LOCATION:-westus2}

Storage account + VHD upload

Create a storage account, blob container, upload the VHD, and build an image.

az group create -l $LOCATION -n $GROUP
az storage account create -g $GROUP -n $STORAGE_ACCOUNT
CONNECTION=$(az storage account show-connection-string -n $STORAGE_ACCOUNT -g $GROUP -o tsv)
az storage container create -n talos --connection-string $CONNECTION
az storage blob upload --connection-string $CONNECTION --container-name talos -f build/talos-azure.vhd -n disk.vhd
az image create --name talos --source https://$STORAGE_ACCOUNT.blob.core.windows.net/talos/disk.vhd --os-type linux -g $GROUP

Create Networking infrastructure

Create a resource group, NSG, some security rules, and public IPs for the masters.

az network nsg create -g $GROUP -n talos
az network nsg rule create -g $GROUP --nsg-name talos -n proxyd --priority 1000 --destination-port-ranges 443  --direction inbound
az network nsg rule create -g $GROUP --nsg-name talos -n osd --priority 1001 --destination-port-ranges 50000 --direction inbound
az network nsg rule create -g $GROUP --nsg-name talos -n trustd --priority 1002 --destination-port-ranges 50001 --direction inbound
az network nsg rule create -g $GROUP --nsg-name talos -n etcd --priority 1003 --destination-port-ranges 2379-2380 --direction inbound
az network nsg rule create -g $GROUP --nsg-name talos -n kube --priority 1004 --destination-port-ranges 6443 --direction inbound
az network public-ip create -g $GROUP --name talos-master-1 --allocation-method static
az network public-ip create -g $GROUP --name talos-master-2 --allocation-method static
az network public-ip create -g $GROUP --name talos-master-3 --allocation-method static
MASTERIPS=$(az network public-ip list -g ace-talos -o tsv --query [].ipAddress | paste -sd,)

Configure and Create VMs

./osctl config generate cluster.local $MASTERIPS
az vm create --name talos1 --image talos --custom-data ./master-1.yaml  --public-ip-address talos-master-1 -g $GROUP --admin-username talos --generate-ssh-keys --verbose --boot-diagnostics-storage $STORAGE_ACCOUNT --nsg talos --os-disk-size-gb 64 --no-wait
az vm create --name talos2 --image talos --custom-data ./master-2.yaml  --public-ip-address talos-master-2 -g $GROUP --admin-username talos --generate-ssh-keys --verbose --boot-diagnostics-storage $STORAGE_ACCOUNT --nsg talos --os-disk-size-gb 64 --no-wait
az vm create --name talos3 --image talos --custom-data ./master-3.yaml  --public-ip-address talos-master-3 -g $GROUP --admin-username talos --generate-ssh-keys --verbose --boot-diagnostics-storage $STORAGE_ACCOUNT --nsg talos --os-disk-size-gb 64 --no-wait
## Worker, reuse as needed
az vm create --name talos4 --image talos --custom-data ./worker.yaml -g $GROUP --admin-username talos --generate-ssh-keys --verbose --boot-diagnostics-storage $STORAGE_ACCOUNT --nsg talos --os-disk-size-gb 64 --no-wait
#!/bin/bash
curl -O -L https://github.com/talos-systems/talos/releases/download/v0.2.0-alpha.2/osctl-linux-amd64
mv osctl-linux-amd64 osctl
chmod +x osctl
git clone [email protected]:talos-systems/talos.git
cd talos
GO111MODULE=on go get
make ci
make talos-azure
STORAGE_ACCOUNT=${STORAGE_ACCOUNT:-mytalosvhd}
GROUP=${GROUP:-talos}
LOCATION=${LOCATION:-westus2}
az group create -l $LOCATION -n $GROUP
az storage account create -g $GROUP -n $STORAGE_ACCOUNT
CONNECTION=$(az storage account show-connection-string -n $STORAGE_ACCOUNT -g $GROUP -o tsv)
az storage container create -n talos --connection-string $CONNECTION
az storage blob upload --connection-string $CONNECTION --container-name talos -f build/talos-azure.vhd -n disk.vhd
az image create --name talos --source https://$STORAGE_ACCOUNT.blob.core.windows.net/talos/disk.vhd --os-type linux -g $GROUP
az network nsg create -g $GROUP -n talos
az network nsg rule create -g $GROUP --nsg-name talos -n proxyd --priority 1000 --destination-port-ranges 443 --direction inbound
az network nsg rule create -g $GROUP --nsg-name talos -n osd --priority 1001 --destination-port-ranges 50000 --direction inbound
az network nsg rule create -g $GROUP --nsg-name talos -n trustd --priority 1002 --destination-port-ranges 50001 --direction inbound
az network nsg rule create -g $GROUP --nsg-name talos -n etcd --priority 1003 --destination-port-ranges 2379-2380 --direction inbound
az network nsg rule create -g $GROUP --nsg-name talos -n kube --priority 1004 --destination-port-ranges 6443 --direction inbound
az network public-ip create -g $GROUP --name talos-master-1 --allocation-method static
az network public-ip create -g $GROUP --name talos-master-2 --allocation-method static
az network public-ip create -g $GROUP --name talos-master-3 --allocation-method static
MASTERIPS=$(az network public-ip list -g ace-talos -o tsv --query [].ipAddress | paste -sd,)
./osctl config generate cluster.local $MASTERIPS
az vm create --name talos1 --image talos --custom-data ./master-1.yaml --public-ip-address talos-master-1 -g $GROUP --admin-username talos --generate-ssh-keys --verbose --boot-diagnostics-storage $STORAGE_ACCOUNT --nsg talos --os-disk-size-gb 64 --no-wait
az vm create --name talos2 --image talos --custom-data ./master-2.yaml --public-ip-address talos-master-2 -g $GROUP --admin-username talos --generate-ssh-keys --verbose --boot-diagnostics-storage $STORAGE_ACCOUNT --nsg talos --os-disk-size-gb 64 --no-wait
az vm create --name talos3 --image talos --custom-data ./master-3.yaml --public-ip-address talos-master-3 -g $GROUP --admin-username talos --generate-ssh-keys --verbose --boot-diagnostics-storage $STORAGE_ACCOUNT --nsg talos --os-disk-size-gb 64 --no-wait
## Worker, reuse as needed
az vm create --name talos4 --image talos --custom-data ./worker.yaml -g $GROUP --admin-username talos --generate-ssh-keys --verbose --boot-diagnostics-storage $STORAGE_ACCOUNT --nsg talos --os-disk-size-gb 64 --no-wait
@andrewrynhard
Copy link

andrewrynhard commented Jul 22, 2019

FYI, the recently released official Azure image can be download, decompressed, and pushed up instead of building it manually.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment