How to Use ArgoCD with GitHub?


How to Use ArgoCD with GitHub?

ArgoCD is a powerful tool for declarative continuous deployment of Kubernetes applications. When integrated with GitHub, it becomes a robust solution for managing and automating the deployment of your applications. In this article, we will guide you through the process of using ArgoCD with GitHub, providing step-by-step instructions and examples to help you seamlessly deploy and manage your Kubernetes applications.

  1. Setting Up ArgoCD:
    To begin, ensure that you have ArgoCD installed in your Kubernetes cluster. You can install ArgoCD using the following command:

    kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml

    This command deploys ArgoCD along with its necessary components.

  2. Accessing the ArgoCD Web UI:
    Once installed, you can access the ArgoCD web UI by port-forwarding the ArgoCD server service. Use the following command:

    kubectl port-forward svc/argocd-server -n argocd 8080:443

    Now, open your web browser and navigate to http://localhost:8080. Log in using the default credentials (username: admin, password: the name of the ArgoCD server pod).

  3. Connecting ArgoCD to GitHub:
    To integrate ArgoCD with GitHub, you need to create a GitHub personal access token. Generate a token with the "repo" and "admin:repo_hook" scopes. Set this token as a secret in ArgoCD using the following command:

    kubectl -n argocd create secret generic argocd-secret --from-literal=github.token=<YOUR_GITHUB_TOKEN>
  4. Adding a GitHub Repository to ArgoCD:
    Now, you can add your GitHub repository to ArgoCD. Use the following command, replacing the placeholders with your repository URL and desired application name:

    argocd repo add <REPO_URL> --username <GITHUB_USERNAME> --password <GITHUB_TOKEN>

    For example:

    argocd repo add https://github.com/your-username/your-repo.git --username your-username --password $ARGOCD_TOKEN

Step-by-Step Instructions:

  1. Access the ArgoCD Web UI:

    • Open a terminal and run the port-forwarding command.
    • Open your web browser and go to http://localhost:8080.
    • Log in using the provided credentials.
  2. Connect ArgoCD to GitHub:

    • Generate a GitHub personal access token with the required scopes.
    • Use kubectl to create a secret in ArgoCD containing your GitHub token.
  3. Add a GitHub Repository to ArgoCD:

    • Run the 'argocd repo add' command, providing your repository URL and GitHub credentials.
    • Verify the repository has been successfully added in the ArgoCD web UI.

More Examples:

  1. Syncing Applications:

    • Use the ArgoCD web UI or the following command to sync your application with the GitHub repository:
    argocd app sync <APP_NAME>

    This command ensures that the application state in the cluster matches the desired state defined in your Git repository.

  2. Monitoring Application Health:

    • Monitor the health of your application using the ArgoCD web UI or the following command:
    argocd app get <APP_NAME>

    This command provides detailed information about the application, including health status and sync status.

By following these steps, you have successfully set up ArgoCD with GitHub, allowing you to efficiently manage and automate the deployment of your Kubernetes applications. Explore further ArgoCD features and GitHub integration options to streamline your continuous deployment workflow.

Related Searches and Questions asked:

  • What is the difference between GitOps and ArgoCD?
  • What is the Difference Between Jenkins and ArgoCD?
  • CD Workflow with ArgoCD
  • CD Workflow Without ArgoCD
  • That's it for this topic, Hope this article is useful. Thanks for Visiting us.