How to deploy ArgoCD on Google Kubernetes Engine (GKE)?

How to deploy ArgoCD on Google Kubernetes Engine (GKE)?

ArgoProj is a collection of tools for getting work done with Kubernetes. Argo Workflows - Container-native Workflow Engine. Argo CD - Declarative GitOps Continuous Delivery. Argo Events - Event-based Dependency Manager. Argo Rollouts - Progressive Delivery with support for Canary and Blue-Green deployment strategies. Argo: https://landscape.cncf.io/?selected=argo

Google Kubernetes Engine (GKE) is a managed, production-ready environment for running containerized applications on Kubernetes. GKE: https://cloud.google.com/kubernetes-engine

Prerequisite

  • IDE with Google Cloud project access.

  • Google Cloud project with GKE access.

Step

  1. Login to IDE and authorize the Google Cloud project. Google Cloud IDE is recommended. Reference: https://manikandank276.hashnode.dev/how-to-authorize-google-cloud-ide

  2. Declare parameter

     PROJECT_ID='<type your GCP project ID>'
     GKE_CLUSTER_NAME='<type cluster name>'
     GKE_CLUSTER_REGION='us-central1'
     GKE_CLUSTER_ZONE='us-central1-c'
     ARGOCD_NAMESPACE_NAME='argocd'
     ARGOCD_YAML_FILENAME='https://raw.githubusercontent.com/argoproj/argo-cd/v2.7.4/manifests/install.yaml'
    
  3. Configure GCP (repeated)

     gcloud config set project ${PROJECT_ID}
    
  4. Create the GKE cluster. Change cluster version if require

     gcloud beta container clusters create ${GKE_CLUSTER_NAME} --zone ${GKE_CLUSTER_ZONE} --no-enable-basic-auth --cluster-version "1.24.12-gke.500" --release-channel "stable" --machine-type "g1-small" --image-type "COS_CONTAINERD" --disk-type "pd-standard" --disk-size "32" --metadata disable-legacy-endpoints=true --scopes "https://www.googleapis.com/auth/devstorage.read_only","https://www.googleapis.com/auth/logging.write","https://www.googleapis.com/auth/monitoring","https://www.googleapis.com/auth/servicecontrol","https://www.googleapis.com/auth/service.management.readonly","https://www.googleapis.com/auth/trace.append" --max-pods-per-node "110" --num-nodes "3" --logging=SYSTEM,WORKLOAD --monitoring=SYSTEM --enable-ip-alias --network "projects/${PROJECT_ID}/global/networks/default" --subnetwork "projects/${PROJECT_ID}/regions/${GKE_CLUSTER_REGION}/subnetworks/default" --no-enable-intra-node-visibility --default-max-pods-per-node "110" --no-enable-master-authorized-networks --addons HorizontalPodAutoscaling,HttpLoadBalancing,GcePersistentDiskCsiDriver --enable-autoupgrade --enable-autorepair --max-surge-upgrade 1 --max-unavailable-upgrade 0 --enable-shielded-nodes --node-locations ${GKE_CLUSTER_ZONE} --project ${PROJECT_ID}
    

    Script to get cluster version

     gcloud container get-server-config --zone $GKE_CLUSTER_ZONE --flatten=channels --filter="channels.channel=STABLE" --format="value(channels.defaultVersion)"
    
  5. Connect to the GKE cluster

     gcloud container clusters get-credentials ${GKE_CLUSTER_NAME} --zone ${GKE_CLUSTER_ZONE} --project ${PROJECT_ID}
    
  6. Review GKE cluster

     kubectl get node
     kubectl get namespaces
     # Note: argocd namespace not present in ouptut
    
  7. Create the namespace for argoCD deployment

     kubectl create namespace ${ARGOCD_NAMESPACE_NAME}
    
  8. Deploy argoCD

     kubectl apply --namespace ${ARGOCD_NAMESPACE_NAME} --filename ${ARGOCD_YAML_FILENAME}
    
  9. Review argoCD pod

     kubectl get pods --namespace ${ARGOCD_NAMESPACE_NAME}
     # Note: Ensure all pods running
    
  10. Enable load balancing

    kubectl patch svc argocd-server --namespace ${ARGOCD_NAMESPACE_NAME} -p '{"spec": {"type": "LoadBalancer"}}'
    
  11. Find the load-balancing IP of ArgoCD

    kubectl get svc argocd-server --namespace ${ARGOCD_NAMESPACE_NAME}
    # Note the external IP
    
  12. Get ArgoCD password

    kubectl --namespace ${ARGOCD_NAMESPACE_NAME} get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo
    #Note the password
    
  13. Open the external IP of load balancing the new browser tab.

  14. Login with the user name (admin) and ArgoCD password

ArgoCD deployed successfully. The output looks like the one below.