From 02d63f851952f18c28a0f45d544564d6d36953da Mon Sep 17 00:00:00 2001 From: Carlos Santana Date: Fri, 27 Oct 2023 00:38:25 -0400 Subject: [PATCH] fix ingress Signed-off-by: Carlos Santana --- .../gitops/getting-started-argocd/README.md | 45 +++++++++++++++++-- .../bootstrap/addons.yaml | 2 + .../bootstrap/workloads.yaml | 2 +- .../gitops/getting-started-argocd/destroy.sh | 19 +++++--- .../getting-started-argocd/k8s/game-2048.yaml | 6 +-- .../gitops/getting-started-argocd/main.tf | 2 +- .../getting-started-argocd/variables.tf | 1 + 7 files changed, 62 insertions(+), 15 deletions(-) diff --git a/patterns/gitops/getting-started-argocd/README.md b/patterns/gitops/getting-started-argocd/README.md index ab3e22f209..083adf2565 100644 --- a/patterns/gitops/getting-started-argocd/README.md +++ b/patterns/gitops/getting-started-argocd/README.md @@ -8,13 +8,52 @@ terraform init terraform apply ``` -Access Terraform output to configure `kubectl` and `argocd` +Get `kubectl` config, and run the output ```shell -terraform output +terraform output -raw configure_kubectl +``` + +Deploy Addons using ArgoCD +```shell +kubectl apply -f bootstrap/addons.yaml +``` +Verify Addons are ready +```shell +kubectl get applications -n argocd \ + addon-getting-started-gitops-aws-load-balancer-controller \ + addon-getting-started-gitops-metrics-server +kubectl get deployment -n kube-system \ + aws-load-balancer-controller \ + metrics-server +``` + +Get ArgoCD UI and CLI access configuration, and run the output in a new terminal window +```shell +terraform output -raw configure_argocd +``` + +Deploy Sample Application +```shell +kubectl apply -f bootstrap/workloads.yaml +``` +Verify Application is ready +```shell +kubectl get -n argocd applications workloads +kubectl get -n game-2048 deployments +kubectl get -n game-2048 deployments +kubectl get -n game-2048 ingress +``` + +Get the Ingress URL for the Application +```shell +kubectl get ingress +``` +Verify Application on the Browser or Terminal +```shell +curl ... ``` Destroy EKS Cluster ```shell -cd hub ./destroy.sh ``` diff --git a/patterns/gitops/getting-started-argocd/bootstrap/addons.yaml b/patterns/gitops/getting-started-argocd/bootstrap/addons.yaml index 286d49c696..58bd8c2344 100644 --- a/patterns/gitops/getting-started-argocd/bootstrap/addons.yaml +++ b/patterns/gitops/getting-started-argocd/bootstrap/addons.yaml @@ -17,6 +17,8 @@ spec: repoURL: '{{metadata.annotations.addons_repo_url}}' path: '{{metadata.annotations.addons_repo_basepath}}{{metadata.annotations.addons_repo_path}}' targetRevision: '{{metadata.annotations.addons_repo_revision}}' + directory: + recurse: true destination: namespace: argocd name: '{{name}}' diff --git a/patterns/gitops/getting-started-argocd/bootstrap/workloads.yaml b/patterns/gitops/getting-started-argocd/bootstrap/workloads.yaml index 7ae1fe43d0..8c883ea346 100644 --- a/patterns/gitops/getting-started-argocd/bootstrap/workloads.yaml +++ b/patterns/gitops/getting-started-argocd/bootstrap/workloads.yaml @@ -10,7 +10,7 @@ spec: - clusters: {} template: metadata: - name: workload + name: workloads finalizers: # This finalizer is for demo purposes, in production remove apps using argocd CLI "argocd app delete workload --cascade" # When you invoke argocd app delete with --cascade, the finalizer is added automatically. diff --git a/patterns/gitops/getting-started-argocd/destroy.sh b/patterns/gitops/getting-started-argocd/destroy.sh index 195f9885a5..9fae53e59c 100755 --- a/patterns/gitops/getting-started-argocd/destroy.sh +++ b/patterns/gitops/getting-started-argocd/destroy.sh @@ -1,13 +1,22 @@ #!/bin/bash -set -x +set -euo pipefail + +SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +ROOTDIR="$(cd ${SCRIPTDIR}/../..; pwd )" +[[ -n "${DEBUG:-}" ]] && set -x # Delete the Ingress/SVC before removing the addons TMPFILE=$(mktemp) -terraform output -raw configure_kubectl > "$TMPFILE" -source "$TMPFILE" - -kubectl delete svc -n argocd argo-cd-argocd-server +terraform -chdir=$SCRIPTDIR output -raw configure_kubectl > "$TMPFILE" +# check if TMPFILE contains the string "No outputs found" +if [[ ! $(cat $TMPFILE) == *"No outputs found"* ]]; then + source "$TMPFILE" + kubectl delete -n argocd applicationset workloads + kubectl delete -n argocd applicationset cluster-addons + kubectl delete -n argocd application addon-dev-argo-cd + kubectl delete -n argocd svc argo-cd-argocd-server +fi terraform destroy -target="module.gitops_bridge_bootstrap" -auto-approve terraform destroy -target="module.eks_blueprints_addons" -auto-approve diff --git a/patterns/gitops/getting-started-argocd/k8s/game-2048.yaml b/patterns/gitops/getting-started-argocd/k8s/game-2048.yaml index 0b2a860582..3dea1dd872 100644 --- a/patterns/gitops/getting-started-argocd/k8s/game-2048.yaml +++ b/patterns/gitops/getting-started-argocd/k8s/game-2048.yaml @@ -46,9 +46,7 @@ metadata: namespace: game-2048 name: ingress-2048 annotations: - alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS":443}]' alb.ingress.kubernetes.io/scheme: internet-facing - alb.ingress.kubernetes.io/ssl-redirect: '443' alb.ingress.kubernetes.io/target-type: ip spec: ingressClassName: alb @@ -61,6 +59,4 @@ spec: service: name: service-2048 port: - number: 80 - tls: - - hosts: [] \ No newline at end of file + name: http \ No newline at end of file diff --git a/patterns/gitops/getting-started-argocd/main.tf b/patterns/gitops/getting-started-argocd/main.tf index f47455a7aa..e189be2165 100644 --- a/patterns/gitops/getting-started-argocd/main.tf +++ b/patterns/gitops/getting-started-argocd/main.tf @@ -76,7 +76,7 @@ locals { enable_ack_eventbridge = try(var.addons.enable_ack_eventbridge, false) } oss_addons = { - enable_argocd = try(var.addons.enable_argocd, false) + enable_argocd = try(var.addons.enable_argocd, true) enable_argo_rollouts = try(var.addons.enable_argo_rollouts, false) enable_argo_events = try(var.addons.enable_argo_events, false) enable_argo_workflows = try(var.addons.enable_argo_workflows, false) diff --git a/patterns/gitops/getting-started-argocd/variables.tf b/patterns/gitops/getting-started-argocd/variables.tf index 53b75b5731..c2b31f65e2 100644 --- a/patterns/gitops/getting-started-argocd/variables.tf +++ b/patterns/gitops/getting-started-argocd/variables.tf @@ -11,6 +11,7 @@ variable "region" { variable "kubernetes_version" { description = "Kubernetes version" type = string + default = "1.28" } variable "environment" { description = "Kubernetes environment"