Skip to content

Commit

Permalink
feat: add KinD module (#31)
Browse files Browse the repository at this point in the history
* refactor(Kind)!: rename module, change service config and output LB IP

* docs(terraform-docs): generate docs and write to README.adoc

* chore: terraform fmt

* revert: restore nodeport variant

* fix: nodeport doc

* docs(terraform-docs): generate docs and write to README.adoc

---------

Co-authored-by: modridi <[email protected]>
Co-authored-by: Gonçalo Heleno <[email protected]>

Release-As: v1.0.0-alpha.9
  • Loading branch information
modridi authored Feb 22, 2023
1 parent 2ef67fd commit 7cbafa7
Show file tree
Hide file tree
Showing 6 changed files with 277 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/terraform-docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ jobs:
terraform-docs:
uses: camptocamp/devops-stack/.github/workflows/modules-terraform-docs.yaml@master
with:
variants: "aks,eks,nodeport,scaleway,sks"
variants: "aks,eks,kind,nodeport,scaleway,sks"
232 changes: 232 additions & 0 deletions kind/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
// BEGIN_TF_DOCS
=== Requirements

No requirements.

=== Providers

The following providers are used by this module:

- [[provider_kubernetes]] <<provider_kubernetes,kubernetes>>

=== Modules

The following Modules are called:

==== [[module_traefik]] <<module_traefik,traefik>>

Source: ../

Version:

=== Resources

The following resources are used by this module:

- https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/data-sources/service[kubernetes_service.traefik] (data source)

=== Required Inputs

The following input variables are required:

==== [[input_argocd_namespace]] <<input_argocd_namespace,argocd_namespace>>

Description: n/a

Type: `string`

==== [[input_base_domain]] <<input_base_domain,base_domain>>

Description: n/a

Type: `string`

==== [[input_cluster_name]] <<input_cluster_name,cluster_name>>

Description: n/a

Type: `string`

=== Optional Inputs

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

==== [[input_app_autosync]] <<input_app_autosync,app_autosync>>

Description: Automated sync options for the Argo CD Application resource.

Type:
[source,hcl]
----
object({
allow_empty = optional(bool)
prune = optional(bool)
self_heal = optional(bool)
})
----

Default:
[source,json]
----
{
"allow_empty": false,
"prune": true,
"self_heal": true
}
----

==== [[input_dependency_ids]] <<input_dependency_ids,dependency_ids>>

Description: n/a

Type: `map(string)`

Default: `{}`

==== [[input_helm_values]] <<input_helm_values,helm_values>>

Description: Helm values, passed as a list of HCL structures.

Type: `any`

Default: `[]`

==== [[input_namespace]] <<input_namespace,namespace>>

Description: n/a

Type: `string`

Default: `"traefik"`

==== [[input_target_revision]] <<input_target_revision,target_revision>>

Description: Override of target revision of the application chart.

Type: `string`

Default: `"v1.0.0-alpha.6"`

=== Outputs

The following outputs are exported:

==== [[output_external_ip]] <<output_external_ip,external_ip>>

Description: External IP address of Traefik LB service.

==== [[output_id]] <<output_id,id>>

Description: n/a
// END_TF_DOCS
// BEGIN_TF_TABLES


= Providers

[cols="a,a",options="header,autowidth"]
|===
|Name |Version
|[[provider_kubernetes]] <<provider_kubernetes,kubernetes>> |n/a
|===

= Modules

[cols="a,a,a",options="header,autowidth"]
|===
|Name |Source |Version
|[[module_traefik]] <<module_traefik,traefik>> |../ |
|===

= Resources

[cols="a,a",options="header,autowidth"]
|===
|Name |Type
|https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/data-sources/service[kubernetes_service.traefik] |data source
|===

= Inputs

[cols="a,a,a,a,a",options="header,autowidth"]
|===
|Name |Description |Type |Default |Required
|[[input_app_autosync]] <<input_app_autosync,app_autosync>>
|Automated sync options for the Argo CD Application resource.
|

[source]
----
object({
allow_empty = optional(bool)
prune = optional(bool)
self_heal = optional(bool)
})
----

|

[source]
----
{
"allow_empty": false,
"prune": true,
"self_heal": true
}
----

|no

|[[input_argocd_namespace]] <<input_argocd_namespace,argocd_namespace>>
|n/a
|`string`
|n/a
|yes

|[[input_base_domain]] <<input_base_domain,base_domain>>
|n/a
|`string`
|n/a
|yes

|[[input_cluster_name]] <<input_cluster_name,cluster_name>>
|n/a
|`string`
|n/a
|yes

|[[input_dependency_ids]] <<input_dependency_ids,dependency_ids>>
|n/a
|`map(string)`
|`{}`
|no

|[[input_helm_values]] <<input_helm_values,helm_values>>
|Helm values, passed as a list of HCL structures.
|`any`
|`[]`
|no

|[[input_namespace]] <<input_namespace,namespace>>
|n/a
|`string`
|`"traefik"`
|no

|[[input_target_revision]] <<input_target_revision,target_revision>>
|Override of target revision of the application chart.
|`string`
|`"v1.0.0-alpha.6"`
|no

|===

= Outputs

[cols="a,a",options="header,autowidth"]
|===
|Name |Description
|[[output_external_ip]] <<output_external_ip,external_ip>> |External IP address of Traefik LB service.
|[[output_id]] <<output_id,id>> |n/a
|===
// END_TF_TABLES
9 changes: 9 additions & 0 deletions kind/local.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
locals {
helm_values = [{
traefik = {
# fullnameOverride is used to set the service name in traefik data source.
# TODO check further if setting this value is necessary.
fullnameOverride = "traefik"
}
}]
}
26 changes: 26 additions & 0 deletions kind/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module "traefik" {
source = "../"

cluster_name = var.cluster_name
base_domain = var.base_domain
argocd_namespace = var.argocd_namespace

target_revision = var.target_revision
namespace = var.namespace
app_autosync = var.app_autosync

helm_values = concat(local.helm_values, var.helm_values)

dependency_ids = var.dependency_ids
}

data "kubernetes_service" "traefik" {
metadata {
name = local.helm_values.0.traefik.fullnameOverride
namespace = var.namespace
}

depends_on = [
module.traefik
]
}
8 changes: 8 additions & 0 deletions kind/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
output "id" {
value = module.traefik.id
}

output "external_ip" {
description = "External IP address of Traefik LB service."
value = data.kubernetes_service.traefik.status.0.load_balancer.0.ingress.0.ip
}
1 change: 1 addition & 0 deletions kind/variables.tf

0 comments on commit 7cbafa7

Please sign in to comment.