Skip to content

Commit ce6c875

Browse files
authored
Merge pull request #1 from gitizenme/dev
Initial module implementation
2 parents 2527aeb + 3d82609 commit ce6c875

File tree

16 files changed

+777
-2
lines changed

16 files changed

+777
-2
lines changed

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/.terraform/
2+
*.tfstate*
3+
*.auto.tfvars
4+
.terraform
5+
.terraform/*
6+
terraform.tfvars
7+
terraform.tfvars.example
8+
terraform.tfstate
9+
terraform.tfstate*
10+
kubeconfig-*
11+
ignore.tf

.pre-commit-config.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
repos:
2+
- repo: git://github.com/antonbabenko/pre-commit-terraform
3+
rev: v1.43.0
4+
hooks:
5+
- id: terraform_fmt
6+
- id: terraform_docs
7+
- id: terraform_validate
8+
- id: terraform_tflint

.terraform.lock.hcl

Lines changed: 36 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,52 @@
1-
# terraform-kubernetes-external-dns-aws-istio
2-
Terraform module to deploy and configure k8s external DNS with EKS and Istio
1+
# Kubernetes External DNS for AWS EKS
2+
3+
Terraform module [External DNS with Istio Gateway](https://github.com/kubernetes-sigs/external-dns/blob/master/docs/tutorials/istio.md) for aws.
4+
5+
## Usage
6+
7+
```
8+
module "external-dns-aws" {
9+
source = "gitizenme/external-dns-aws/kubernetes"
10+
version = "1.0.1"
11+
12+
domain = "my-domain.com"
13+
k8s_cluster_name = "cluster-name"
14+
k8s_replicas = 2
15+
hosted_zone_id = "ROUTE53 ZONE ID"
16+
}
17+
```
18+
19+
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
20+
## Requirements
21+
22+
| Name | Version |
23+
|------|---------|
24+
| terraform | >= 0.12 |
25+
26+
## Providers
27+
28+
| Name | Version |
29+
|------|---------|
30+
| aws | n/a |
31+
| kubernetes | n/a |
32+
33+
## Inputs
34+
35+
| Name | Description | Type | Default | Required |
36+
|------|-------------|------|---------|:--------:|
37+
| domain | Domain to add external DNS to | `string` | n/a | yes |
38+
| k8s\_cluster\_name | Current Cluster Name | `string` | n/a | yes |
39+
| hosted\_zone\_id | Route53 Hosted Zone ID | `string` | n/a | yes |
40+
| external\_dns\_version | The AWS External DNS version to use. See https://github.com/kubernetes-sigs/external-dns/releases for available versions | `string` | `"0.7.6"` | no |
41+
| k8s\_cluster\_type | K8s cluster Type | `string` | `"eks"` | no |
42+
| k8s\_namespace | Kubernetes namespace to deploy the AWS External DNS into. | `string` | `"kube-system"` | no |
43+
| k8s\_pod\_labels | Additional labels to be added to the Pods. | `map(string)` | `{}` | no |
44+
| k8s\_replicas | Amount of replicas to be created. | `number` | `1` | no |
45+
46+
## Outputs
47+
48+
| Name | Description |
49+
|------|-------------|
50+
| kubernetes\_deployment | n/a |
51+
52+
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

examples/basic/.terraform.lock.hcl

Lines changed: 110 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/basic/README.md

Whitespace-only changes.

examples/basic/main.tf

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
2+
3+
data "aws_eks_cluster" "cluster" {
4+
name = module.eks.cluster_id
5+
}
6+
7+
data "aws_eks_cluster_auth" "cluster" {
8+
name = module.eks.cluster_id
9+
}
10+
11+
provider "kubernetes" {
12+
host = data.aws_eks_cluster.cluster.endpoint
13+
cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data)
14+
token = data.aws_eks_cluster_auth.cluster.token
15+
}
16+
17+
data "aws_availability_zones" "available" {
18+
}
19+
20+
locals {
21+
cluster_name = "test-eks-${random_string.suffix.result}"
22+
}
23+
24+
resource "random_string" "suffix" {
25+
length = 8
26+
special = false
27+
}
28+
29+
resource "aws_security_group" "worker_group_mgmt_one" {
30+
name_prefix = "worker_group_mgmt_one"
31+
vpc_id = module.vpc.vpc_id
32+
33+
ingress {
34+
from_port = 22
35+
to_port = 22
36+
protocol = "tcp"
37+
38+
cidr_blocks = [
39+
"10.0.0.0/8",
40+
]
41+
}
42+
}
43+
44+
resource "aws_security_group" "worker_group_mgmt_two" {
45+
name_prefix = "worker_group_mgmt_two"
46+
vpc_id = module.vpc.vpc_id
47+
48+
ingress {
49+
from_port = 22
50+
to_port = 22
51+
protocol = "tcp"
52+
53+
cidr_blocks = [
54+
"192.168.0.0/16",
55+
]
56+
}
57+
}
58+
59+
resource "aws_security_group" "all_worker_mgmt" {
60+
name_prefix = "all_worker_management"
61+
vpc_id = module.vpc.vpc_id
62+
63+
ingress {
64+
from_port = 22
65+
to_port = 22
66+
protocol = "tcp"
67+
68+
cidr_blocks = [
69+
"10.0.0.0/8",
70+
"172.16.0.0/12",
71+
"192.168.0.0/16",
72+
]
73+
}
74+
}
75+
76+
module "vpc" {
77+
source = "terraform-aws-modules/vpc/aws"
78+
version = "2.70.0"
79+
80+
name = "test-vpc"
81+
cidr = "10.0.0.0/16"
82+
azs = data.aws_availability_zones.available.names
83+
private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"]
84+
public_subnets = ["10.0.4.0/24", "10.0.5.0/24", "10.0.6.0/24"]
85+
enable_nat_gateway = true
86+
single_nat_gateway = true
87+
enable_dns_hostnames = true
88+
89+
public_subnet_tags = {
90+
"kubernetes.io/cluster/${local.cluster_name}" = "shared"
91+
"kubernetes.io/role/elb" = "1"
92+
}
93+
94+
private_subnet_tags = {
95+
"kubernetes.io/cluster/${local.cluster_name}" = "shared"
96+
"kubernetes.io/role/internal-elb" = "1"
97+
}
98+
}
99+
100+
module "eks" {
101+
source = "terraform-aws-modules/eks/aws"
102+
cluster_name = local.cluster_name
103+
cluster_version = "1.18"
104+
subnets = module.vpc.private_subnets
105+
106+
tags = {
107+
Environment = "test"
108+
GithubRepo = "terraform-aws-eks"
109+
GithubOrg = "terraform-aws-modules"
110+
}
111+
112+
vpc_id = module.vpc.vpc_id
113+
114+
worker_groups = [
115+
{
116+
name = "worker-group-1"
117+
instance_type = "t3.small"
118+
additional_userdata = "echo foo bar"
119+
asg_desired_capacity = 2
120+
},
121+
{
122+
name = "worker-group-2"
123+
instance_type = "t3.medium"
124+
additional_userdata = "echo foo bar"
125+
asg_desired_capacity = 1
126+
},
127+
]
128+
129+
worker_additional_security_group_ids = [aws_security_group.all_worker_mgmt.id]
130+
}
131+
132+
resource "aws_route53_zone" "main" {
133+
name = "my-domain.com"
134+
}
135+
136+
resource "aws_route53_zone" "dev" {
137+
name = "dev.my-domain.com"
138+
139+
tags = {
140+
Environment = "dev"
141+
}
142+
}
143+
144+
resource "aws_route53_record" "dev-ns" {
145+
zone_id = aws_route53_zone.main.zone_id
146+
name = "dev.example.com"
147+
type = "NS"
148+
ttl = "30"
149+
records = aws_route53_zone.dev.name_servers
150+
}
151+
152+
module "external-dns-aws" {
153+
source = "gitizenme/external-dns-aws/kubernetes"
154+
155+
domain = "my-domain.com"
156+
k8s_cluster_name = local.cluster_name
157+
k8s_replicas = 2
158+
hosted_zone_id = aws_route53_zone.main.zone_id
159+
}

0 commit comments

Comments
 (0)