diff --git a/README.md b/README.md index fc07bb9..d9be0e2 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ This tutorial is optimized for learning, which means taking the long route to he * [Google Compute Engine](https://cloud.google.com/compute) * [Amazon EC2](https://aws.amazon.com/ec2) +* [Microsoft Azure VMs](https://azure.microsoft.com/en-us/services/virtual-machines/?b=16.51b) > The results of this tutorial should not be viewed as production ready, and may receive limited support from the community, but don't let that prevent you from learning! @@ -47,16 +48,21 @@ AWS * The us-west-2 region will be used +Azure + +* The westus region will be used + ## Platforms This tutorial assumes you have access to one of the following: * [Google Cloud Platform](https://cloud.google.com) and the [Google Cloud SDK](https://cloud.google.com/sdk/) (125.0.0+) * [Amazon Web Services](https://aws.amazon.com), the [AWS CLI](https://aws.amazon.com/cli) (1.10.63+), and [jq](https://stedolan.github.io/jq) (1.5+) +* [Microsoft Azure](https://azure.com) and the [Azure CLI](https://github.com/azure/azure-cli) ## Labs -While GCP or AWS will be used for basic infrastructure needs, the things learned in this tutorial apply to every platform. +While GCP, AWS or Azure will be used for basic infrastructure needs, the things learned in this tutorial apply to every platform. * [Cloud Infrastructure Provisioning](docs/01-infrastructure.md) * [Setting up a CA and TLS Cert Generation](docs/02-certificate-authority.md) diff --git a/docs/01-infrastructure.md b/docs/01-infrastructure.md index bd4ae69..6c5c9c1 100644 --- a/docs/01-infrastructure.md +++ b/docs/01-infrastructure.md @@ -1,8 +1,9 @@ # Cloud Infrastructure Provisioning -Kubernetes can be installed just about anywhere physical or virtual machines can be run. In this lab we are going to focus on [Google Cloud Platform](https://cloud.google.com/) and [Amazon Web Services](https://aws.amazon.com). +Kubernetes can be installed just about anywhere physical or virtual machines can be run. In this lab we are going to focus on [Google Cloud Platform](https://cloud.google.com/), [Amazon Web Services](https://aws.amazon.com) and [Microsoft Azure](https://azure.com). This lab will walk you through provisioning the compute instances required for running a H/A Kubernetes cluster. * [Cloud Infrastructure Provisioning - Google Cloud Platform](01-infrastructure-gcp.md) * [Cloud Infrastructure Provisioning - Amazon Web Services](01-infrastructure-aws.md) +* [Cloud Infrastructure Provisioning - Microsoft Azure](01-infrastructure-azure.md) \ No newline at end of file diff --git a/docs/02-certificate-authority.md b/docs/02-certificate-authority.md index b8facb2..fb187a0 100644 --- a/docs/02-certificate-authority.md +++ b/docs/02-certificate-authority.md @@ -38,7 +38,6 @@ chmod +x cfssljson_darwin-amd64 sudo mv cfssljson_darwin-amd64 /usr/local/bin/cfssljson ``` - ### Linux ``` @@ -137,6 +136,13 @@ KUBERNETES_PUBLIC_ADDRESS=$(aws elb describe-load-balancers \ jq -r '.LoadBalancerDescriptions[].DNSName') ``` +#### Azure + +```shell +KUBERNETES_PUBLIC_ADDRESS=$(az network public-ip show -g kubernetes \ + -n kubernetes-pip --query "ipAddress" -otsv) +``` + --- Create the `kubernetes-csr.json` file: @@ -229,7 +235,7 @@ done The following command will: * Extract the public IP address for each Kubernetes host * Copy the TLS certificates and keys to each Kubernetes host using `scp` - + ``` for host in ${KUBERNETES_HOSTS[*]}; do PUBLIC_IP_ADDRESS=$(aws ec2 describe-instances \ @@ -239,3 +245,19 @@ for host in ${KUBERNETES_HOSTS[*]}; do ubuntu@${PUBLIC_IP_ADDRESS}:~/ done ``` + +### Azure + +The following command will: + * Extract the public IP address for each Kubernetes host + * Copy the TLS certificates and keys to each Kubernetes host using `scp` + +```shell +for host in ${KUBERNETES_HOSTS[*]}; do + PUBLIC_IP_ADDRESS=$(az network public-ip show -g kubernetes \ + -n ${host}-pip --query "ipAddress" -otsv) + + scp ca.pem kubernetes-key.pem kubernetes.pem \ + $(whoami)@${PUBLIC_IP_ADDRESS}:~/ +done +``` \ No newline at end of file diff --git a/docs/03-etcd.md b/docs/03-etcd.md index f64271a..3f8e824 100644 --- a/docs/03-etcd.md +++ b/docs/03-etcd.md @@ -107,6 +107,12 @@ INTERNAL_IP=$(curl -s -H "Metadata-Flavor: Google" \ INTERNAL_IP=$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4) ``` +#### Azure + +```shell +INTERNAL_IP=$(ip addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}') +``` + --- Each etcd member must have a unique name within an etcd cluster. Set the etcd name: @@ -167,4 +173,4 @@ member 3a57933972cb5131 is healthy: got healthy result from https://10.240.0.12: member f98dc20bce6225a0 is healthy: got healthy result from https://10.240.0.10:2379 member ffed16798470cab5 is healthy: got healthy result from https://10.240.0.11:2379 cluster is healthy -``` +``` \ No newline at end of file diff --git a/docs/04-kubernetes-controller.md b/docs/04-kubernetes-controller.md index 05c1e88..e894a97 100644 --- a/docs/04-kubernetes-controller.md +++ b/docs/04-kubernetes-controller.md @@ -138,6 +138,12 @@ INTERNAL_IP=$(curl -s -H "Metadata-Flavor: Google" \ INTERNAL_IP=$(curl -s http://169.254.169.254/latest/meta-data/local-ipv4) ``` +#### Azure + +```shell +INTERNAL_IP=$(ip addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}') +``` + --- Create the systemd unit file: @@ -340,3 +346,26 @@ aws elb register-instances-with-load-balancer \ --load-balancer-name kubernetes \ --instances ${CONTROLLER_0_INSTANCE_ID} ${CONTROLLER_1_INSTANCE_ID} ${CONTROLLER_2_INSTANCE_ID} ``` + +### Azure + +```shell +az network lb probe create -g kubernetes \ + -n kubernetes-apiserver-check \ + --lb-name kubernetes-lb \ + --protocol http \ + --port 8080 \ + --path /healthz +``` + +```shell +az network lb rule create -g kubernetes \ + -n kubernetes-apiserver-rule \ + --protocol tcp \ + --lb-name kubernetes-lb \ + --frontend-ip-name LoadBalancerFrontEnd \ + --frontend-port 6443 \ + --backend-pool-name kubernetes-lb-pool \ + --backend-port 6443 \ + --probe-name kubernetes-apiserver-check +``` \ No newline at end of file diff --git a/docs/05-kubernetes-worker.md b/docs/05-kubernetes-worker.md index 52ac597..c6c8128 100644 --- a/docs/05-kubernetes-worker.md +++ b/docs/05-kubernetes-worker.md @@ -15,7 +15,6 @@ Kubernetes worker nodes are responsible for running your containers. All Kuberne Some people would like to run workers and cluster services anywhere in the cluster. This is totally possible, and you'll have to decide what's best for your environment. - ## Provision the Kubernetes Worker Nodes Run the following commands on `worker0`, `worker1`, `worker2`: diff --git a/docs/06-kubectl.md b/docs/06-kubectl.md index c75b17b..44b9036 100644 --- a/docs/06-kubectl.md +++ b/docs/06-kubectl.md @@ -36,6 +36,14 @@ KUBERNETES_PUBLIC_ADDRESS=$(aws elb describe-load-balancers \ --load-balancer-name kubernetes | \ jq -r '.LoadBalancerDescriptions[].DNSName') ``` + +#### Azure + +```shell +KUBERNETES_PUBLIC_ADDRESS=$(az network public-ip show -g kubernetes \ + -n kubernetes-pip --query "ipAddress" -otsv) +``` + --- Recall the token we setup for the admin user: @@ -95,4 +103,4 @@ NAME STATUS AGE worker0 Ready 7m worker1 Ready 5m worker2 Ready 2m -``` +``` \ No newline at end of file diff --git a/docs/07-network.md b/docs/07-network.md index 5b99809..31e6657 100644 --- a/docs/07-network.md +++ b/docs/07-network.md @@ -118,3 +118,44 @@ aws ec2 create-route \ --destination-cidr-block 10.200.2.0/24 \ --instance-id ${WORKER_2_INSTANCE_ID} ``` + +### Azure + +```shell +az network route-table create -g kubernetes \ + -n kubernetes-routes +``` + +```shell +az network vnet subnet update -g kubernetes \ + -n kubernetes-subnet \ + --vnet-name kubernetes-vnet \ + --route-table kubernetes-routes +``` + +```shell +az network route-table route create -g kubernetes \ + -n kubernetes-route-10-200-0-0-24 \ + --route-table-name kubernetes-routes \ + --address-prefix 10.200.0.0/24 \ + --next-hop-ip-address 10.240.0.20 \ + --next-hop-type VirtualAppliance +``` + +```shell +az network route-table route create -g kubernetes \ + -n kubernetes-route-10-200-1-0-24 \ + --route-table-name kubernetes-routes \ + --address-prefix 10.200.1.0/24 \ + --next-hop-ip-address 10.240.0.21 \ + --next-hop-type VirtualAppliance +``` + +```shell +az network route-table route create -g kubernetes \ + -n kubernetes-route-10-200-2-0-24 \ + --route-table-name kubernetes-routes \ + --address-prefix 10.200.2.0/24 \ + --next-hop-ip-address 10.240.0.22 \ + --next-hop-type VirtualAppliance +``` \ No newline at end of file diff --git a/docs/09-smoke-test.md b/docs/09-smoke-test.md index a812108..cdc818f 100644 --- a/docs/09-smoke-test.md +++ b/docs/09-smoke-test.md @@ -79,6 +79,29 @@ NODE_PUBLIC_IP=$(aws ec2 describe-instances \ jq -j '.Reservations[].Instances[].PublicIpAddress') ``` +#### Azure + +```shell +az network nsg rule create -g kubernetes \ + -n kubernetes-allow-nginx \ + --access allow \ + --destination-address-prefix '*' \ + --destination-port-range ${NODE_PORT} \ + --direction inbound \ + --nsg-name kubernetes-nsg \ + --protocol tcp \ + --source-address-prefix '*' \ + --source-port-range '*' \ + --priority 1002 +``` + +Grab the `EXTERNAL_IP` for one of the worker nodes: + +``` +NODE_PUBLIC_IP=$(gcloud compute instances describe worker0 \ + --format 'value(networkInterfaces[0].accessConfigs[0].natIP)') +``` + --- Test the nginx service using cURL: diff --git a/docs/10-cleanup.md b/docs/10-cleanup.md index 452b58a..63d97c6 100644 --- a/docs/10-cleanup.md +++ b/docs/10-cleanup.md @@ -205,3 +205,9 @@ DHCP_OPTION_SET_ID=$(aws ec2 describe-dhcp-options \ aws ec2 delete-dhcp-options \ --dhcp-options-id ${DHCP_OPTION_SET_ID} ``` + +## GCP + +```shell +az group delete -n kubernetes +``` \ No newline at end of file