Skip to content

Commit d8834ae

Browse files
author
Benjamin P. Jung
committed
Prepare for release of v2.0.0.
Closes #1
1 parent e295fde commit d8834ae

File tree

5 files changed

+60
-53
lines changed

5 files changed

+60
-53
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
[2.0.0] - 2019-08-30
9+
10+
## Updated
11+
12+
- Module has been updated to Terraform 0.12 format. ([#1](https://github.com/iplabs/terraform-kubernetes-alb-ingress-controller/issues/1))
13+
14+
## Changed
15+
16+
- Kubernetes labels have been updated to comply with known best practices.
17+
818
[1.0.0] - 2019-04-12
919

1020
## Added

main.tf

+40-46
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
provider "kubernetes" {
2-
version = "~> 1.5"
3-
}
4-
5-
provider "aws" {
6-
version = "~> 2.6"
7-
}
8-
91
locals {
102
aws_alb_ingress_controller_version = "1.1.2"
113
aws_alb_ingress_controller_docker_image = "docker.io/amazon/aws-alb-ingress-controller:v${local.aws_alb_ingress_controller_version}"
@@ -15,9 +7,9 @@ locals {
157
resource "aws_iam_role" "this" {
168
name = "k8s-${var.k8s_cluster_name}-alb-ingress-controller"
179
description = "Permissions required by the Kubernetes AWS ALB Ingress controller to do it's job."
18-
path = "${var.aws_iam_path_prefix}"
10+
path = var.aws_iam_path_prefix
1911

20-
tags = "${var.aws_tags}"
12+
tags = var.aws_tags
2113

2214
force_detach_policies = true
2315

@@ -35,12 +27,13 @@ resource "aws_iam_role" "this" {
3527
]
3628
}
3729
EOF
30+
3831
}
3932

4033
resource "aws_iam_policy" "this" {
4134
name = "k8s-${var.k8s_cluster_name}-alb-management"
4235
description = "Permissions that are required to manage the AWS Application Load Balancer."
43-
path = "${var.aws_iam_path_prefix}"
36+
path = var.aws_iam_path_prefix
4437

4538
policy = <<EOF
4639
{
@@ -155,21 +148,23 @@ resource "aws_iam_policy" "this" {
155148
]
156149
}
157150
EOF
151+
158152
}
159153

160154
resource "aws_iam_role_policy_attachment" "this" {
161-
policy_arn = "${aws_iam_policy.this.arn}"
162-
role = "${aws_iam_role.this.name}"
155+
policy_arn = aws_iam_policy.this.arn
156+
role = aws_iam_role.this.name
163157
}
164158

165159
resource "kubernetes_service_account" "this" {
160+
automount_service_account_token = true
166161
metadata {
167162
name = "aws-alb-ingress-controller"
168-
namespace = "${var.k8s_namespace}"
163+
namespace = var.k8s_namespace
169164

170-
labels {
171-
"app" = "aws-alb-ingress-controller"
172-
"heritage" = "Terraform"
165+
labels = {
166+
"app.kubernetes.io/name" = "aws-alb-ingress-controller"
167+
"app.kubernetes.io/managed-by" = "terraform"
173168
}
174169
}
175170
}
@@ -178,9 +173,9 @@ resource "kubernetes_cluster_role" "this" {
178173
metadata {
179174
name = "aws-alb-ingress-controller"
180175

181-
labels {
182-
"app" = "aws-alb-ingress-controller"
183-
"heritage" = "Terraform"
176+
labels = {
177+
"app.kubernetes.io/name" = "aws-alb-ingress-controller"
178+
"app.kubernetes.io/managed-by" = "terraform"
184179
}
185180
}
186181

@@ -235,42 +230,40 @@ resource "kubernetes_cluster_role_binding" "this" {
235230
metadata {
236231
name = "aws-alb-ingress-controller"
237232

238-
labels {
239-
"app" = "aws-alb-ingress-controller"
240-
"heritage" = "Terraform"
233+
labels = {
234+
"app.kubernetes.io/name" = "aws-alb-ingress-controller"
235+
"app.kubernetes.io/managed-by" = "terraform"
241236
}
242237
}
243238

244239
role_ref {
245240
api_group = "rbac.authorization.k8s.io"
246241
kind = "ClusterRole"
247-
name = "${kubernetes_cluster_role.this.metadata.0.name}"
242+
name = kubernetes_cluster_role.this.metadata[0].name
248243
}
249244

250245
subject {
251246
api_group = ""
252247
kind = "ServiceAccount"
253-
name = "${kubernetes_service_account.this.metadata.0.name}"
254-
namespace = "${kubernetes_service_account.this.metadata.0.namespace}"
248+
name = kubernetes_service_account.this.metadata[0].name
249+
namespace = kubernetes_service_account.this.metadata[0].namespace
255250
}
256251
}
257252

258253
resource "kubernetes_deployment" "this" {
259-
depends_on = [
260-
"kubernetes_cluster_role_binding.this",
261-
]
254+
depends_on = [kubernetes_cluster_role_binding.this]
262255

263256
metadata {
264257
name = "aws-alb-ingress-controller"
265-
namespace = "${var.k8s_namespace}"
258+
namespace = var.k8s_namespace
266259

267-
labels {
268-
"app" = "aws-alb-ingress-controller"
269-
"version" = "${local.aws_alb_ingress_controller_version}"
270-
"heritage" = "Terraform"
260+
labels = {
261+
"app.kubernetes.io/name" = "aws-alb-ingress-controller"
262+
"app.kubernetes.io/version" = local.aws_alb_ingress_controller_version
263+
"app.kubernetes.io/managed-by" = "terraform"
271264
}
272265

273-
annotations {
266+
annotations = {
274267
"field.cattle.io/description" = "AWS ALB Ingress Controller"
275268
}
276269
}
@@ -279,20 +272,21 @@ resource "kubernetes_deployment" "this" {
279272
replicas = 1
280273

281274
selector {
282-
match_labels {
283-
"name" = "aws-alb-ingress-controller"
275+
match_labels = {
276+
"app.kubernetes.io/name" = "aws-alb-ingress-controller"
284277
}
285278
}
286279

287280
template {
288281
metadata {
289-
labels {
290-
"name" = "aws-alb-ingress-controller"
282+
labels = {
283+
"app.kubernetes.io/name" = "aws-alb-ingress-controller"
284+
"app.kubernetes.io/version" = local.aws_alb_ingress_controller_version
291285
}
292286

293-
annotations {
287+
annotations = {
294288
# Annotation to be used by KIAM
295-
"iam.amazonaws.com/role" = "${aws_iam_role.this.arn}"
289+
"iam.amazonaws.com/role" = aws_iam_role.this.arn
296290
}
297291
}
298292

@@ -302,7 +296,7 @@ resource "kubernetes_deployment" "this" {
302296

303297
container {
304298
name = "server"
305-
image = "${local.aws_alb_ingress_controller_docker_image}"
299+
image = local.aws_alb_ingress_controller_docker_image
306300
image_pull_policy = "Always"
307301
termination_message_path = "/dev/termination-log"
308302

@@ -316,7 +310,7 @@ resource "kubernetes_deployment" "this" {
316310

317311
volume_mount {
318312
mount_path = "/var/run/secrets/kubernetes.io/serviceaccount"
319-
name = "${kubernetes_service_account.this.default_secret_name}"
313+
name = kubernetes_service_account.this.default_secret_name
320314
read_only = true
321315
}
322316

@@ -351,14 +345,14 @@ resource "kubernetes_deployment" "this" {
351345
}
352346

353347
volume {
354-
name = "${kubernetes_service_account.this.default_secret_name}"
348+
name = kubernetes_service_account.this.default_secret_name
355349

356350
secret {
357-
secret_name = "${kubernetes_service_account.this.default_secret_name}"
351+
secret_name = kubernetes_service_account.this.default_secret_name
358352
}
359353
}
360354

361-
service_account_name = "${kubernetes_service_account.this.metadata.0.name}"
355+
service_account_name = kubernetes_service_account.this.metadata[0].name
362356
termination_grace_period_seconds = 60
363357
}
364358
}

outputs.tf

-1
This file was deleted.

variables.tf

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
variable "k8s_cluster_name" {
22
description = "Name of the Kubernetes cluster. This string is used to contruct the AWS IAM permissions and roles."
3-
type = "string"
3+
type = string
44
}
55

66
variable "k8s_namespace" {
@@ -9,20 +9,21 @@ variable "k8s_namespace" {
99
}
1010

1111
variable "aws_iam_path_prefix" {
12-
description = "Prefix to be used for all AWS IAM objects to be created."
13-
type = "string"
12+
description = "Prefix to be used for all AWS IAM objects."
13+
type = string
1414
}
1515

1616
variable "aws_vpc_id" {
17-
type = "string"
17+
type = string
1818
}
1919

2020
variable "aws_region_name" {
21-
type = "string"
21+
type = string
2222
}
2323

2424
variable "aws_tags" {
2525
description = "Common AWS tags to be applied to all AWS objects being created."
26-
type = "map"
26+
type = map(string)
2727
default = {}
2828
}
29+

versions.tf

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
terraform {
2+
required_version = ">= 0.12"
3+
}

0 commit comments

Comments
 (0)