Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/int128/terraform-aws-kops-alb
Terraform module for ALB, Route53 and nginx-ingress with kops on AWS
https://github.com/int128/terraform-aws-kops-alb
acm alb aws kops kubernetes nginx-ingress terraform
Last synced: about 1 month ago
JSON representation
Terraform module for ALB, Route53 and nginx-ingress with kops on AWS
- Host: GitHub
- URL: https://github.com/int128/terraform-aws-kops-alb
- Owner: int128
- License: apache-2.0
- Created: 2017-12-11T07:03:00.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2020-07-04T12:48:38.000Z (over 4 years ago)
- Last Synced: 2024-05-02T00:14:56.712Z (6 months ago)
- Topics: acm, alb, aws, kops, kubernetes, nginx-ingress, terraform
- Language: HCL
- Homepage: https://registry.terraform.io/modules/int128/kops-alb
- Size: 430 KB
- Stars: 52
- Watchers: 3
- Forks: 23
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# terraform-aws-kops-alb [![CircleCI](https://circleci.com/gh/int128/terraform-aws-kops-alb.svg?style=shield)](https://circleci.com/gh/int128/terraform-aws-kops-alb)
This is a Terraform module which provides AWS ALB and Route53 for publishing services via nginx-ingress on kops.
It provides the following stack:
![aws-diagram.png](images/aws-diagram.png)
HTTPS requests are transfered to a pod via the external ALB and the node port of nginx-ingress (e.g. tcp/30080).
This is an open source software licensed under Apache License 2.0.
Feel free to bring up issues and pull requests.## Example
Bootstrap a Kubernetes cluster:
```sh
export AWS_DEFAULT_REGION="us-west-2"
export KOPS_CLUSTER_NAME="hello.k8s.local"
kubernetes_ingress_domain="hello.example.com"
state_store_bucket_name="state.hello.k8s.local"# Create a public hosted zone for the domain
aws route53 create-hosted-zone --name "$kubernetes_ingress_domain" --caller-reference "$(date)"# Request a certificate for the wildcard domain
aws acm request-certificate --domain-name "*.$kubernetes_ingress_domain" --validation-method DNS# Create a bucket for the state store of kops and Terraform
aws s3api create-bucket \
--bucket "$state_store_bucket_name" \
--region "$AWS_DEFAULT_REGION" \
--create-bucket-configuration "LocationConstraint=$AWS_DEFAULT_REGION"
aws s3api put-bucket-versioning \
--bucket "$state_store_bucket_name" \
--versioning-configuration "Status=Enabled"# Create a cluster
kops create cluster --name "$KOPS_CLUSTER_NAME" --zones "${AWS_DEFAULT_REGION}a"
kops update cluster --yes
```Load the module:
```hcl
module "kops_alb" {
source = "int128/kops-alb/aws"
kops_cluster_name = "hello.k8s.local"
kubernetes_ingress_domain = "hello.example.com"
}
```Run Terraform and then install nginx-ingress:
```sh
# Create AWS resources
terraform init
terraform apply# Install Helm
kubectl create -f helm-service-account.yaml
helm init --service-account tiller --history-max 100# Install nginx-ingress
helmfile sync
```See [examples](examples) for more.
## Prerequisite
This module assumes the following resources exist:
- Route53 hosted zone of the domain `kubernetes_ingress_domain`
- ACM certificate of the wildcard domain `*.kubernetes_ingress_domain`
- VPC for the cluster `kops_cluster_name`
- Subnets for the cluster `kops_cluster_name`
- Auto scaling group for the nodes of the cluster `kops_cluster_name`
- Security group for the masters of the cluster `kops_cluster_name`
- Security group for the nodes of the cluster `kops_cluster_name`## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| alb\_external\_allow\_ip | List of IP addresses to allow to the external ALB | list | `` | no |
| alb\_internal\_enabled | Enable the internal ALB (needed if the external ALB is not public) | string | `"false"` | no |
| kops\_cluster\_name | Kubernetes cluster name | string | n/a | yes |
| kops\_ig\_nodes\_names | List of name of instance-group nodes managed by kops | list | `` | no |
| kubernetes\_ingress\_domain | Domain name for the external/internal ALB | string | n/a | yes |
| kubernetes\_ingress\_port | Node port of the ingress controller | string | `"30080"` | no |## Outputs
| Name | Description |
|------|-------------|
| kops\_cluster\_name | Kubernetes cluster name |
| kops\_subnet\_ids | IDs of subnets managed by kops |
| kops\_vpc\_id | ID of VPC managed by kops |
| sgid\_allow\_from\_nodes | ID of security group which is allowed from Kubernetes nodes |