Last active
September 14, 2017 16:43
-
-
Save brusMX/23077b2764f35cb20830e47c27a0c0d7 to your computer and use it in GitHub Desktop.
These are a set of instructions to deploy a Kubernetes cluster to Azure with ACS-Engine. K8s v 1.7 and managed disks
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
#!/bin/bash | |
# NOT A SCRIPT | |
# Commands to deploy Kubernetes cluster with k8s 1.7 and managed disks | |
# Author: Bruno Medina (@brusmx) | |
# Requirements: | |
# - Azure Cli 2.0 (Using 2.0.16) | |
# - jq (Using 1.5) | |
# - acs-engine (using release acs-engine-v0.6.0-darwin-amd64 | MD5 checksum(acs-engine-v0.6.0-darwin-amd64/acs-engine) = b124d5ca90dcf5bdd0d9da5699ba776b ) | |
# - managed-disks-cluster.json most be at the same level of this | |
# Export Azure Service Principal Credentials | |
# You can use my script to get your credentials | |
# wget https://gist.githubusercontent.com/brusMX/96538826d582388cb3b73a66a023b332/raw/e6925b0686bef5492296b2d4707b78a76c62ba2b/obtainAzureSP.sh | |
# You can use | |
# source obtainAzureSP.sh | |
# Or write them by hand here and paste them in your terminal | |
# export AZURE_CLIENT_NAME= | |
# export AZURE_CLIENT_SECRET= | |
# export AZURE_TENANT_ID= | |
az login --service-principal -u "${AZURE_CLIENT_NAME}" -p "${AZURE_CLIENT_SECRET}" --tenant "${AZURE_TENANT_ID}" | |
# Set your environment variables for the cluster (PLEASE CHANGE) | |
export LOC=southcentralus | |
export RG_NAME=cluster-mngd-k8s-02 | |
# And lets use the same cluster in the managed disk file you defined. | |
export RG_DNS_NAME=`cat managed-disks-cluster.json | jq -r ."properties"."masterProfile"."dnsPrefix"` | |
# Create a Resource Group because its way easier to remove the RG than each thing at a time | |
az group create --name "${RG_NAME}" --location $LOC | |
# Create artifacts with acs-engine (Assuming is located in same folder) | |
./acs-engine generate managed-disks-cluster.json | |
# You should get a 'INFO[0000] Generating assets...' | |
# Deploy it | |
az group deployment create --resource-group="${RG_NAME}" --template-file="_output/${RG_DNS_NAME}/azuredeploy.json" --name="${RG_DNS_NAME}" --parameters @_output/${RG_DNS_NAME}/azuredeploy.parameters.json | |
#It should take about 10-20 mins | |
#And after it's done we need the kubeconfig file | |
# After you have the cluster running | |
# Get the keys | |
scp -o StrictHostKeyChecking=no azureuser@$RG_DNS_NAME.$LOC.cloudapp.azure.com:/home/azureuser/.kube/config config-$RG_DNS_NAME | |
mkdir ~/.kube | |
#paste this config file into your kube config files and use it's route to make it default | |
mv config-$RG_DNS_NAME ~/.kube | |
export KUBECONFIG=~/.kube/config-$RG_DNS_NAME | |
#Confirm the cluster is up and running by doing | |
kubectl cluster-INFO | |
# Get the nodes | |
kubectl get nodes | |
#If something went wrong, just delete the resource group and start again | |
#az group delete -n $RG_NAME |
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
{ | |
"apiVersion": "vlabs", | |
"properties": { | |
"orchestratorProfile": { | |
"orchestratorType": "Kubernetes", | |
"orchestratorRelease": "1.7" | |
}, | |
"masterProfile": { | |
"count": 1, | |
"dnsPrefix": "mngdk8cl02", | |
"vmSize": "Standard_D2_v2", | |
"OSDiskSizeGB": 200 | |
}, | |
"agentPoolProfiles": [ | |
{ | |
"name": "agent", | |
"count": 3, | |
"vmSize": "Standard_DS12_v2", | |
"OSDiskSizeGB": 200, | |
"storageProfile" : "ManagedDisks", | |
"availabilityProfile": "AvailabilitySet" | |
} | |
], | |
"linuxProfile": { | |
"adminUsername": "azureuser", | |
"ssh": { | |
"publicKeys": [ | |
{ | |
"keyData": "" | |
} | |
] | |
} | |
}, | |
"servicePrincipalProfile": { | |
"clientId": "", | |
"secret": "" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment