Inspired by Google Anthos Configuration Manager (ACM) I wondered if I could use Argo CD and a repository to auto-configure multiple Kubernetes clusters. This repo is my sandbox for testing this theory and playing with different features.
The objective is to connect multiple kubernetes clusters via Argo CD to this repo and whenever I push changes in this repo, they will automatically apply the changes.
- Create or use an existing Google Cloud Platform project (demo purposes but any clusters should work)
- Clone this repository to your computer, cd to
multi-cluster-argo-demo
- Create a
.env
file in the same directory ascreate-k8s-clusters.sh
cat > .env << EOF
export PROJECT_ID=<YOUR PROJECT ID>
export AUTH_NETWORK="<YOUR IP ADDRESS>/32"
EOF
- Execute the bootstrap script
./create-k8s-clusters.sh
- Log into your clusters after 8-10 minutes and confirm you have
east
andwest
clusters and Argo CD workloads are installed. - Port forward requests to Argo CD server and fetch default password (server pod name)
# port forward (for now) to access argocd UI
kubectl port-forward svc/argocd-server -n argocd 8080:443 &
# fetch initial password (auto generated)
export ARGO_PASS=$(kubectl get pods -n argocd -l app.kubernetes.io/name=argocd-server -o name | cut -d'/' -f 2)
echo "Argo default pass: ${ARGO_PASS}"
- Open browser to
http://localhost:8080
(accept security warning) and useadmin
and<PASSWORD FROM ABOVE>
to confirm applications synced - Confirm your clusters have the
namespace
,serviceaccount
,role
,rolebinding
declared in thek8s-config/
folder - Create your own repo and change the
app-of-apps.yaml
andk8s-config.yaml
to point to your repo instead. - Enjoy!
If you are just trying this out, then to avoid unnecessary expense either delete your project or remove the recently-created clusters using the commands below:
gcloud container clusters delete west --zone us-west2-b
gcloud container clusters delete east --zone us-east1-c
If you want to see this demo in action, view the YouTube video below
- read about private repositories
- use Argo CD
projects
- use recursive directories
- add application workloads as well as cluster config