Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@vfarcic
Last active July 20, 2022 10:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save vfarcic/d7f85feebfd9ae2fa442a0248390b0d6 to your computer and use it in GitHub Desktop.
Save vfarcic/d7f85feebfd9ae2fa442a0248390b0d6 to your computer and use it in GitHub Desktop.
# Source: https://gist.github.com/d7f85feebfd9ae2fa442a0248390b0d6
####################
# Create A Cluster #
####################
# Replace `[...]` with the GitHub organization
export GH_ORG=[...]
git clone https://github.com/$GH_ORG/cf-terraform-eks.git
cd cf-terraform-eks
cp orig/codefresh-argocd.yml \
codefresh.yml
# Open `variables.tf` and change the value of `destroy` from `true` to `false`
git add .
git commit -m "Let there be light"
git push
codefresh get builds \
--pipeline-name cf-terraform-eks
# Replace with the ID of the newly created build
export BUILD_ID=[...]
codefresh logs $BUILD_ID -f
###################
# Get Kube Config #
###################
source creds
chmod +x codefresh/get-kubeconfig.sh
./codefresh/get-kubeconfig.sh
export KUBECONFIG=$PWD/kubeconfig.yaml
kubectl get nodes
##########################
# Update Argo CD Ingress #
##########################
export INGRESS_HOSTNAME=$(kubectl \
--namespace ingress-nginx \
get svc ingress-nginx-controller \
--output jsonpath="{.status.loadBalancer.ingress[0].hostname}")
export INGRESS_HOST=$(\
dig +short $INGRESS_HOSTNAME)
echo $INGRESS_HOST
# Repeat the `export` commands if the output is empty
# If the output contains more than one IP, wait for a while longer, and repeat the `export` commands.
# If the output continues having more than one IP, choose one of them and execute `export INGRESS_HOST=[...]` with `[...]` being the selected IP.
export ARGOCD_ADDR=argocd.$INGRESS_HOST.xip.io
cp orig/argocd-values.yaml \
argocd-values.yaml
cat argocd-values.yaml \
| sed -e "s@acme.com@$ARGOCD_ADDR@g" \
| tee argocd-values.yaml
git add .
git commit -m "Changing the Ingress host"
git push
codefresh get builds \
--pipeline-name cf-terraform-eks
# Replace with the ID of the newly created build
export BUILD_ID=[...]
codefresh logs $BUILD_ID -f
###########################
# Update Argo CD Password #
###########################
export PASS=$(kubectl --namespace argocd \
get pods \
--selector app.kubernetes.io/name=argocd-server \
--output name \
| cut -d'/' -f 2)
argocd login \
--insecure \
--username admin \
--password $PASS \
--grpc-web \
argocd.$INGRESS_HOST.xip.io
argocd account update-password \
--current-password $PASS \
--new-password admin
helm upgrade argocd argo/argo-cd \
--namespace argocd \
--reuse-values \
--set controller.args.appResyncPeriod=30
cd ..
#######################
# Destroy The Cluster #
#######################
cd cf-terraform-eks
kubectl --namespace ingress-nginx \
delete service ingress-nginx-controller
# Open `variables.tf` and change the value of `destroy` from `false` to `true`
git add .
git commit -m "Let there be darkness"
git push
cd ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment