diff --git a/README.md b/README.md index cc82f1b..daffe1e 100644 --- a/README.md +++ b/README.md @@ -34,4 +34,5 @@ Examples: - [ ] EKS root module - [ ] Adopt terraform-docs for modules https://terraform-docs.io/ - [x] token-sa-kubeconfig module (working with EKS and GKE) -- [ ] educates-gitops module \ No newline at end of file +- [x] educates-gitops module +- [ ] sample root-module with educates-gitops \ No newline at end of file diff --git a/platform/educates-gitops/05-additional-files.tf b/platform/educates-gitops/05-additional-files.tf new file mode 100644 index 0000000..80fccfc --- /dev/null +++ b/platform/educates-gitops/05-additional-files.tf @@ -0,0 +1,7 @@ +# Install additional files if they are provided + +# Install theme if file exists +resource "kubectl_manifest" "theme" { + count = fileexists(var.gitopsConfig.themeFile) ? 1 : 0 + yaml_body = file(var.gitopsConfig.themeFile) +} \ No newline at end of file diff --git a/platform/educates-gitops/10-educates-gitops-workshops.tf b/platform/educates-gitops/10-educates-gitops-workshops.tf new file mode 100644 index 0000000..628a6cf --- /dev/null +++ b/platform/educates-gitops/10-educates-gitops-workshops.tf @@ -0,0 +1,192 @@ +######### +## educates ns and rbac +######### +resource "kubectl_manifest" "namespace_gitops_installs" { + yaml_body = < [terraform](#requirement\_terraform) | >= 1.5.7 , < 2.0.0 | +| [kubectl](#requirement\_kubectl) | 2.0.4 | + +## Providers + +| Name | Version | +|------|---------| +| [kubectl](#provider\_kubectl) | 2.0.4 | +| [time](#provider\_time) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [kubectl_manifest.clusterrolebinding_gitops_installs](https://registry.terraform.io/providers/alekc/kubectl/2.0.4/docs/resources/manifest) | resource | +| [kubectl_manifest.gitops_app](https://registry.terraform.io/providers/alekc/kubectl/2.0.4/docs/resources/manifest) | resource | +| [kubectl_manifest.gitops_credentials](https://registry.terraform.io/providers/alekc/kubectl/2.0.4/docs/resources/manifest) | resource | +| [kubectl_manifest.namespace_gitops_installs](https://registry.terraform.io/providers/alekc/kubectl/2.0.4/docs/resources/manifest) | resource | +| [kubectl_manifest.serviceaccount_gitops_installs](https://registry.terraform.io/providers/alekc/kubectl/2.0.4/docs/resources/manifest) | resource | +| [kubectl_manifest.theme](https://registry.terraform.io/providers/alekc/kubectl/2.0.4/docs/resources/manifest) | resource | +| [time_sleep.k8s_gitops_rbac](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/sleep) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [gitopsApp](#input\_gitopsApp) | n/a |
object({
namespace = optional(string, "workshop-gitops")
configFile = optional(string, "workshop-gitops-config.yaml")
})
| `{}` | no | +| [gitopsConfig](#input\_gitopsConfig) | n/a |
object({
configRepo = optional(string, "https://github.com/educates/educates-workshop-gitops-configurer")
environment = optional(string, "sample-environment")
ref = optional(string, "origin/main")
subPathPrefix = optional(string, "config")
syncPeriod = optional(string, "0h10m0s")
overlaysBundle = optional(string, "ghcr.io/educates/educates-workshop-gitops-configurer:main")
github = optional(object({
username = optional(string, "")
password = optional(string, "")
}))
themeFile = optional(string, "theme.yaml")
})
|
{
"github": {}
}
| no | + +## Outputs + +| Name | Description | +|------|-------------| +| [educates-gitops](#output\_educates-gitops) | n/a | diff --git a/platform/educates-gitops/outputs.tf b/platform/educates-gitops/outputs.tf new file mode 100644 index 0000000..267dd2e --- /dev/null +++ b/platform/educates-gitops/outputs.tf @@ -0,0 +1,6 @@ +output "educates-gitops" { + value = { + is_kapp_controller_installed = true + # educates_version = local.educates_package + } +} diff --git a/platform/educates-gitops/variables.tf b/platform/educates-gitops/variables.tf new file mode 100644 index 0000000..cfe9bc6 --- /dev/null +++ b/platform/educates-gitops/variables.tf @@ -0,0 +1,34 @@ +variable "gitopsApp"{ + type = object({ + namespace = optional(string, "workshop-gitops") + configFile = optional(string, "workshop-gitops-config.yaml") + }) + default = { + } +} + +variable "gitopsConfig"{ + type = object({ + configRepo = optional(string, "https://github.com/educates/educates-workshop-gitops-configurer") + environment = optional(string, "sample-environment") + ref = optional(string, "origin/main") + subPathPrefix = optional(string, "config") + syncPeriod = optional(string, "0h10m0s") + overlaysBundle = optional(string, "ghcr.io/educates/educates-workshop-gitops-configurer:main") + github = optional(object({ + username = optional(string, "") + password = optional(string, "") + })) + themeFile = optional(string, "theme.yaml") + }) + default = { + github = { + } + } + + + validation { + condition = can(regex("^(\\d{1,2})h(\\d{1,2})m(\\d{1,2})s", var.gitopsConfig.syncPeriod)) + error_message = "gitops_config_syncperiod must be a valid kapp-controller sync period (e.g. 12h0m0s or 1h or 10m) and always greater that 30s" + } +} \ No newline at end of file diff --git a/platform/educates-gitops/versions.tf b/platform/educates-gitops/versions.tf new file mode 100644 index 0000000..5ad9cc8 --- /dev/null +++ b/platform/educates-gitops/versions.tf @@ -0,0 +1,9 @@ +terraform { + required_providers { + kubectl = { + source = "alekc/kubectl" + version = "2.0.4" + } + } + required_version = ">= 1.5.7 , < 2.0.0" +}