> ## Documentation Index
> Fetch the complete documentation index at: https://docs.apinizer.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Version Management with ArgoCD

> Argo CD is an open-source GitOps Continuous Deployment tool developed for Kubernetes environments. It has an architecture based on the Single Source of Truth model, which is the cornerstone of GitOps, and monitors applications deployed to Kubernetes at certain intervals and compares them with yaml files in the git repository. When it detects any change, it automatically synchronizes.

## ArgoCD Installation

Follow the steps below to install ArgoCD on the Kubernetes Cluster.

<Steps>
  <Step title="Creating namespace">
    Create a namespace for ArgoCD:

    ```bash theme={null}
    kubectl create namespace argocd
    ```
  </Step>

  <Step title="ArgoCD installation">
    Apply ArgoCD manifest files from GitHub repository:

    ```bash theme={null}
    kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
    ```
  </Step>

  <Step title="Monitoring pod status">
    Monitor the startup of pods:

    ```bash theme={null}
    watch kubectl get pods -n argocd
    ```

    <img src="https://mintcdn.com/apinizer/rfZaKpIysRC7U9dY/images/setup/kubernetes/argocd/01-pods.png?fit=max&auto=format&n=rfZaKpIysRC7U9dY&q=85&s=8b6c547f99de0b1a2eefb9b685ded4aa" alt="ArgoCD Pods" width="741" height="176" style={{ borderRadius: '0.5rem' }} data-path="images/setup/kubernetes/argocd/01-pods.png" />
  </Step>

  <Step title="Configuring service type">
    Configure the service type as NodePort to access the ArgoCD interface:

    ```bash theme={null}
    kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "NodePort"}}'
    kubectl get svc argocd-server -n argocd
    ```

    <img src="https://mintcdn.com/apinizer/rfZaKpIysRC7U9dY/images/setup/kubernetes/argocd/02-service.png?fit=max&auto=format&n=rfZaKpIysRC7U9dY&q=85&s=b10dd71721d516bd6ffe70e7a36e62bb" alt="ArgoCD Service" width="793" height="129" style={{ borderRadius: '0.5rem' }} data-path="images/setup/kubernetes/argocd/02-service.png" />
  </Step>

  <Step title="Accessing interface">
    Access the ArgoCD interface using the port address your service exposes externally:

    ```
    http://<KUBERNETES_WORKER_IP_ADDRESS>:<PORT>
    ```

    <img src="https://mintcdn.com/apinizer/rfZaKpIysRC7U9dY/images/setup/kubernetes/argocd/03-ui.png?fit=max&auto=format&n=rfZaKpIysRC7U9dY&q=85&s=ff4324ef4d1b825be6a9b23a13420234" alt="ArgoCD Interface" width="1200" height="533" style={{ borderRadius: '0.5rem' }} data-path="images/setup/kubernetes/argocd/03-ui.png" />
  </Step>

  <Step title="Getting password">
    Decode and display the password encoded in Base64 format:

    ```bash theme={null}
    kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo
    ```

    <Info>
      The default username is **admin**. You can log in to the ArgoCD interface using this information.
    </Info>
  </Step>
</Steps>

## Git Installation and Repository Configuration

Perform Git installation and configure the repository to push deployment files to GitHub.

<Steps>
  <Step title="Git installation">
    Install the Git package:

    ```bash theme={null}
    sudo apt update
    sudo apt install git
    git --version
    ```

    <Warning>
      Git may ask you for user information. Configure using the following commands:

      ```bash theme={null}
      git config --global user.email "you@example.com"
      git config --global user.name "Your Name"
      ```
    </Warning>
  </Step>

  <Step title="Creating GitHub repository">
    Create a repository on GitHub to store your deployment files.
  </Step>

  <Step title="Configuring remote address">
    Add it to the git system as a remote address to be able to add files to the GitHub repository.

    <Warning>
      **Authentication Error Solution**

      If you get an "Authentication failed" error when using git, follow these steps:

      1. Log in to your GitHub account
      2. Click your profile picture in the top right corner and select "Settings"
      3. Go to "Personal access tokens" under "Developer settings" from the left menu
      4. Click "Generate new token" after "Token"
      5. Give necessary permissions
      6. Go to the bottom of the page and click "Generate token"
      7. **Copy the token value and save it to a safe place. You cannot view this value again.**

      Configure the remote address with the token:

      ```bash theme={null}
      git remote set-url origin https://<USERNAME>:<ACCESS_TOKEN>@<REPO_ADDRESS>
      ```

      Example: `https://test:ghp_xxxx@github.com/test/test.git`
    </Warning>
  </Step>

  <Step title="Pushing deployment files">
    Add the Apinizer Manager deployment yaml file to the git version system and push it to the remote repository:

    ```bash theme={null}
    git init
    git add apinizer-api-manager-deployment.yaml
    git commit -m "manager add"
    git remote add origin <GITHUB_REPO_ADDRESS>
    git push -u origin master
    ```
  </Step>
</Steps>

## Adding Git Repository to ArgoCD

After adding YAML files to the GitHub repository, you need to add this repository address from the ArgoCD interface.

There are many connection methods. For the HTTPS method, you need to fill in the following fields.

<img src="https://mintcdn.com/apinizer/rfZaKpIysRC7U9dY/images/setup/kubernetes/argocd/04-git-repo.png?fit=max&auto=format&n=rfZaKpIysRC7U9dY&q=85&s=f48c3465fbc4ab347aa56040533a9fb0" alt="Adding Git Repository" width="1000" height="481" style={{ borderRadius: '0.5rem', maxWidth: '100%', height: 'auto' }} data-path="images/setup/kubernetes/argocd/04-git-repo.png" />

<Warning>
  **Important**

  If **HTTPS** is selected as the connection method, write the **token** value you created in the previous step in the **password** section.
</Warning>

<img src="https://mintcdn.com/apinizer/rfZaKpIysRC7U9dY/images/setup/kubernetes/argocd/05-git-repo-detail.png?fit=max&auto=format&n=rfZaKpIysRC7U9dY&q=85&s=2ac8d40147d1534fa0a90715bc31e7e3" alt="Git Repository Connection Details" width="1000" height="317" style={{ borderRadius: '0.5rem', maxWidth: '100%', height: 'auto' }} data-path="images/setup/kubernetes/argocd/05-git-repo-detail.png" />

## Creating ArgoCD Application

You can automate your deployment processes by creating an application on ArgoCD.

<Steps>
  <Step title="Determining application name">
    Give a name for the application.
  </Step>

  <Step title="Sync Policy configuration">
    If you want ArgoCD to automatically check for updates in the repository, set the **SYNC POLICY** option to **Automatic**.

    <Info>
      When Automatic sync policy is active, ArgoCD checks every 3 minutes on your behalf.
    </Info>

    <img src="https://mintcdn.com/apinizer/rfZaKpIysRC7U9dY/images/setup/kubernetes/argocd/06-app-create.png?fit=max&auto=format&n=rfZaKpIysRC7U9dY&q=85&s=1c7624c47e4168e7ba33bb9966038384" alt="Creating Application" width="1200" height="600" style={{ borderRadius: '0.5rem' }} data-path="images/setup/kubernetes/argocd/06-app-create.png" />
  </Step>

  <Step title="Automatic namespace creation">
    <Info>
      When you need a namespace that has not been created before in your Kubernetes Cluster, ArgoCD creates a namespace in your Kubernetes cluster with the **AUTO-CREATE NAMESPACE** option.
    </Info>

    <img src="https://mintcdn.com/apinizer/rfZaKpIysRC7U9dY/images/setup/kubernetes/argocd/07-auto-namespace.png?fit=max&auto=format&n=rfZaKpIysRC7U9dY&q=85&s=cc601447c3c038d7e754b73aecdebf0c" alt="Auto-create Namespace" width="1200" height="600" style={{ borderRadius: '0.5rem' }} data-path="images/setup/kubernetes/argocd/07-auto-namespace.png" />

    <img src="https://mintcdn.com/apinizer/rfZaKpIysRC7U9dY/images/setup/kubernetes/argocd/08-app-detail.png?fit=max&auto=format&n=rfZaKpIysRC7U9dY&q=85&s=b8f8a6b854669bbab786d6dc2fac309b" alt="Application Details" width="1200" height="600" style={{ borderRadius: '0.5rem' }} data-path="images/setup/kubernetes/argocd/08-app-detail.png" />
  </Step>
</Steps>

### Application Management

ArgoCD visually shows you deployments, replica sets, and pods. You can view real-time log data of pods.

<img src="https://mintcdn.com/apinizer/rfZaKpIysRC7U9dY/images/setup/kubernetes/argocd/09-pod-logs.png?fit=max&auto=format&n=rfZaKpIysRC7U9dY&q=85&s=3e1666c4459cc23fc488891308861dec" alt="Pod Logs" width="1000" height="600" style={{ borderRadius: '0.5rem' }} data-path="images/setup/kubernetes/argocd/09-pod-logs.png" />

**Manual Synchronization:** You can manually synchronize a change made in your YAML file by pressing the **SYNC** button.

**Automatic Synchronization:** ArgoCD, which automatically detects every change made in YAML files, automates your deploy processes by updating your pods. This way, while your deploy processes occur more efficiently and quickly, you can prevent manual interventions and errors.
