Created
November 22, 2020 13:48
-
-
Save ninjarobot/67cecc570f6d69b96b6b3481c3fb5cf4 to your computer and use it in GitHub Desktop.
Deploying etcd on Azure with Farmer
This file contains hidden or 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
open System | |
open Farmer | |
open Farmer.Builders | |
let deploymentLocation = Location.EastUS | |
let etcdDataStorage = storageAccount { | |
name "etcddata" | |
add_file_share_with_quota "data" 5<Gb> | |
} | |
let clusterDnsName = "etcdcluster" | |
let clusterFqdn = sprintf "%s.%s.azurecontainer.io" clusterDnsName deploymentLocation.ArmValue | |
let etcdCluster = containerGroup { | |
name "etcd-cluster" | |
public_dns clusterDnsName [ TCP, 2379us; TCP, 2380us ] | |
add_volumes [ | |
volume_mount.azureFile "etcd-data" "data" "etcddata" | |
] | |
add_instances [ | |
containerInstance { | |
cpu_cores 0.25 | |
memory 0.3<Gb> | |
name "etc-node-0" | |
image "quay.io/coreos/etcd:latest" | |
add_public_ports [ 2379us; 2380us ] | |
add_volume_mount "etcd-data" "/etcd-data" | |
command_line [ | |
"/usr/local/bin/etcd" | |
"--data-dir=/etcd-data" | |
"--name" | |
"node1" | |
"--initial-advertise-peer-urls" | |
sprintf "http://%s:2380" clusterFqdn | |
"--listen-peer-urls" | |
"http://0.0.0.0:2380" | |
"--advertise-client-urls" | |
sprintf "http://%s:2379" clusterFqdn | |
"--listen-client-urls" | |
"http://0.0.0.0:2379" | |
"--initial-cluster" | |
sprintf "node1=http://%s:2380" clusterFqdn | |
] | |
} | |
] | |
} | |
let deployment = arm { | |
location deploymentLocation | |
add_resources [ | |
etcdDataStorage | |
etcdCluster | |
] | |
} | |
deployment |> Writer.quickWrite "etcd-cluster" |
This file contains hidden or 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
{ | |
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | |
"contentVersion": "1.0.0.0", | |
"outputs": {}, | |
"parameters": {}, | |
"resources": [ | |
{ | |
"apiVersion": "2019-06-01", | |
"dependsOn": [], | |
"kind": "StorageV2", | |
"location": "eastus", | |
"name": "etcddata", | |
"properties": {}, | |
"sku": { | |
"name": "Standard_LRS" | |
}, | |
"tags": {}, | |
"type": "Microsoft.Storage/storageAccounts" | |
}, | |
{ | |
"apiVersion": "2019-06-01", | |
"dependsOn": [ | |
"etcddata" | |
], | |
"name": "etcddata/default/data", | |
"properties": { | |
"shareQuota": 5 | |
}, | |
"type": "Microsoft.Storage/storageAccounts/fileServices/shares" | |
}, | |
{ | |
"apiVersion": "2018-10-01", | |
"dependsOn": [ | |
"[resourceId('Microsoft.Storage/storageAccounts/fileServices/shares', 'etcddata', 'default', 'data')]" | |
], | |
"identity": { | |
"type": "None" | |
}, | |
"location": "eastus", | |
"name": "etcd-cluster", | |
"properties": { | |
"containers": [ | |
{ | |
"name": "etc-node-0", | |
"properties": { | |
"command": [ | |
"/usr/local/bin/etcd", | |
"--data-dir=/etcd-data", | |
"--name", | |
"node1", | |
"--initial-advertise-peer-urls", | |
"http://etcdcluster.eastus.azurecontainer.io:2380", | |
"--listen-peer-urls", | |
"http://0.0.0.0:2380", | |
"--advertise-client-urls", | |
"http://etcdcluster.eastus.azurecontainer.io:2379", | |
"--listen-client-urls", | |
"http://0.0.0.0:2379", | |
"--initial-cluster", | |
"node1=http://etcdcluster.eastus.azurecontainer.io:2380" | |
], | |
"environmentVariables": [], | |
"image": "quay.io/coreos/etcd:latest", | |
"ports": [ | |
{ | |
"port": 2379 | |
}, | |
{ | |
"port": 2380 | |
} | |
], | |
"resources": { | |
"requests": { | |
"cpu": 0.25, | |
"memoryInGB": 0.3 | |
} | |
}, | |
"volumeMounts": [ | |
{ | |
"mountPath": "/etcd-data", | |
"name": "etcd-data" | |
} | |
] | |
} | |
} | |
], | |
"imageRegistryCredentials": [], | |
"ipAddress": { | |
"dnsNameLabel": "etcdcluster", | |
"ports": [ | |
{ | |
"port": 2379, | |
"protocol": "TCP" | |
}, | |
{ | |
"port": 2380, | |
"protocol": "TCP" | |
} | |
], | |
"type": "Public" | |
}, | |
"osType": "Linux", | |
"restartPolicy": "Always", | |
"volumes": [ | |
{ | |
"azureFile": { | |
"shareName": "data", | |
"storageAccountKey": "[listKeys('Microsoft.Storage/storageAccounts/etcddata', '2018-07-01').keys[0].value]", | |
"storageAccountName": "etcddata" | |
}, | |
"name": "etcd-data" | |
} | |
] | |
}, | |
"tags": {}, | |
"type": "Microsoft.ContainerInstance/containerGroups" | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment