Complete Guide: Setup Azure Arc Kubernetes on GCP (GKE) & AWS (EKS)

Azure Arc allows you to manage Kubernetes clusters running outside of Azure, including those hosted on Google Cloud (GKE) and Amazon Web Services (EKS). This guide will walk you through setting up and onboarding Kubernetes clusters to Azure Arc on both GCP and AWS.


1. Prerequisites

General Requirements

  • Azure Subscription: You need an active Azure account. Sign up here
  • Azure CLI: Install Azure CLI on your local machine.
  • kubectl: Kubernetes command-line tool.
  • Helm: Helm package manager for Kubernetes.
  • GCP Account: Set up a GCP project and enable Kubernetes Engine.
  • AWS Account: Set up an AWS account with permissions to create EKS clusters.

2. Setting Up Kubernetes on GCP (GKE)

Step 1: Create a GKE Cluster

  1. Authenticate with GCP:
    gcloud auth login
  2. Set project:
    gcloud config set project YOUR_PROJECT_ID
  3. Enable Kubernetes API:
    gcloud services enable container.googleapis.com
  4. Create a GKE cluster:
    gcloud container clusters create gke-cluster \
        --zone us-central1-a \
        --num-nodes 3 \
        --machine-type e2-standard-4
  5. Get cluster credentials:
    gcloud container clusters get-credentials gke-cluster --zone us-central1-a

3. Setting Up Kubernetes on AWS (EKS)

Step 1: Create an EKS Cluster

  1. Install AWS CLI and configure:
    aws configure
  2. Create an EKS cluster:
    eksctl create cluster --name eks-cluster --region us-east-1 --nodes 3
  3. Verify the cluster:
    kubectl get nodes

4. Connecting GKE & EKS to Azure Arc

Step 1: Register Azure Arc Provider

Run the following to register Azure Arc for Kubernetes:

az login
az provider register --namespace Microsoft.Kubernetes
az provider register --namespace Microsoft.KubernetesConfiguration

Step 2: Install Azure Arc CLI Extensions

az extension add --name connectedk8s
az extension add --name k8s-configuration

Step 3: Connect Kubernetes to Azure Arc

For GKE Cluster:

az connectedk8s connect --name gke-cluster --resource-group YOUR_RESOURCE_GROUP --location eastus

For EKS Cluster:

az connectedk8s connect --name eks-cluster --resource-group YOUR_RESOURCE_GROUP --location eastus

Step 4: Verify Connection

az connectedk8s list --resource-group YOUR_RESOURCE_GROUP

5. Deploying Azure Policies & Monitoring

Step 1: Enable Azure Policy for Kubernetes

az k8s-extension create --cluster-type connectedClusters --cluster-name gke-cluster \
   --resource-group YOUR_RESOURCE_GROUP --extension-type Microsoft.PolicyInsights

Step 2: Enable Azure Monitor for Containers

  1. Enable Azure Monitor:
    az monitor log-analytics workspace create --resource-group YOUR_RESOURCE_GROUP --workspace-name arc-logs
    
  2. Connect monitoring:
    az monitor log-analytics workspace list
    az k8s-extension create --cluster-type connectedClusters --cluster-name gke-cluster \
        --resource-group YOUR_RESOURCE_GROUP --extension-type Microsoft.AzureMonitor.Containers
    

6. Managing and Deploying Applications

You can now use Azure Arc to deploy applications across your Kubernetes clusters using GitOps, policies, and Azure Monitor.

To deploy a sample app:

kubectl create deployment hello-world --image=k8s.gcr.io/echoserver:1.4

Expose the app:

kubectl expose deployment hello-world --type=LoadBalancer --port=80 --target-port=8080

7. Conclusion

You have successfully onboarded GKE and EKS to Azure Arc. Now, you can manage these clusters as if they were Azure-native using Azure Portal, Azure Policy, and Azure Monitor.

Popular posts from this blog

Learn Java 8 streams with an example - print odd/even numbers from Array and List

Java Stream API - How to convert List of objects to another List of objects using Java streams?

Registration and Login with Spring Boot + Spring Security + Thymeleaf

Java, Spring Boot Mini Project - Library Management System - Download

ReactJS, Spring Boot JWT Authentication Example

Top 5 Java ORM tools - 2024

Java - Blowfish Encryption and decryption Example

Spring boot video streaming example-HTML5

Google Cloud Storage + Spring Boot - File Upload, Download, and Delete