What is Azure ARC?
Azure Arc is an Azure offering that simplifies managing complex and distributed environments across on-premises, edge and multi-cloud. Azure Arc delivers three capabilities – managing VMs running outside of Azure, registering and managing Kubernetes clusters deployed within and outside of Azure and running managed data services based on Azure SQL and PostgreSQL Hyperscale in Kubernetes clusters registered with Azure Arc. Currently Azure ARC is in preview.
How to manage GKE on Azure ARC?
Follow the below steps to configure and manage GKE in Azure ARC. For this blog we used a linux machine (jump server) which has connectivity to both GKE in Google cloud and Azure.
- Use an existing GKE in Google cloud or to test create a new one, if not available
- Open Azure ARC in Azure Portal
- Click on “Next : Cluster details”
- Fill up the details related to Subscription, Resource group, Cluster name and Region and click “Next : Run Script”
- For this blog we used a Cent OS 7 as a jumpbox and install gcloud installed in it. To download and install gcloud refer https://cloud.google.com/sdk/docs#linux
- Login as root in jumpbox and create file “azcli_installer.sh”. this file will be responsible for installing Azure CLI on Linux machine
Content of “azcli_installer.sh”
#!/bin/bash echo "Script to install Azure CLI with YUM package manager" echo "Import the Microsoft repository key" sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc echo "Create local azure-cli repository information" sudo sh -c 'echo -e "[azure-cli] name=Azure CLI baseurl=https://packages.microsoft.com/yumrepos/azure-cli enabled=1 gpgcheck=1 gpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/azure-cli.repo' echo "Install with the yum install command" sudo yum install azure-cli -y
Making file executable
chmod 755 azcli_installer.sh
Execute the file
- Verify the Azure CLI installation by execute
Output will be similar to this, and you have to navigate to “https://microsoft.com/devicelogin”and enter the code displayed
To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code ETMY3E9Q9 to authenticate
- Add extension to Azure CLI
az extension add --name connectedk8s az extension add --name k8sconfiguration
- Installing helm in the jump server. Helm is a Kubernetes package manager. Create a file helm_installer.sh
Content of “helm_install.sh”
#!/bin/bash echo "Downloading the file" curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3 echo "Making get_helm.sh executable" chmod 700 get_helm.sh echo "Executing get_helm.sh" sudo sh get_helm.sh
Making file executable
chmod 755 helm_install.sh
Before executing make sure “/usr/local/bin” is there in PATH variable
If “/usr/local/bin”, not available in PATH add it
Then execute it
- Create CreateConnectedClusterScript.sh in jump server, which is downloaded from Azure ARC portal (shown below)
Copy the content of file downloaded from ARC to the file created in jump server
Make it executable
chmod 755 CreateConnectedClusterScript.sh
- Making “kubeconfig” file in jump server for GKE created in Google Cloud. This activity is done since CreateConnectedClusterScript.sh will try to connect the Google CLoud GKE cluster via helm
gcloud container clusters get-credentials gcp-gke --zone us-central1-c --project devops-273723
here gcp-gke is the GKE cluster in Google cloud.
Verify the cluster added and make sure the cluster added is current context by (an * mark will be there in front)
kubectl config get-contexts
- Execute CreateConnectedClusterScript.sh
it might take couple of minute to complete the execution.
- Once completed go to back to Azure portal and click on ”Verification” and click on “Go to cluster”
Now the GKE cluster is visible and manageable via Azure.