Skip to content

Commit 5140824

Browse files
committed
feat: Updated according to how we discussed it
1 parent bda75cb commit 5140824

File tree

4 files changed

+75
-101
lines changed

4 files changed

+75
-101
lines changed

README.md

Lines changed: 29 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
# Terraform managemen of cert-manager on AKS
1+
# Terraform management of cert-manager on AKS
22

33
## Introduction
44

55
This module manages cert-manager on AKS (Azure Kubernetes Service)
66

7-
## K8S requirements
8-
9-
This module requires Kubernetes >= 1.19, see https://cert-manager.io/docs/installation/helm/#option-2-install-crds-as-part-of-the-helm-release
10-
117
## Usage
128

139
Instantiate the module by calling it from Terraform like this:
@@ -19,17 +15,20 @@ module "azure-basics" {
1915
}
2016
```
2117

22-
2318
<!-- BEGIN_TF_DOCS -->
2419
## Requirements
2520

26-
No requirements.
21+
The following requirements are needed by this module:
22+
23+
- helm (>= 2.4.1)
2724

2825
## Providers
2926

3027
The following providers are used by this module:
3128

32-
- azurerm
29+
- helm (>= 2.4.1)
30+
31+
- kubernetes
3332

3433
## Modules
3534

@@ -39,75 +38,53 @@ No modules.
3938

4039
The following resources are used by this module:
4140

42-
- [azurerm_management_lock.resource-group-level](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/management_lock) (resource)
43-
- [azurerm_proximity_placement_group.ppg](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/proximity_placement_group) (resource)
44-
- [azurerm_resource_group.azure-resource-group](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/resource_group) (resource)
41+
- [helm_release.cert-manager](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) (resource)
42+
- [helm_release.cert-manager-issuers](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) (resource)
43+
- [kubernetes_namespace.cert-manager](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/namespace) (resource)
4544

4645
## Required Inputs
4746

48-
The following input variables are required:
49-
50-
### location
51-
52-
Description: The azure location used for azure
53-
54-
Type: `string`
55-
56-
### project
57-
58-
Description: Three letter project key
59-
60-
Type: `string`
61-
62-
### stage
63-
64-
Description: Stage for this ressource group
65-
66-
Type: `string`
47+
No required inputs.
6748

6849
## Optional Inputs
6950

7051
The following input variables are optional (have default values):
7152

72-
### lock
73-
74-
Description: Lock ressource group for deletion
75-
76-
Type: `bool`
53+
### cert-manager-issuers-version
7754

78-
Default: `true`
55+
Description: Version of the Cert-Manager-issuers helm chart to use
7956

80-
### manage\_proximity\_placement\_group
57+
Type: `string`
8158

82-
Description: Manage a proximity placement group for the resource group
59+
Default: `"0.2.2"`
8360

84-
Type: `bool`
61+
### cert-manager-version
8562

86-
Default: `true`
63+
Description: Version of the Cert-Manager helm chart to use
8764

88-
### tags
65+
Type: `string`
8966

90-
Description: Map of tags for the resources
67+
Default: `"v1.5.4"`
9168

92-
Type: `map(any)`
69+
### cluster-issuers-yaml
9370

94-
Default: `{}`
71+
Description: The YAML code to define cluster issuers for cert-manager. Example: https://github.com/adfinis-sygroup/helm-charts/blob/master/charts/cert-manager-issuers/examples/letsencrypt-clusterissuers.yaml
9572

96-
## Outputs
73+
Type: `string`
9774

98-
The following outputs are exported:
75+
Default: `""`
9976

100-
### location
77+
### issuers-yaml
10178

102-
Description: The location input variable (can be used for dependency resolution)
79+
Description: The YAML code to define issuers for cert-manager. Example: https://github.com/adfinis-sygroup/helm-charts/blob/master/charts/cert-manager-issuers/examples/disable-issuers.yaml
10380

104-
### ppg\_id
81+
Type: `string`
10582

106-
Description: The ID of the generated proximity placement group
83+
Default: `""`
10784

108-
### resource\_group
85+
## Outputs
10986

110-
Description: The name of the generated resource group
87+
No outputs.
11188
<!-- END_TF_DOCS -->
11289

11390
## Development

main.tf

Lines changed: 22 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -6,61 +6,40 @@ resource "kubernetes_namespace" "cert-manager" {
66
}
77
}
88

9-
# documentation: https://cert-manager.io/docs/installation/helm/
9+
# https://artifacthub.io/packages/helm/cert-manager/cert-manager
1010
resource "helm_release" "cert-manager" {
1111
name = "cert-manager"
1212
repository = "https://charts.jetstack.io"
1313
chart = "cert-manager"
14-
version = "v1.5.4"
14+
version = var.cert-manager-version
1515
namespace = kubernetes_namespace.cert-manager.metadata.0.name
1616

1717
set {
18-
name = "installCRDs"
18+
name = "installCRDs"
1919
value = "true"
2020
}
2121
}
2222

23-
resource "helm_release" "cert-manager-clusterissuer" {
24-
name = "cert-manager-clusterissuer"
25-
chart = "../helm-charts/cert-manager-cluster-issuer"
23+
locals {
24+
clusterIssuers = <<EOT
25+
clusterIssuers:
26+
${var.cluster-issuers-yaml}
27+
EOT
28+
issuers = <<EOT
29+
issuers:
30+
${var.issuers-yaml}
31+
EOT
32+
}
2633

27-
set {
28-
name = "letsencryptEmail"
29-
value = var.email
30-
}
34+
# https://artifacthub.io/packages/helm/adfinis/cert-manager-issuers
35+
resource "helm_release" "cert-manager-issuers" {
36+
chart = "cert-manager-issuers"
37+
name = "cert-manager-issuers"
38+
version = var.cert-manager-issuers-version
39+
repository = "https://charts.adfinis.com"
3140

32-
depends_on = [
33-
helm_release.cert-manager,
41+
values = [
42+
var.cluster-issuers-yaml == "" ? "" : local.clusterIssuers,
43+
var.issuers-yaml == "" ? "" : local.issuers
3444
]
3545
}
36-
37-
# TODO: to replaced by helm chart
38-
//
39-
//resource "kubernetes_manifest" "cluster-issuer-prod" {
40-
// manifest = {
41-
// apiVersion = "cert-manager.io/v1alpha2" # TODO, still correct?
42-
// kind = "ClusterIssuer"
43-
// metadata = {
44-
// name = "letsencrypt-prod"
45-
// }
46-
// }
47-
//}
48-
//
49-
//apiVersion: cert-manager.io/v1alpha2
50-
//kind: ClusterIssuer
51-
//metadata:
52-
// name: letsencrypt-prod
53-
//spec:
54-
// acme:
55-
// # The ACME server URL
56-
// server: https://acme-v02.api.letsencrypt.org/directory
57-
// # Email address used for ACME registration
58-
// email: {{ .Values.letsencryptEmail }}
59-
// # Name of a secret used to store the ACME account private key
60-
// privateKeySecretRef:
61-
// name: letsencrypt-prod
62-
// # Enable the HTTP-01 challenge provider
63-
// solvers:
64-
// - http01:
65-
// ingress:
66-
// class: nginx

terraform.tf

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
# setting required because we need helm >= 3.3, see https://cert-manager.io/docs/installation/helm/#option-2-install-crds-as-part-of-the-helm-release
21
terraform {
32
required_providers {
43
helm = {
54
source = "hashicorp/helm"
6-
version = ">= 1.3.1"
5+
version = ">= 2.4.1"
76
}
87
}
9-
}
8+
}

vars.tf

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,23 @@
1-
variable "email" {
2-
type = string
3-
description = "Notification-Address"
1+
variable "cert-manager-version" {
2+
type = string
3+
default = "v1.5.4"
4+
description = "Version of the Cert-Manager helm chart to use"
5+
}
6+
7+
variable "cert-manager-issuers-version" {
8+
type = string
9+
default = "0.2.2"
10+
description = "Version of the Cert-Manager-issuers helm chart to use"
11+
}
12+
13+
variable "issuers-yaml" {
14+
type = string
15+
default = ""
16+
description = "The YAML code to define issuers for cert-manager. Example: https://github.com/adfinis-sygroup/helm-charts/blob/master/charts/cert-manager-issuers/examples/disable-issuers.yaml"
17+
}
18+
19+
variable "cluster-issuers-yaml" {
20+
type = string
21+
default = ""
22+
description = "The YAML code to define cluster issuers for cert-manager. Example: https://github.com/adfinis-sygroup/helm-charts/blob/master/charts/cert-manager-issuers/examples/letsencrypt-clusterissuers.yaml"
423
}

0 commit comments

Comments
 (0)