Skip to content

Commit

Permalink
remove environment variables
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Santana <[email protected]>
  • Loading branch information
csantanapr committed Oct 28, 2023
1 parent 642e5c5 commit ffa99f7
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 64 deletions.
33 changes: 15 additions & 18 deletions patterns/gitops/getting-started-argocd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ The output looks like the following:
"aws_load_balancer_controller_service_account": "aws-load-balancer-controller-sa",
"aws_region": "us-west-2",
"aws_vpc_id": "vpc-001d3f00151bbb731",
"cluster_name": "getting-started-gitops",
"cluster_name": "in-cluster",
"environment": "dev",
"workload_repo_basepath": "patterns/gitops/",
"workload_repo_path": "getting-started-argocd/k8s",
"workload_repo_revision": "gitops-bridge-1st-example",
"workload_repo_revision": "main",
"workload_repo_url": "https://github.com/csantanapr/terraform-aws-eks-blueprints"
}
```
Expand All @@ -93,49 +93,46 @@ The output looks like the following:
"enable_argocd": "true",
"enable_aws_load_balancer_controller": "true",
"enable_metrics_server": "true",
"environment": "dev",
"kubernetes_version": "1.28",
}
```

## Access ArgoCD
Access ArgoCD's UI and CLI configuration, on a new Terminal window run the following command
```shell
terraform output -raw configure_argocd
```

## Deploy the Addons
Bootstrap the addons using ArgoCD:
```shell
kubectl apply -f bootstrap/addons.yaml
```

### Monitor GitOps Progress for Addons
Wait until all the ArgoCD applications' `HEALTH STATUS` is `Healthy`. Use Crl+C to exit the `watch` command
```shell
watch kubectl get applications -n argocd \
addon-getting-started-gitops-aws-load-balancer-controller \
addon-getting-started-gitops-metrics-server \
addon-getting-started-gitops-argo-cd
watch kubectl get applications -n argocd
```

## Access ArgoCD
Access ArgoCD's UI, run the command from the output:
```shell
terraform output -raw access_argocd
```
Wait until the ArgoCD Applications `HEALTH STATUS` is `Healthy`. Crl+C to exit the `watch` command

### Verify the Addons
Verify that the addons are ready:
```shell
kubectl get sts,deployment -n argocd
kubectl get deployment -n kube-system \
aws-load-balancer-controller \
metrics-server
```



## Deploy the Workloads
Deploy a sample application located in [k8s/game-2048.yaml](k8s/game-2048.yaml) using ArgoCD:
```shell
kubectl apply -f bootstrap/workloads.yaml
```

### Monitor GitOps Progress for Workloads
Watch the Workloads ArgoCD Application
Watch until the Workloads ArgoCD Application is `Healthy`
```shell
watch kubectl get -n argocd applications workloads
```
Expand All @@ -146,11 +143,11 @@ Verify that the application configuration is present and the pod is running:
```shell
kubectl get -n game-2048 deployments,service,ep,ingress
```
Watch the events for the Ingress, this take a few minutes
Wait until the Ingress/game-2048 `MESSAGE` column value is `Successfully reconciled`. Crl+C to exit the `watch` command
```shell
kubectl events -n game-2048 --for ingress/game-2048 --watch
```
Wait until the Ingress/game-2048 `MESSAGE` column value is `Successfully reconciled`. Crl+C to exit the `watch` command



### Access the Application using AWS Load Balancer
Expand Down
71 changes: 31 additions & 40 deletions patterns/gitops/getting-started-argocd/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ provider "kubernetes" {
}

locals {
name = "getting-started-gitops"
environment = var.environment
region = var.region
name = "getting-started-gitops"
region = var.region

cluster_version = var.kubernetes_version
vpc_cidr = var.vpc_cidr

vpc_cidr = var.vpc_cidr
azs = slice(data.aws_availability_zones.available.names, 0, 3)

gitops_addons_url = "${var.gitops_addons_org}/${var.gitops_addons_repo}"
gitops_addons_basepath = var.gitops_addons_basepath
Expand All @@ -47,7 +49,6 @@ locals {
gitops_workload_path = var.gitops_workload_path
gitops_workload_revision = var.gitops_workload_revision


aws_addons = {
enable_cert_manager = try(var.addons.enable_cert_manager, false)
enable_aws_efs_csi_driver = try(var.addons.enable_aws_efs_csi_driver, false)
Expand Down Expand Up @@ -95,8 +96,7 @@ locals {
local.aws_addons,
local.oss_addons,
{ kubernetes_version = local.cluster_version },
{ aws_cluster_name = module.eks.cluster_name },
{ workloads = "true" }
{ aws_cluster_name = module.eks.cluster_name }
)

addons_metadata = merge(
Expand All @@ -121,17 +121,9 @@ locals {
}
)

argocd_apps = {
# Uncomment to deploy GitOps bootstrap from Terraform, instead of kubectl
# addons = file("${path.module}/bootstrap/addons.yaml")
# workloads = file("${path.module}/bootstrap/workloads.yaml")
}

azs = slice(data.aws_availability_zones.available.names, 0, 3)

tags = {
Blueprint = local.name
GithubRepo = "github.com/csantanapr/terraform-gitops-bridge"
GithubRepo = "github.com/aws-ia/terraform-aws-eks-blueprints"
}
}

Expand All @@ -142,12 +134,9 @@ module "gitops_bridge_bootstrap" {
source = "github.com/gitops-bridge-dev/gitops-bridge-argocd-bootstrap-terraform?ref=v2.0.0"

cluster = {
cluster_name = module.eks.cluster_name
environment = local.environment
metadata = local.addons_metadata
addons = local.addons
metadata = local.addons_metadata
addons = local.addons
}
apps = local.argocd_apps
}

################################################################################
Expand All @@ -166,21 +155,21 @@ module "eks_blueprints_addons" {
create_kubernetes_resources = false

# EKS Blueprints Addons
enable_cert_manager = try(local.aws_addons.enable_cert_manager, false)
enable_aws_efs_csi_driver = try(local.aws_addons.enable_aws_efs_csi_driver, false)
enable_aws_fsx_csi_driver = try(local.aws_addons.enable_aws_fsx_csi_driver, false)
enable_aws_cloudwatch_metrics = try(local.aws_addons.enable_aws_cloudwatch_metrics, false)
enable_aws_privateca_issuer = try(local.aws_addons.enable_aws_privateca_issuer, false)
enable_cluster_autoscaler = try(local.aws_addons.enable_cluster_autoscaler, false)
enable_external_dns = try(local.aws_addons.enable_external_dns, false)
enable_external_secrets = try(local.aws_addons.enable_external_secrets, false)
enable_aws_load_balancer_controller = try(local.aws_addons.enable_aws_load_balancer_controller, false)
enable_fargate_fluentbit = try(local.aws_addons.enable_fargate_fluentbit, false)
enable_aws_for_fluentbit = try(local.aws_addons.enable_aws_for_fluentbit, false)
enable_aws_node_termination_handler = try(local.aws_addons.enable_aws_node_termination_handler, false)
enable_karpenter = try(local.aws_addons.enable_karpenter, false)
enable_velero = try(local.aws_addons.enable_velero, false)
enable_aws_gateway_api_controller = try(local.aws_addons.enable_aws_gateway_api_controller, false)
enable_cert_manager = local.aws_addons.enable_cert_manager
enable_aws_efs_csi_driver = local.aws_addons.enable_aws_efs_csi_driver
enable_aws_fsx_csi_driver = local.aws_addons.enable_aws_fsx_csi_driver
enable_aws_cloudwatch_metrics = local.aws_addons.enable_aws_cloudwatch_metrics
enable_aws_privateca_issuer = local.aws_addons.enable_aws_privateca_issuer
enable_cluster_autoscaler = local.aws_addons.enable_cluster_autoscaler
enable_external_dns = local.aws_addons.enable_external_dns
enable_external_secrets = local.aws_addons.enable_external_secrets
enable_aws_load_balancer_controller = local.aws_addons.enable_aws_load_balancer_controller
enable_fargate_fluentbit = local.aws_addons.enable_fargate_fluentbit
enable_aws_for_fluentbit = local.aws_addons.enable_aws_for_fluentbit
enable_aws_node_termination_handler = local.aws_addons.enable_aws_node_termination_handler
enable_karpenter = local.aws_addons.enable_karpenter
enable_velero = local.aws_addons.enable_velero
enable_aws_gateway_api_controller = local.aws_addons.enable_aws_gateway_api_controller

tags = local.tags
}
Expand All @@ -203,15 +192,17 @@ module "eks" {

eks_managed_node_groups = {
initial = {
instance_types = ["t3.medium"]
instance_types = ["m5.large"]

min_size = 3
max_size = 10
desired_size = 3
min_size = 1
max_size = 3
desired_size = 2
}
}
# EKS Addons
cluster_addons = {
coredns = {}
kube-proxy = {}
vpc-cni = {
# Specify the VPC CNI addon should be deployed before compute to ensure
# the addon is configured before data plane compute resources are created
Expand Down
2 changes: 1 addition & 1 deletion patterns/gitops/getting-started-argocd/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ output "access_argocd" {
value = <<-EOT
export KUBECONFIG="/tmp/${module.eks.cluster_name}"
aws eks --region ${local.region} update-kubeconfig --name ${module.eks.cluster_name}
echo "ArgoCD URL: https://$(kubectl get svc -n argocd argo-cd-argocd-server -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')"
echo "ArgoCD Username: admin"
echo "ArgoCD Password: $(kubectl get secrets argocd-initial-admin-secret -n argocd --template="{{index .data.password | base64decode}}")"
echo "ArgoCD URL: https://$(kubectl get svc -n argocd argo-cd-argocd-server -o jsonpath='{.status.loadBalancer.ingress[0].hostname}')"
EOT
}
5 changes: 0 additions & 5 deletions patterns/gitops/getting-started-argocd/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ variable "kubernetes_version" {
type = string
default = "1.28"
}
variable "environment" {
description = "Kubernetes environment"
type = string
default = "dev"
}
variable "addons" {
description = "Kubernetes addons"
type = any
Expand Down

0 comments on commit ffa99f7

Please sign in to comment.