Skip to content

Instantly share code, notes, and snippets.

@vfarcic
Last active July 20, 2022 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save vfarcic/842c7acf084d45a6c9162f792e1762cd to your computer and use it in GitHub Desktop.
Save vfarcic/842c7acf084d45a6c9162f792e1762cd to your computer and use it in GitHub Desktop.
# Source: https://gist.github.com/842c7acf084d45a6c9162f792e1762cd
#########
# 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=[...]
# Please 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 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
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 Civo #
##############
# Replace `[...]` with your Civo token
export CIVO_TOKEN=[...]
export CIVO_TOKEN_ENCODED=$(\
echo $CIVO_TOKEN | base64)
cat orig/civo-creds.yaml \
| sed -e "s@MY_CREDS@$CIVO_TOKEN_ENCODED@g" \
| kubeseal --format yaml \
| tee crossplane-configs/civo-creds.yaml
#################
# Setup Argo CD #
#################
git add .
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
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
############
# Directly #
############
cat orig/cluster-civo.yaml
kubectl apply \
--filename orig/cluster-civo.yaml
kubectl get civokubernetes
kubectl describe civokubernetes devops-toolkit
# Download Kube config and copy it to the current directory and with the name kubeconfig.yaml
export KUBECONFIG=$PWD/kubeconfig.yaml
kubectl --namespace monitoring get pods
unset KUBECONFIG
kubectl delete \
--filename orig/cluster-civo.yaml
##########
# GitOps #
##########
cat apps.yaml
ls -1 production/
cat orig/cluster.yaml
cp orig/cluster.yaml team-a-infra/.
# Open it in an editor and change `spec.compositionRef.name` to `cluster-civo`
git add .
git commit -m "Team A infra"
git push
kubectl get civokubernetes
# Destroy the node pool
###########
# Destroy #
###########
rm team-a-infra/cluster.yaml
git add .
git commit -m "It's gone"
git push
minikube delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment