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

Add calico to Kubernetes addon #885

Merged
merged 9 commits into from
Aug 27, 2022
Merged
Show file tree
Hide file tree
Changes from 7 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
39 changes: 39 additions & 0 deletions docs/add-ons/calico.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Calico

Calico is a widely adopted, battle-tested open source networking and network security solution for Kubernetes, virtual machines, and bare-metal workloads
Calico provides two major services for Cloud Native applications: network connectivity between workloads and network security policy enforcement between workloads.
[Calico](https://projectcalico.docs.tigera.io/getting-started/kubernetes/helm#download-the-helm-chart) docs chart bootstraps Calico infrastructure on a Kubernetes cluster using the Helm package manager.

For complete project documentation, please visit the [Calico documentation site](https://www.tigera.io/calico-documentation/).

## Usage

Calico can be deployed by enabling the add-on via the following.

```hcl
enable_calico = true
```

Deploy Calico with custom `values.yaml`

```hcl
# Optional Map value; pass calico-values.yaml from consumer module
calico_helm_config = {
name = "calico" # (Required) Release name.
repository = "https://projectcalico.docs.tigera.io/charts" # (Optional) Repository URL where to locate the requested chart.
chart = "calico" # (Required) Chart name to be installed.
florentio marked this conversation as resolved.
Show resolved Hide resolved
version = "v3.24.0" # (Optional) Specify the exact chart version to install. If this is not specified, it defaults to the version set within default_helm_config: https://github.com/aws-ia/terraform-aws-eks-blueprints/blob/main/modules/kubernetes-addons/calico/locals.tf
namespace = "tigera-operator" # (Optional) The namespace to install the release into.
values = [templatefile("${path.module}/calico-values.yaml", {})]
}
```

### GitOps Configuration

The following properties are made available for use when managing the add-on via GitOps.

```sh
calico = {
enable = true
}
```
1 change: 1 addition & 0 deletions examples/grafana-loki/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ module "eks_blueprints_kubernetes_addons" {
eks_cluster_version = module.eks_blueprints.eks_cluster_version

enable_promtail = true
enable_calico = true

tags = local.tags
}
Expand Down
3 changes: 3 additions & 0 deletions modules/kubernetes-addons/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
| <a name="module_aws_node_termination_handler"></a> [aws\_node\_termination\_handler](#module\_aws\_node\_termination\_handler) | ./aws-node-termination-handler | n/a |
| <a name="module_aws_privateca_issuer"></a> [aws\_privateca\_issuer](#module\_aws\_privateca\_issuer) | ./aws-privateca-issuer | n/a |
| <a name="module_aws_vpc_cni"></a> [aws\_vpc\_cni](#module\_aws\_vpc\_cni) | ./aws-vpc-cni | n/a |
| <a name="module_calico"></a> [calico](#module\_calico) | ./calico | n/a |
| <a name="module_cert_manager"></a> [cert\_manager](#module\_cert\_manager) | ./cert-manager | n/a |
| <a name="module_cluster_autoscaler"></a> [cluster\_autoscaler](#module\_cluster\_autoscaler) | ./cluster-autoscaler | n/a |
| <a name="module_coredns_autoscaler"></a> [coredns\_autoscaler](#module\_coredns\_autoscaler) | ./cluster-proportional-autoscaler | n/a |
Expand Down Expand Up @@ -115,6 +116,7 @@
| <a name="input_aws_privateca_acmca_arn"></a> [aws\_privateca\_acmca\_arn](#input\_aws\_privateca\_acmca\_arn) | ARN of AWS ACM PCA | `string` | `""` | no |
| <a name="input_aws_privateca_issuer_helm_config"></a> [aws\_privateca\_issuer\_helm\_config](#input\_aws\_privateca\_issuer\_helm\_config) | PCA Issuer Helm Chart config | `any` | `{}` | no |
| <a name="input_aws_privateca_issuer_irsa_policies"></a> [aws\_privateca\_issuer\_irsa\_policies](#input\_aws\_privateca\_issuer\_irsa\_policies) | IAM policy ARNs for AWS ACM PCA IRSA | `list(string)` | `[]` | no |
| <a name="input_calico_helm_config"></a> [calico\_helm\_config](#input\_calico\_helm\_config) | Calico add-on config | `any` | `{}` | no |
| <a name="input_cert_manager_domain_names"></a> [cert\_manager\_domain\_names](#input\_cert\_manager\_domain\_names) | Domain names of the Route53 hosted zone to use with cert-manager | `list(string)` | `[]` | no |
| <a name="input_cert_manager_helm_config"></a> [cert\_manager\_helm\_config](#input\_cert\_manager\_helm\_config) | Cert Manager Helm Chart config | `any` | `{}` | no |
| <a name="input_cert_manager_install_letsencrypt_issuers"></a> [cert\_manager\_install\_letsencrypt\_issuers](#input\_cert\_manager\_install\_letsencrypt\_issuers) | Install Let's Encrypt Cluster Issuers | `bool` | `true` | no |
Expand Down Expand Up @@ -154,6 +156,7 @@
| <a name="input_enable_aws_load_balancer_controller"></a> [enable\_aws\_load\_balancer\_controller](#input\_enable\_aws\_load\_balancer\_controller) | Enable AWS Load Balancer Controller add-on | `bool` | `false` | no |
| <a name="input_enable_aws_node_termination_handler"></a> [enable\_aws\_node\_termination\_handler](#input\_enable\_aws\_node\_termination\_handler) | Enable AWS Node Termination Handler add-on | `bool` | `false` | no |
| <a name="input_enable_aws_privateca_issuer"></a> [enable\_aws\_privateca\_issuer](#input\_enable\_aws\_privateca\_issuer) | Enable PCA Issuer | `bool` | `false` | no |
| <a name="input_enable_calico"></a> [enable\_calico](#input\_enable\_calico) | Enable Calico add-on | `bool` | `false` | no |
| <a name="input_enable_cert_manager"></a> [enable\_cert\_manager](#input\_enable\_cert\_manager) | Enable Cert Manager add-on | `bool` | `false` | no |
| <a name="input_enable_cluster_autoscaler"></a> [enable\_cluster\_autoscaler](#input\_enable\_cluster\_autoscaler) | Enable Cluster autoscaler add-on | `bool` | `false` | no |
| <a name="input_enable_coredns_autoscaler"></a> [enable\_coredns\_autoscaler](#input\_enable\_coredns\_autoscaler) | Enable CoreDNS autoscaler add-on | `bool` | `false` | no |
Expand Down
42 changes: 42 additions & 0 deletions modules/kubernetes-addons/calico/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Calico Helm Chart
Calico is a widely adopted, battle-tested open source networking and network security solution for Kubernetes, virtual machines, and bare-metal workloads.

For more details checkout [calico](https://projectcalico.docs.tigera.io/getting-started/kubernetes/helm#download-the-helm-chart) docs

<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.72 |
| <a name="requirement_kubernetes"></a> [kubernetes](#requirement\_kubernetes) | >= 2.10 |

## Providers

No providers.

## Modules

| Name | Source | Version |
|------|--------|---------|
| <a name="module_helm_addon"></a> [helm\_addon](#module\_helm\_addon) | ../helm-addon | n/a |

## Resources

No resources.

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_addon_context"></a> [addon\_context](#input\_addon\_context) | Input configuration for the addon | <pre>object({<br> aws_caller_identity_account_id = string<br> aws_caller_identity_arn = string<br> aws_eks_cluster_endpoint = string<br> aws_partition_id = string<br> aws_region_name = string<br> eks_cluster_id = string<br> eks_oidc_issuer_url = string<br> eks_oidc_provider_arn = string<br> tags = map(string)<br> irsa_iam_role_path = string<br> irsa_iam_permissions_boundary = string<br> })</pre> | n/a | yes |
| <a name="input_helm_config"></a> [helm\_config](#input\_helm\_config) | Helm Config for calico | `any` | `{}` | no |
| <a name="input_manage_via_gitops"></a> [manage\_via\_gitops](#input\_manage\_via\_gitops) | Determines if the add-on should be managed via GitOps. | `bool` | `false` | no |

## Outputs

| Name | Description |
|------|-------------|
| <a name="output_argocd_gitops_config"></a> [argocd\_gitops\_config](#output\_argocd\_gitops\_config) | Configuration used for managing the add-on with ArgoCD |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
26 changes: 26 additions & 0 deletions modules/kubernetes-addons/calico/locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
locals {
name = "calico"
default_helm_config = {
name = local.name
chart = local.name
florentio marked this conversation as resolved.
Show resolved Hide resolved
repository = "https://projectcalico.docs.tigera.io/charts"
version = "v3.24.0"
florentio marked this conversation as resolved.
Show resolved Hide resolved
namespace = "tigera-operator"
values = local.default_helm_values
create_namespace = true
description = "calico helm Chart deployment configuration"
}

helm_config = merge(
local.default_helm_config,
var.helm_config
)

default_helm_values = [templatefile("${path.module}/values.yaml", {
aws_region = var.addon_context.aws_region_name
})]

argocd_gitops_config = {
enable = true
}
}
6 changes: 6 additions & 0 deletions modules/kubernetes-addons/calico/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module "helm_addon" {
source = "../helm-addon"
helm_config = local.helm_config
manage_via_gitops = var.manage_via_gitops
addon_context = var.addon_context
}
4 changes: 4 additions & 0 deletions modules/kubernetes-addons/calico/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
output "argocd_gitops_config" {
description = "Configuration used for managing the add-on with ArgoCD"
value = var.manage_via_gitops ? local.argocd_gitops_config : null
}
2 changes: 2 additions & 0 deletions modules/kubernetes-addons/calico/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
installation:
kubernetesProvider: "EKS"
28 changes: 28 additions & 0 deletions modules/kubernetes-addons/calico/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
variable "helm_config" {
florentio marked this conversation as resolved.
Show resolved Hide resolved
description = "Helm Config for calico"
type = any
default = {}
}

variable "manage_via_gitops" {
description = "Determines if the add-on should be managed via GitOps."
type = bool
default = false
}

variable "addon_context" {
description = "Input configuration for the addon"
type = object({
florentio marked this conversation as resolved.
Show resolved Hide resolved
aws_caller_identity_account_id = string
aws_caller_identity_arn = string
aws_eks_cluster_endpoint = string
aws_partition_id = string
aws_region_name = string
eks_cluster_id = string
eks_oidc_issuer_url = string
eks_oidc_provider_arn = string
tags = map(string)
irsa_iam_role_path = string
irsa_iam_permissions_boundary = string
})
}
14 changes: 14 additions & 0 deletions modules/kubernetes-addons/calico/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
terraform {
required_version = ">= 1.0.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.72"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = ">= 2.10"
}
}
}
1 change: 1 addition & 0 deletions modules/kubernetes-addons/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ locals {
externalDns = var.enable_external_dns ? module.external_dns[0].argocd_gitops_config : null
velero = var.enable_velero ? module.velero[0].argocd_gitops_config : null
promtail = var.enable_promtail ? module.promtail[0].argocd_gitops_config : null
calico = var.enable_calico ? module.calico[0].argocd_gitops_config : null
}

addon_context = {
Expand Down
8 changes: 8 additions & 0 deletions modules/kubernetes-addons/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -506,3 +506,11 @@ module "promtail" {
manage_via_gitops = var.argocd_manage_add_ons
addon_context = local.addon_context
}

module "calico" {
count = var.enable_calico ? 1 : 0
source = "./calico"
helm_config = var.calico_helm_config
manage_via_gitops = var.argocd_manage_add_ons
addon_context = local.addon_context
}
13 changes: 13 additions & 0 deletions modules/kubernetes-addons/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -1039,3 +1039,16 @@ variable "promtail_helm_config" {
type = any
default = {}
}

#-----------Calico ADDON-------------
variable "enable_calico" {
description = "Enable Calico add-on"
type = bool
default = false
}

variable "calico_helm_config" {
description = "Calico add-on config"
type = any
default = {}
}