Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/readme #14

Merged
merged 8 commits into from
Aug 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 26 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,50 +30,48 @@
|helm_release| A terraform resource to deploy helm charts on kubernetes cluster |

## Inputs
- Availabel Flags for helm command are [here](https://github.com/clouddrove/terraform-helm-eks-addons/blob/master/addons/helm/main.tf#L2-L33).

| Name | Description | Default | Required |
|------|-------------|---------|:--------:|
|metrics_server| Set this to true to install metrics-server helmchart on eks cluster | False | Yes |
|metrics_server_helm_config | Flags for helm command | {values = "addons/metrics-server/config/metrics_server.yaml"} | No |
|cluster_autoscaler| Set this to true to install cluster-autoscaler helmchart on eks cluster | False | Yes |
|cluster_autoscaler_helm_config | Flags for helm command | {values = "addons/cluster-autoscaler/config/cluster_autoscaler.yaml"} | No |
|aws_load_balancer_controller| Set this to true to install aws-load-balancer-controller helmchart on eks cluster | False | Yes |
|aws_load_balancer_controller_helm_config | Flags for helm command | {values = "addons/aws-load-balancer-controller/config/aws_load_balancer_controller.yaml"} | No |
|aws_node_termination_handler| Set this to true to install aws-node-termination-handler helmchart on eks cluster | False | Yes |
|aws_node_termination_handler_helm_config | Flags for helm command | {values = "addons/aws-node-termination-handler/config/aws_node_termination_handler.yaml"} | No |
|aws_efs_csi_driver| Set this to true to install aws-efs-csi-driver helmchart on eks cluster | False | Yes |
|aws_efs_csi_driver_helm_config | Flags for helm command | {values = "addons/aws-efs-csi-driver/config/aws_efs_csi_driver.yaml"} | No |
|aws_ebs_csi_driver| Set this to true to install aws-ebs-csi-driver helmchart on eks cluster | False | Yes |
|aws_ebs_csi_driver_helm_config | Flags for helm command | {values = "addons/aws-ebs-csi-driver/config/aws_ebs_csi_driver.yaml"} | No |
|karpenter| Set this to true to install karpenter helmchart on eks cluster | False | Yes |
|karpenter_helm_config | Flags for helm command | {values = "addons/karpenter/config/karpenter.yaml"} | No |
|calico_tigera| Set this to true to install Calico helmchart on eks cluster | False | Yes |
|calico_tigera_helm_config | Flags for helm command | {values = "addons/calico-tigera/config/calico-tigera-values.yaml"} | No |
|istio_ingress| Set this to true to install Istio-ingress helmchart on eks cluster | False | Yes |
|metrics_server| To install metrics-server helmchart on eks cluster | False | Yes |
|metrics_server_helm_config | option to provide path to override-values.yaml | {values = "addons/metrics-server/config/metrics_server.yaml"} | No |
|cluster_autoscaler| To install cluster-autoscaler helmchart on eks cluster | False | Yes |
|cluster_autoscaler_helm_config | option to provide path to override-values.yaml | {values = "addons/cluster-autoscaler/config/cluster_autoscaler.yaml"} | No |
|aws_load_balancer_controller| To install aws-load-balancer-controller helmchart on eks cluster | False | Yes |
|aws_load_balancer_controller_helm_config | option to provide path to override-values.yaml | {values = "addons/aws-load-balancer-controller/config/aws_load_balancer_controller.yaml"} | No |
|aws_node_termination_handler| To install aws-node-termination-handler helmchart on eks cluster | False | Yes |
|aws_node_termination_handler_helm_config | option to provide path to override-values.yaml | {values = "addons/aws-node-termination-handler/config/aws_node_termination_handler.yaml"} | No |
|aws_efs_csi_driver| To install aws-efs-csi-driver helmchart on eks cluster | False | Yes |
|aws_efs_csi_driver_helm_config | option to provide path to override-values.yaml | {values = "addons/aws-efs-csi-driver/config/aws_efs_csi_driver.yaml"} | No |
|aws_ebs_csi_driver| To install aws-ebs-csi-driver helmchart on eks cluster | False | Yes |
|aws_ebs_csi_driver_helm_config | option to provide path to override-values.yaml | {values = "addons/aws-ebs-csi-driver/config/aws_ebs_csi_driver.yaml"} | No |
|karpenter| To install karpenter helmchart on eks cluster | False | Yes |
|karpenter_helm_config | option to provide path to override-values.yaml | {values = "addons/karpenter/config/karpenter.yaml"} | No |
|calico_tigera| To install Calico helmchart on eks cluster | False | Yes |
|calico_tigera_helm_config | option to provide path to override-values.yaml | {values = "addons/calico-tigera/config/calico-tigera-values.yaml"} | No |
|istio_ingress| To install Istio-ingress helmchart on eks cluster | False | Yes |
|istio_manifests| Kubernetes yaml manifests to create `ingress` and `gateway` with specified `host` | addons/istio-ingress/config/manifest/*.yaml | Yes |
|istio_ingress_helm_config | Flags for helm command | {values = "addons/istio-ingress/config/override-values.yaml"} | No |
|kiali_server| Set this to true to install Kiali Dashboard helmchart on eks cluster | False | Yes |
|istio_ingress_helm_config | option to provide path to override-values.yaml | {values = "addons/istio-ingress/config/override-values.yaml"} | No |
|kiali_server| To install Kiali Dashboard helmchart on eks cluster | False | Yes |
|kiali_manifests| Includes VirtualService manifest file path and flag to install prometheus, grafana & jaeger | kiali_manifests { <br/>kiali_virtualservice_file_path = addons/kiali-server/config/kiali_vs.yaml <br> enable_monitoring = true <br/>}| Yes |
|kiali_server_helm_config | Flags for helm command | {values = "addons/kiali-server/config/kiali_server.yaml"} | No |
|k8s_pod_restart_info_collector| Set this to true to install k8s-pod-restart-info-collector helmchart on eks cluster | False | Yes |
|info_collector_slack_config | Details of slack channel where to send notification | n/a <br/> an example is given [here](https://github.com/clouddrove/terraform-helm-eks-addons/blob/master/_examples/complete/variables.tf#L117-L126) | Yes |

|kiali_server_helm_config | option to provide path to override-values.yaml | {values = "addons/kiali-server/config/kiali_server.yaml"} | No |


## Outputs

No outputs.

## How to Use
- An example of complete usage is given [here](https://github.com/clouddrove/terraform-helm-eks-addons/blob/master/_examples/complete/main.tf#L190-L232) and below also.

- A complete documentation to use `Calico` with AWS EKS is present [here](https://docs.aws.amazon.com/eks/latest/userguide/calico.html)
- An example of usage is given [here](https://github.com/clouddrove/terraform-helm-eks-addons/blob/master/_examples/complete/main.tf#L190-L232) and below also.

- Use below terraform module in your infrastructure's terraform script.

```bash
module "addons" {
source = "clouddrove/eks-addons/aws"
version = "1.3.0"
source = "../../addons"

depends_on = [module.eks.cluster_id]
eks_cluster_name = module.eks.cluster_name

Expand All @@ -83,17 +81,12 @@ module "addons" {
aws_node_termination_handler = true
aws_efs_csi_driver = true
aws_ebs_csi_driver = true
karpenter = false
calico_tigera = false

kiali_server = true
kiali_manifests = var.kiali_manifests

istio_ingress = true
istio_manifests = var.istio_manifests

k8s_pod_restart_info_collector = true
info_collector_slack_config = var.info_collector_slack_config
}

```
Expand All @@ -112,7 +105,7 @@ module "addons" {
```bash
kubectl patch ingress ingressName -n namespace -p '{"metadata":{"finalizers":[]}}' --type=merge
```
4. Now you can run `terraform destroy` for complete destruction.
4. Now you can run `terraform destroy` for complete destruction.

- ### Calico CNI
Our `calico-tigera` addon creates `trigera-operator` and `calico-node` out of which `calico-node` is being created using a manifest (calico-deployment.yaml). This manifest create two serviceAccounts (`calico-cni-plugin` & `calico-node`) which needs to be delete manually as shown below -
Expand Down
1 change: 1 addition & 0 deletions _examples/basic/config/istio/gateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: istio-gateway
namespace: istio-system
spec:
selector:
istio: ingressgateway
Expand Down
2 changes: 1 addition & 1 deletion _examples/basic/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ locals {

tags = {
Example = local.name
GithubRepo = "terraform-aws-vpc"
GithubRepo = "terraform-helm-eks-addons"
GithubOrg = "clouddrove"
}
cluster_version = "1.26"
Expand Down
10 changes: 3 additions & 7 deletions _examples/basic/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,8 @@ data "aws_ami" "eks_default_arm" {

module "addons" {
source = "../../"
#version = "0.0.1"

depends_on = [module.eks.cluster_id]
depends_on = [module.eks.cluster_name]
eks_cluster_name = module.eks.cluster_name

metrics_server = true
Expand All @@ -200,15 +199,12 @@ module "addons" {
aws_node_termination_handler = true
aws_efs_csi_driver = true
aws_ebs_csi_driver = true
karpenter = true
calico_tigera = true
karpenter = false
calico_tigera = false

kiali_server = true
kiali_manifests = var.kiali_manifests

istio_ingress = true
istio_manifests = var.istio_manifests

k8s_pod_restart_info_collector = true
info_collector_slack_config = var.info_collector_slack_config
}
12 changes: 0 additions & 12 deletions _examples/basic/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,3 @@ variable "kiali_manifests" {
enable_monitoring = true
}
}

#---------K8S POD RESTART INFO COLLECTOR ----------
variable "info_collector_slack_config" {
type = object({
slack_webhook_url = string
slack_channel = string
})
default = {
slack_webhook_url = "https://hooks.slack.com/services/XXXXXXXX/XXXXXXXX/xxxxx11111xxxx22222"
slack_channel = "alert"
}
}
1 change: 1 addition & 0 deletions _examples/complete/config/istio/gateway.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: networking.istio.io/v1alpha3
kind: Gateway
metadata:
name: istio-gateway
namespace: istio-system
spec:
selector:
istio: ingressgateway
Expand Down
1 change: 1 addition & 0 deletions _examples/complete/config/kiali/kiali_vs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: kiali
namespace: istio-system
spec:
hosts:
- dash.test.clouddrove.com
Expand Down
21 changes: 21 additions & 0 deletions _examples/complete/config/kiali/override-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## Node affinity for particular node in which labels key is "Infra-Services" and value is "true"
deployment:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "eks.amazonaws.com/nodegroup"
operator: In
values:
- "critical"

## Using limits and requests

resources:
limits:
cpu: 200m
memory: 250Mi
requests:
cpu: 50m
memory: 150Mi
4 changes: 2 additions & 2 deletions _examples/complete/locals.tf
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@

locals {

name = "tf-helm-addons"
name = "tf-helm-2"
region = "us-east-1"

vpc_cidr = "10.0.0.0/16"
azs = slice(data.aws_availability_zones.available.names, 0, 3)

tags = {
Example = local.name
GithubRepo = "terraform-aws-vpc"
GithubRepo = "terraform-helm-eks-addons"
GithubOrg = "clouddrove"
}
cluster_version = "1.26"
Expand Down
66 changes: 29 additions & 37 deletions _examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ module "eks" {
policy_arn = aws_iam_policy.node_additional.arn
}
tags = {
"kubernetes.io/cluster/${module.eks.cluster_name}" = "shared"
"karpenter.sh/discovery" = "${module.eks.cluster_name}"
"kubernetes.io/cluster/${module.eks.cluster_name}" = "shared"
"karpenter.sh/discovery/${module.eks.cluster_name}" = "${module.eks.cluster_name}"
}
}

Expand Down Expand Up @@ -194,40 +194,32 @@ module "addons" {
depends_on = [module.eks.cluster_name]
eks_cluster_name = module.eks.cluster_name

metrics_server = true
metrics_server_helm_config = var.metrics_server_helm_config

cluster_autoscaler = true
cluster_autoscaler_helm_config = var.cluster_autoscaler_helm_config

aws_load_balancer_controller = true
aws_load_balancer_controller_helm_config = var.aws_load_balancer_controller_helm_config

aws_node_termination_handler = true
aws_node_termination_handler_helm_config = var.aws_node_termination_handler_helm_config

aws_efs_csi_driver = true
aws_efs_csi_driver_helm_config = var.aws_efs_csi_driver_helm_config

aws_ebs_csi_driver = true
aws_ebs_csi_driver_helm_config = var.aws_ebs_csi_driver_helm_config

karpenter = true
karpenter_helm_config = var.karpenter_helm_config

calico_tigera = true
calico_tigera_helm_config = var.calico_tigera_helm_config

istio_ingress = true
istio_manifests = var.istio_manifests
istio_ingress_helm_config = var.istio_ingress_helm_config

kiali_server = true
kiali_manifests = var.kiali_manifests
kiali_server_helm_config = var.kiali_server_helm_config

k8s_pod_restart_info_collector = true
info_collector_slack_config = var.info_collector_slack_config

# -- Enable Addons
metrics_server = true
cluster_autoscaler = false
karpenter = false
aws_load_balancer_controller = true
aws_node_termination_handler = true
aws_efs_csi_driver = true
aws_ebs_csi_driver = true
calico_tigera = false

# -- Addons with mandatory variable
istio_ingress = false
istio_manifests = var.istio_manifests
kiali_server = false
kiali_manifests = var.kiali_manifests

# -- Path of override-values.yaml file
metrics_server_helm_config = { values = ["${file("./config/override-metrics-server.yaml")}"] }
cluster_autoscaler_helm_config = { values = ["${file("./config/override-cluster-autoscaler.yaml")}"] }
karpenter_helm_config = { values = ["${file("./config/override-karpenter.yaml")}"] }
aws_load_balancer_controller_helm_config = { values = ["${file("./config/override-aws-load-balancer-controller.yaml")}"] }
aws_node_termination_handler_helm_config = { values = ["${file("./config/override-aws-node-termination-handler.yaml")}"] }
aws_efs_csi_driver_helm_config = { values = ["${file("./config/override-aws-efs-csi-driver.yaml")}"] }
aws_ebs_csi_driver_helm_config = { values = ["${file("./config/override-aws-ebs-csi-driver.yaml")}"] }
calico_tigera_helm_config = { values = ["${file("./config/calico-tigera-values.yaml")}"] }
istio_ingress_helm_config = { values = ["${file("./config/istio/override-values.yaml")}"] }
kiali_server_helm_config = { values = ["${file("./config/kiali/override-values.yaml")}"] }
}

9 changes: 0 additions & 9 deletions _examples/complete/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
# ------------------------------------------------------------------------------
# Outputs
# ------------------------------------------------------------------------------
output "module_path" {
value = path.module
}
output "cwd" {
value = path.cwd
}
output "KUBE_CONFIG_PATH" {
value = "~/.kube/config"
}
26 changes: 19 additions & 7 deletions _examples/complete/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,23 @@ provider "aws" {
provider "kubernetes" {
host = module.eks.cluster_endpoint
cluster_ca_certificate = base64decode(module.eks.cluster_certificate_authority_data)
config_context = module.eks.cluster_arn
config_path = "${path.cwd}/config/kubeconfig"
exec {
api_version = "client.authentication.k8s.io/v1beta1"
args = ["eks", "get-token", "--cluster-name", module.eks.cluster_name]
command = "aws"
token = join("", data.aws_eks_cluster_auth.eks_cluster.*.token)
}

provider "helm" {
kubernetes {
host = module.eks.cluster_endpoint
cluster_ca_certificate = base64decode(module.eks.cluster_certificate_authority_data)
token = join("", data.aws_eks_cluster_auth.eks_cluster.*.token)
}
}
}

provider "kubectl" {
host = module.eks.cluster_endpoint
cluster_ca_certificate = base64decode(module.eks.cluster_certificate_authority_data)
token = join("", data.aws_eks_cluster_auth.eks_cluster.*.token)
}

data "aws_eks_cluster_auth" "eks_cluster" {
name = data.aws_eks_cluster.eks_cluster.id
}
Loading