This project uses Kind (Kubernetes in Docker) to create isolated Kubernetes clusters, installs ArgoCD using Helm, and manages applications through ArgoCD. This guide provides all the steps to set up, install, and interact with the project.
- Prerequisites
- Installation Steps
- Configuring Environments
- Interacting with the Project
- Uninstalling
- Troubleshooting
Before starting, ensure you have the following tools installed on your machine:
-
Docker: Required for Kind to create Kubernetes clusters.
Install Docker -
Kind: Kubernetes in Docker, used for creating local Kubernetes clusters.
Install Kind -
kubectl: Command-line tool for interacting with Kubernetes clusters.
Install kubectl -
Helm: Kubernetes package manager, used to install ArgoCD and other Helm charts.
Install Helm -
argocd CLI: Command-line tool to interact with the ArgoCD API server.
Install ArgoCD CLI
Clone this repository to your local machine:
git clone https://github.com/omarfawzi/K8s-Starter
cd K8s-Starter
We support two environments: Production and Staging. Each environment runs on its own Kind cluster.
- To set up the Production cluster:
make env-production install-argocd install-ingress
- To set up the Staging cluster:
make env-staging install-argocd install-ingress
This will:
- Create a Kind cluster (
production-cluster
orstaging-cluster
). - Install ArgoCD in the respective cluster using Helm.
- Install Kind Ingress Controller in the respective cluster using Helm.
To interact with ArgoCD, you’ll need to log in to the ArgoCD server and retrieve the initial admin password.
- For Production:
make env-production get-argocd-password
- For Staging:
make env-staging get-argocd-password
This will print out the initial ArgoCD admin password.
- For Production:
make env-production login-argocd
- For Staging:
make env-staging login-argocd
This will log you in to the ArgoCD UI. The CLI will output a success message if the login is successful.
You can easily switch between the Production and Staging environments using the following commands:
- Set environment to Production:
make env-production
- Set environment to Staging:
make env-staging
This will set the necessary environment variables like ENVIRONMENT
, ARGO_PORT
, and INGRESS_PORT
which are used in various make targets.
Once the environment is set, you can run the installation commands as follows:
make install-argocd
This command will create the Kind cluster and install ArgoCD via Helm.
You can view the logs of ArgoCD or any application deployed in the cluster.
- For Production:
make env-production switch-cluster
kubectl logs -n argocd -l app.kubernetes.io/name=argocd-server -f
- For Staging:
make env-staging switch-cluster
kubectl logs -n argocd -l app.kubernetes.io/name=argocd-server -f
To view logs for a specific application managed by ArgoCD, use the following command:
kubectl logs <pod_name> -n <namespace> -f
You can find the pod name using:
kubectl get pods -n <namespace>
To access the ArgoCD UI, we use port-forwarding:
- For Production:
make env-production port-forward-argocd
- For Staging:
make env-staging port-forward-argocd
After running the command, open your browser and navigate to:
- Production: http://localhost:8080
- Staging: http://localhost:8081
You can log in with the admin username and the password retrieved earlier.
To apply argocd applications set you would need to execute following:
- For Production:
make env-production apply-argocd
- For Staging:
make env-staging apply-argocd
You can use the ArgoCD CLI or the UI to manage applications. To sync an application from the CLI:
- For Production:
make env-production switch-cluster
argocd app sync <app_name> --insecure
- For Staging:
make env-staging switch-cluster
argocd app sync <app_name> --insecure
You can also create, delete, or manage applications via the ArgoCD UI.
- ArgoCD UI not accessible: Make sure the port-forwarding is running. If necessary, check if the ArgoCD server pod is up using
kubectl get pods -n argocd
. - Application sync fails: Check the logs for the application using
kubectl logs
to identify issues. Also, verify the ArgoCD UI for error messages. - Kind cluster issues: If the Kind cluster isn’t starting, ensure Docker is running and that your machine has enough resources.
Here’s a high-level architecture diagram of the project setup:
- Kind: Creates isolated Kubernetes clusters.
- Helm: Installs ArgoCD in the clusters.
- ArgoCD: Manages applications and provides GitOps functionality.
Feel free to open issues or contribute by creating pull requests for improvements or bug fixes.