Forked from vfarcic/099-crossplane-kubevela-argocd.sh
Created
February 7, 2022 17:22
-
-
Save alisson276/f1c3a9c8bc5e8956d9d3c4f1842a044c to your computer and use it in GitHub Desktop.
Revisions
-
vfarcic revised this gist
Sep 21, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -134,7 +134,7 @@ argocd login \ argocd account update-password \ --current-password $PASS \ --new-password admin123 echo http://argo-cd.$INGRESS_HOST.nip.io -
vfarcic revised this gist
Aug 3, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -243,7 +243,7 @@ git push unset KUBECONFIG # In the second terminal kubectl get clusters,nodegroup,iamroles,iamrolepolicyattachments,vpcs,securitygroups,subnets,internetgateways,routetables,providerconfigs.helm.crossplane.io,releases # Wait until all the resources are removed -
vfarcic revised this gist
Aug 2, 2021 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,7 +23,7 @@ # Setup # ######### # Create a Kuberentes cluster with Ingress. It can be a local (e.g., KinD, minikube, etc.) or a remote cluster. # Replace `[...]` with the external IP of the Ingress service export INGRESS_HOST=[...] @@ -165,7 +165,7 @@ git commit -m "Team A infra" git push # In the second terminal kubectl get clusters,nodegroup,iamroles,iamrolepolicyattachments,vpcs,securitygroups,subnets,internetgateways,routetables,providerconfigs.helm.crossplane.io,releases # It might take a while until Argo CD detects the changes and the resources appear. -
vfarcic revised this gist
Aug 2, 2021 . 1 changed file with 17 additions and 18 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,14 +23,10 @@ # Setup # ######### # Create a Kuberentes cluster with Ingress # Replace `[...]` with the external IP of the Ingress service export INGRESS_HOST=[...] # Replace `[...]` with the GitHub organization or user export GITHUB_ORG=[...] @@ -65,10 +61,6 @@ cat orig/team-apps.yaml \ | sed -e "s@repoURL: .*@repoURL: $REPO_URL@g" \ | tee orig/team-apps.yaml cat apps.yaml \ | sed -e "s@repoURL: .*@repoURL: $REPO_URL@g" \ | tee apps.yaml @@ -108,13 +100,20 @@ git commit -m "Personalization" git push helm repo add argo \ https://argoproj.github.io/argo-helm helm repo update helm upgrade --install \ argocd argo/argo-cd \ --namespace argocd \ --create-namespace \ --set server.ingress.hosts="{argo-cd.$INGRESS_HOST.nip.io}" \ --set server.ingress.enabled=true \ --set server.extraArgs="{--insecure}" \ --set controller.args.appResyncPeriod=30 \ --wait kubectl apply --filename project.yaml @@ -266,4 +265,4 @@ git commit -m "Revert" git push # Delete the cluster -
vfarcic revised this gist
Aug 2, 2021 . No changes.There are no files selected for viewing
-
vfarcic revised this gist
Aug 2, 2021 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -63,11 +63,11 @@ cat orig/team-app-reqs.yaml \ cat orig/team-apps.yaml \ | sed -e "s@repoURL: .*@repoURL: $REPO_URL@g" \ | tee orig/team-apps.yaml cat argo-cd/overlays/production/ingress.yaml \ | sed -e "s@host: .*@host: argo-cd.$INGRESS_HOST.nip.io@g" \ | tee argo-cd/overlays/production/ingress.yaml cat apps.yaml \ | sed -e "s@repoURL: .*@repoURL: $REPO_URL@g" \ -
vfarcic revised this gist
Aug 2, 2021 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -65,6 +65,10 @@ cat orig/team-apps.yaml \ | sed -e "s@repoURL: .*@repoURL: $REPO_URL@g" \ | tee cat orig/team-apps.yaml cat argo-cd/overlays/production/ingress.yaml \ | sed -e "s@host: .*@host: argo-cd.$INGRESS_HOST.nip.io@g" \ | tee cat argo-cd/overlays/production/ingress.yaml cat apps.yaml \ | sed -e "s@repoURL: .*@repoURL: $REPO_URL@g" \ | tee apps.yaml -
vfarcic revised this gist
Jul 26, 2021 . 1 changed file with 0 additions and 10 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -45,20 +45,10 @@ cd crossplane-kubevela-argocd-demo export REPO_URL=https://github.com/$GITHUB_ORG/crossplane-kubevela-argocd-demo cat production/sealed-secrets.yaml \ | sed -e "s@repoURL: .*@repoURL: $REPO_URL@g" \ | tee production/sealed-secrets.yaml cat production/crossplane.yaml \ | sed -e "s@repoURL: https://github.com.*@repoURL: $REPO_URL@g" \ | tee production/crossplane.yaml -
vfarcic revised this gist
Jul 26, 2021 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -53,6 +53,8 @@ cat production/sealed-secrets.yaml \ | sed -e "s@repoURL: .*@repoURL: $REPO_URL@g" \ | tee production/sealed-secrets.yaml cp orig/argo-cd.yaml production/. cat production/argo-cd.yaml \ | sed -e "s@repoURL: .*@repoURL: $REPO_URL@g" \ | tee production/argo-cd.yaml -
vfarcic revised this gist
Jul 13, 2021 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,9 @@ # Source: https://gist.github.com/6fb3e7da327df9203d9d4c184fcb5831 ############################################################################## # Combining Argo CD (GitOps), Crossplane (Control Plane), And Kubevela (OAM) # # https://youtu.be/eEcgn_gU3SM # ############################################################################## # Referenced videos: # - Argo CD - Applying GitOps Principles To Manage Production Environment In Kubernetes: https://youtu.be/vpWQeoaiRM4 -
vfarcic revised this gist
Jul 13, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # Source: https://gist.github.com/6fb3e7da327df9203d9d4c184fcb5831 ############################################################################ # Making Kubernetes Dissapear With Argo CD, Crossplane, And Kubevela (OAM) # -
vfarcic created this gist
Jul 13, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,273 @@ # Source: TODO: ############################################################################ # Making Kubernetes Dissapear With Argo CD, Crossplane, And Kubevela (OAM) # # https://youtu.be/eEcgn_gU3SM # ############################################################################ # Referenced videos: # - Argo CD - Applying GitOps Principles To Manage Production Environment In Kubernetes: https://youtu.be/vpWQeoaiRM4 # - Cloud-Native Apps With Open Application Model (OAM) And KubeVela: https://youtu.be/2CBu6sOTtwk # - Crossplane - GitOps-based Infrastructure as Code through Kubernetes API: https://youtu.be/n8KjVmuHm7A # - How to apply GitOps to everything - combining Argo CD and Crossplane: https://youtu.be/yrj4lmScKHQ # - How To Shift Left Infrastructure Management Using Crossplane Composites: https://youtu.be/AtbS1u2j7po # - Bitnami Sealed Secrets - How To Store Kubernetes Secrets In Git Repositories: https://youtu.be/xd2QoV6GJlc # - Terraform vs. Pulumi vs. Crossplane - Infrastructure as Code (IaC) Tools Comparison: https://youtu.be/RaoKcJGchKM # - Portainer - Container Management Made Easy: https://youtu.be/-mWUbDHTEkQ # - Ketch - How to Simplify Kubernetes Deployments: https://youtu.be/sMOIiTfGnj0 # - Shipa - A Kubernetes platform from developer's perspective: https://youtu.be/aCwlI3AhNOY # - Flux CD v2 With GitOps Toolkit - Kubernetes Deployment And Sync Mechanism: https://youtu.be/R6OeIgb7lUI # - GitHub CLI - How to manage repositories more efficiently: https://youtu.be/BII6ZY2Rnlc ######### # Setup # ######### # Feel free to use any other Kubernetes distribution minikube start # If not using Minikube, install Ingress in whichever way is suitable for your Kubernetes distribution minikube addons enable ingress # If not using Minikube, replace the value with the IP through which the Ingress Service can be accessed. export INGRESS_HOST=$(minikube ip) # Replace `[...]` with the GitHub organization or user export GITHUB_ORG=[...] # Watch https://youtu.be/BII6ZY2Rnlc if you are not familiar with GitHub CLI gh repo fork vfarcic/crossplane-kubevela-argocd-demo \ --clone cd crossplane-kubevela-argocd-demo # Install Crossplane CLI from https://crossplane.io/docs/v1.3/getting-started/install-configure.html#start-with-a-self-hosted-crossplane export REPO_URL=https://github.com/$GITHUB_ORG/crossplane-kubevela-argocd-demo cat argo-cd/overlays/production/ingress.yaml \ | sed -e "s@host: .*@host: argo-cd.$INGRESS_HOST.nip.io@g" \ | tee argo-cd/overlays/production/ingress.yaml cat production/sealed-secrets.yaml \ | sed -e "s@repoURL: .*@repoURL: $REPO_URL@g" \ | tee production/sealed-secrets.yaml cat production/argo-cd.yaml \ | sed -e "s@repoURL: .*@repoURL: $REPO_URL@g" \ | tee production/argo-cd.yaml cat production/crossplane.yaml \ | sed -e "s@repoURL: https://github.com.*@repoURL: $REPO_URL@g" \ | tee production/crossplane.yaml cat production/team-a-infra.yaml \ | sed -e "s@repoURL: .*@repoURL: $REPO_URL@g" \ | tee production/team-a-infra.yaml cat orig/team-app-reqs.yaml \ | sed -e "s@repoURL: .*@repoURL: $REPO_URL@g" \ | tee orig/team-app-reqs.yaml cat orig/team-apps.yaml \ | sed -e "s@repoURL: .*@repoURL: $REPO_URL@g" \ | tee cat orig/team-apps.yaml cat apps.yaml \ | sed -e "s@repoURL: .*@repoURL: $REPO_URL@g" \ | tee apps.yaml kubectl apply --filename sealed-secrets ############# # Setup AWS # ############# # Replace `[...]` with your access key ID` export AWS_ACCESS_KEY_ID=[...] # Replace `[...]` with your secret access key export AWS_SECRET_ACCESS_KEY=[...] echo "[default] aws_access_key_id = $AWS_ACCESS_KEY_ID aws_secret_access_key = $AWS_SECRET_ACCESS_KEY " | tee aws-creds.conf kubectl --namespace crossplane-system \ create secret generic aws-creds \ --from-file creds=./aws-creds.conf \ --output json \ --dry-run=client \ | kubeseal --format yaml \ | tee crossplane-configs/aws-creds.yaml ################# # Setup Argo CD # ################# git add . git commit -m "Personalization" git push kustomize build \ argo-cd/overlays/production \ | kubectl apply --filename - kubectl --namespace argocd \ rollout status \ deployment argocd-server kubectl apply --filename project.yaml kubectl apply --filename apps.yaml export PASS=$(kubectl \ --namespace argocd \ get secret argocd-initial-admin-secret \ --output jsonpath="{.data.password}" \ | base64 --decode) argocd login \ --insecure \ --username admin \ --password $PASS \ --grpc-web \ argo-cd.$INGRESS_HOST.nip.io argocd account update-password \ --current-password $PASS \ --new-password admin echo http://argo-cd.$INGRESS_HOST.nip.io # Open it in a browser # Use `admin` as both the username and password # Open a second terminal and go to the same directory as in the first ########## # GitOps # ########## # Observe the Argo CD UI and wait until the apps are rolled out ################## # Infrastructure # ################## cat orig/cluster.yaml cp orig/cluster.yaml team-a-infra/. git add . git commit -m "Team A infra" git push # In the second terminal kubectl get clusters,nodegroup,iamroles,iamrolepolicyattachments,vpcs,securitygroups,subnets,internetgateways,routetables,providerconfigs,releases # It might take a while until Argo CD detects the changes and the resources appear. # Wait until all the resources are ready and synced chmod +x config-cluster-aws.sh ./config-cluster-aws.sh team-a ################ # Applications # ################ cat orig/my-app.yaml cp orig/my-app.yaml team-a-apps/. git add . git commit -m "Team A apps" git push # In the second terminal export KUBECONFIG=$PWD/kubeconfig.yaml # In the second terminal kubectl --namespace production \ get all,hpa,ingress ########################## # How did it all happen? # ########################## # In the second terminal cat apps.yaml # In the second terminal ls -1 production # In the second terminal cat production/team-a-infra.yaml # In the second terminal ls -1 team-a-infra # In the second terminal cat crossplane-compositions/definition.yaml # In the second terminal cat crossplane-compositions/cluster-aws.yaml cat team-a-infra/cluster.yaml # In the second terminal cat team-a-app-reqs/kubevela.yaml cat team-a-apps/my-app.yaml # Show Argo CD ########################### # Deleting infrastructure # ########################### rm team-a-infra/cluster.yaml git add . git commit -m "Remove the cluster" git push # In the second terminal unset KUBECONFIG # In the second terminal kubectl get clusters,nodegroup,iamroles,iamrolepolicyattachments,vpcs,securitygroups,subnets,internetgateways,routetables,providerconfigs # Wait until all the resources are removed ########### # Destroy # ########### rm -rf team-a-apps rm -rf team-a-app-reqs rm production/team-a-apps.yaml rm production/team-a-app-reqs.yaml git add . git commit -m "Revert" git push minikube delete