Last active
January 18, 2022 00:24
-
-
Save vfarcic/fc32da271b7648e3db6e040401353cc5 to your computer and use it in GitHub Desktop.
This file contains 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 characters
# Source: https://gist.github.com/fc32da271b7648e3db6e040401353cc5 | |
#################### | |
# Create A Cluster # | |
#################### | |
# TODO: Link to the article that explains how to create the cluster and install Argo CD | |
# Replace `[...]` with the GitHub organization | |
export GH_ORG=[...] | |
git clone https://github.com/$GH_ORG/cf-terraform-eks.git | |
cd cf-terraform-eks | |
# 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 | |
terraform init | |
chmod +x get-kubeconfig.sh | |
./get-kubeconfig.sh \ | |
$(terraform output cluster_name) \ | |
$(terraform output region) | |
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 ARGO_ADDR=argocd.$INGRESS_HOST.xip.io | |
cp orig/argocd-values.yaml \ | |
argocd-values.yaml | |
cat argocd-values.yaml \ | |
| sed -e "s@acme.com@$ARGO_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 | |
echo $PASS | |
# Use the output of the previous command to `enter current password`. | |
argocd account update-password | |
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