From c6cb2eaee4760be84006f65362290224382df1f8 Mon Sep 17 00:00:00 2001 From: Ryan Zhang Date: Tue, 6 Dec 2022 15:29:58 -0800 Subject: [PATCH 1/3] argo demo --- examples/demo/README.md | 43 +++++++++++++++++++++++++++++++ examples/demo/argo-app.yaml | 18 +++++++++++++ examples/demo/argoCD_install.yaml | 28 ++++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 examples/demo/README.md create mode 100644 examples/demo/argo-app.yaml create mode 100644 examples/demo/argoCD_install.yaml diff --git a/examples/demo/README.md b/examples/demo/README.md new file mode 100644 index 000000000..28b16c018 --- /dev/null +++ b/examples/demo/README.md @@ -0,0 +1,43 @@ +Here is how to run e2e locally. Make sure that you have installed Docker and Kind. + +1. Add the ArgoCD Helm +```shell +export KUBECONFIG=~/.kube/fleet-hub +helm repo add argo https://argoproj.github.io/argo-helm +helm search repo argo +``` + +2. Create the CRP on the hub +```shell +kubectl apply -f argoCD_install.yaml +``` + +3. Install the argoCD + ```shell +helm install --create-namespace -n argocd-system aks-demo argo/argo-cd +``` + +4. Verify on one member cluster that the argoCD is installed +```shell +kubectl get crds -l app.kubernetes.io/part-of=argocd +kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo +kubectl port-forward svc/aks-demo-argocd-server -n argocd-system 8080:443 +``` +Check the argoCD web on cluster1 + +5. Apply the Argo application on the hub +```shell +kubectl apply -f argo-app.yaml +``` + +Use a local prometheus to draw graphs. Download prometheus binary for your local machine. Start the prometheus. +```shell +prometheus --config.file=test/e2e/prometheus.yml +``` + +6.uninstall the resources +```shell +helm delete aks-demo -n argocd-system +kubectl delete crds -l app.kubernetes.io/part-of=argocd +kubectl delete ns argocd-system +``` \ No newline at end of file diff --git a/examples/demo/argo-app.yaml b/examples/demo/argo-app.yaml new file mode 100644 index 000000000..7a6f46979 --- /dev/null +++ b/examples/demo/argo-app.yaml @@ -0,0 +1,18 @@ +apiVersion: argoproj.io/v1alpha1 +kind: Application +metadata: + name: in-cluster-guestbook + namespace: argocd-system +spec: + destination: + namespace: guestbook + server: https://kubernetes.default.svc + project: default + source: + path: guestbook + repoURL: https://github.com/ryanzhang-oss/argocd-example-apps/ + targetRevision: argo-test + syncPolicy: + automated: {} + syncOptions: + - CreateNamespace=true \ No newline at end of file diff --git a/examples/demo/argoCD_install.yaml b/examples/demo/argoCD_install.yaml new file mode 100644 index 000000000..daa39721f --- /dev/null +++ b/examples/demo/argoCD_install.yaml @@ -0,0 +1,28 @@ +apiVersion: fleet.azure.com/v1alpha1 +kind: ClusterResourcePlacement +metadata: + name: argocd-installer +spec: + resourceSelectors: + - group: "" + version: v1 + kind: Namespace + name: argocd-system + - group: rbac.authorization.k8s.io + version: v1 + kind: ClusterRole + labelSelector: + matchLabels: + app.kubernetes.io/part-of: argocd + - group: rbac.authorization.k8s.io + version: v1 + kind: ClusterRoleBinding + labelSelector: + matchLabels: + app.kubernetes.io/part-of: argocd + - group: apiextensions.k8s.io + version: v1 + kind: CustomResourceDefinition + labelSelector: + matchLabels: + app.kubernetes.io/part-of: argocd \ No newline at end of file From 939a22d3f2f8cebddfae7a51bdb2158d02c200d1 Mon Sep 17 00:00:00 2001 From: Ryan Zhang Date: Tue, 6 Dec 2022 16:21:22 -0800 Subject: [PATCH 2/3] minor fix --- examples/demo/README.md | 14 +++++++++----- examples/demo/argo-app.yaml | 5 ++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/examples/demo/README.md b/examples/demo/README.md index 28b16c018..a8e5970f5 100644 --- a/examples/demo/README.md +++ b/examples/demo/README.md @@ -20,22 +20,26 @@ helm install --create-namespace -n argocd-system aks-demo argo/argo-cd 4. Verify on one member cluster that the argoCD is installed ```shell kubectl get crds -l app.kubernetes.io/part-of=argocd -kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo +kubectl -n argocd-system get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo kubectl port-forward svc/aks-demo-argocd-server -n argocd-system 8080:443 ``` Check the argoCD web on cluster1 5. Apply the Argo application on the hub ```shell -kubectl apply -f argo-app.yaml +kubectl apply -f argo-app.yaml ``` -Use a local prometheus to draw graphs. Download prometheus binary for your local machine. Start the prometheus. +6. Check the member cluster1 and cluster2 web + +7. Change the Git Repo + +8. Delete the argo application ```shell -prometheus --config.file=test/e2e/prometheus.yml +kubectl delete -f argo-app.yaml ``` -6.uninstall the resources +9.uninstall the resources ```shell helm delete aks-demo -n argocd-system kubectl delete crds -l app.kubernetes.io/part-of=argocd diff --git a/examples/demo/argo-app.yaml b/examples/demo/argo-app.yaml index 7a6f46979..da1cb0c9e 100644 --- a/examples/demo/argo-app.yaml +++ b/examples/demo/argo-app.yaml @@ -3,6 +3,8 @@ kind: Application metadata: name: in-cluster-guestbook namespace: argocd-system + #finalizers: + # - resources-finalizer.argocd.argoproj.io spec: destination: namespace: guestbook @@ -13,6 +15,7 @@ spec: repoURL: https://github.com/ryanzhang-oss/argocd-example-apps/ targetRevision: argo-test syncPolicy: - automated: {} + automated: + prune: true syncOptions: - CreateNamespace=true \ No newline at end of file From 7bffabd228ef004f7d034b08a18be554efdd3903 Mon Sep 17 00:00:00 2001 From: Ryan Zhang Date: Wed, 14 Dec 2022 15:31:34 -0800 Subject: [PATCH 3/3] temp --- examples/demo/README.md | 21 ++++++++++++++++++++- examples/demo/mongo_install.yaml | 10 ++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 examples/demo/mongo_install.yaml diff --git a/examples/demo/README.md b/examples/demo/README.md index a8e5970f5..e585e4a0c 100644 --- a/examples/demo/README.md +++ b/examples/demo/README.md @@ -1,6 +1,24 @@ Here is how to run e2e locally. Make sure that you have installed Docker and Kind. -1. Add the ArgoCD Helm +1. Install mongo db +```shell +helm install ryan-mongodb -n mongodb-system --create-namespace azure-marketplace/mongodb-sharded --set service.type=LoadBalancer,configsvr.pdb.create=true,configsvr.persistence.storageClass=managed-csi + +kubectl apply -f mongo_install.yaml +``` + +2. Verify on the member cluster +```shell +helm list -n mongodb-system + +export MONGODB_ROOT_PASSWORD=$(kubectl get secret --namespace mongodb-system ryan-mongodb-mongodb-sharded -o jsonpath="{.data.mongodb-root-password}" | base64 -d) +kubectl run --namespace mongodb-system ryan-mongodb-mongodb-sharded-client --rm --tty -i --restart='Never' --image marketplace.azurecr.io/bitnami/mongodb-sharded:6.0.1-debian-11-r1 --command -- mongosh admin --host ryan-mongodb-mongodb-sharded --authenticationDatabase admin -u root -p $MONGODB_ROOT_PASSWORD + +export SERVICE_IP=$(kubectl get svc --namespace mongodb-system ryan-mongodb-mongodb-sharded --include "{{ range (index .status.loadBalancer.ingress 0) }}{{ . }}{{ end }}") +mongosh --host $SERVICE_IP --port 27017 --authenticationDatabase admin -p $MONGODB_ROOT_PASSWORD +``` + +3. Add the ArgoCD Helm ```shell export KUBECONFIG=~/.kube/fleet-hub helm repo add argo https://argoproj.github.io/argo-helm @@ -41,6 +59,7 @@ kubectl delete -f argo-app.yaml 9.uninstall the resources ```shell +helm delete ryan-mongodb -n mongodb-system helm delete aks-demo -n argocd-system kubectl delete crds -l app.kubernetes.io/part-of=argocd kubectl delete ns argocd-system diff --git a/examples/demo/mongo_install.yaml b/examples/demo/mongo_install.yaml new file mode 100644 index 000000000..6cb1cdad3 --- /dev/null +++ b/examples/demo/mongo_install.yaml @@ -0,0 +1,10 @@ +apiVersion: fleet.azure.com/v1alpha1 +kind: ClusterResourcePlacement +metadata: + name: mongo-installer +spec: + resourceSelectors: + - group: "" + version: v1 + kind: Namespace + name: mongodb-system \ No newline at end of file