Skip to content

Commit

Permalink
Merge pull request #3 from streamnative/fixes/composition
Browse files Browse the repository at this point in the history
Made changes for better module composition
  • Loading branch information
jrsdav authored Aug 31, 2021
2 parents 012aa8c + a72fa36 commit a2441be
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 89 deletions.
49 changes: 29 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,40 @@ The `main.tf` file in the root of this repository contains an example of how to
A simple example of how to use one of the modules is shown below:

```hcl
data "aws_eks_cluster" "cluster" {
name = "my_eks_cluster_id"
}
data "aws_eks_cluster_auth" "cluster" {
name = "my_eks_cluster_id"
}
provider "kubernetes" {
host = data.aws_eks_cluster.cluster.endpoint
cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data)
token = data.aws_eks_cluster_auth.cluster.token
insecure = false
config_path = "./my-eks-kube-config"
}
provider "helm" {
kubernetes {
config_path = pathexpand("~/.kube/my-eks-cluster-config")
config_path = "./my-eks-kube-config"
}
}
module "pulsar_operator" {
source = "streamnative/charts/helm//pulsar-operator"
module "sn_bootstrap" {
source = "streamnative/charts/helm"
chart_name = "pulsar-operator"
chart_repository = "https://charts.streamnative.io"
chart_version = "0.7.2"
cleanup_on_fail = true
namespace = "pulsar-system"
release_name = "pulsar-operator"
settings = {
"namespace" = "pulsar-system"
"namespaceCreate" = "true"
}
enable_vault_operator = true
enable_function_mesh_operator = true
enable_istio_operator = true
enable_prometheus_operator = true
enable_pulsar_operator = true
timeout = 300
depends_on = [
module.sn_cluster,
]
}
```

Expand Down Expand Up @@ -96,9 +108,6 @@ No resources.
| <a name="input_function_mesh_operator_release_name"></a> [function\_mesh\_operator\_release\_name](#input\_function\_mesh\_operator\_release\_name) | The name of the helm release | `string` | `"function-mesh-operator"` | no |
| <a name="input_function_mesh_operator_settings"></a> [function\_mesh\_operator\_settings](#input\_function\_mesh\_operator\_settings) | Additional settings which will be passed to the Helm chart values | `map(any)` | `null` | no |
| <a name="input_function_mesh_operator_timeout"></a> [function\_mesh\_operator\_timeout](#input\_function\_mesh\_operator\_timeout) | Time in seconds to wait for any individual kubernetes operation | `number` | `600` | no |
| <a name="input_istio_operator_chart_name"></a> [istio\_operator\_chart\_name](#input\_istio\_operator\_chart\_name) | The name of the Helm chart to install | `string` | `"istio-operator"` | no |
| <a name="input_istio_operator_chart_repository"></a> [istio\_operator\_chart\_repository](#input\_istio\_operator\_chart\_repository) | The repository containing the Helm chart to install | `string` | `"https://kubernetes-charts.banzaicloud.com"` | no |
| <a name="input_istio_operator_chart_version"></a> [istio\_operator\_chart\_version](#input\_istio\_operator\_chart\_version) | The version of the Helm chart to install | `string` | `"0.0.88"` | no |
| <a name="input_istio_operator_cleanup_on_fail"></a> [istio\_operator\_cleanup\_on\_fail](#input\_istio\_operator\_cleanup\_on\_fail) | Allow deletion of new resources created in this upgrade when upgrade fails | `bool` | `true` | no |
| <a name="input_istio_operator_namespace"></a> [istio\_operator\_namespace](#input\_istio\_operator\_namespace) | The namespace used for the operator deployment | `string` | `"istio-system"` | no |
| <a name="input_istio_operator_release_name"></a> [istio\_operator\_release\_name](#input\_istio\_operator\_release\_name) | The name of the helm release | `string` | `"istio-operator"` | no |
Expand All @@ -108,7 +117,7 @@ No resources.
| <a name="input_olm_namespace"></a> [olm\_namespace](#input\_olm\_namespace) | The namespace used by OLM and its resources | `string` | `"olm"` | no |
| <a name="input_olm_operators_namespace"></a> [olm\_operators\_namespace](#input\_olm\_operators\_namespace) | The namespace where OLM will install the operators | `string` | `"operators"` | no |
| <a name="input_olm_settings"></a> [olm\_settings](#input\_olm\_settings) | Additional settings which will be passed to the Helm chart values | `map(any)` | `null` | no |
| <a name="input_olm_sn_image"></a> [olm\_sn\_image](#input\_olm\_sn\_image) | The registry containing StreamNative's operator catalog image | `string` | n/a | yes |
| <a name="input_olm_sn_image"></a> [olm\_sn\_image](#input\_olm\_sn\_image) | The registry containing StreamNative's operator catalog image | `string` | `""` | no |
| <a name="input_olm_subscription_settings"></a> [olm\_subscription\_settings](#input\_olm\_subscription\_settings) | Additional settings which will be passed to the Helm chart values | `map(any)` | `null` | no |
| <a name="input_prometheus_operator_chart_name"></a> [prometheus\_operator\_chart\_name](#input\_prometheus\_operator\_chart\_name) | The name of the Helm chart to install | `string` | `"kube-prometheus-stack"` | no |
| <a name="input_prometheus_operator_chart_repository"></a> [prometheus\_operator\_chart\_repository](#input\_prometheus\_operator\_chart\_repository) | The repository containing the Helm chart to install | `string` | `"https://prometheus-community.github.io/helm-charts"` | no |
Expand All @@ -128,7 +137,7 @@ No resources.
| <a name="input_pulsar_operator_timeout"></a> [pulsar\_operator\_timeout](#input\_pulsar\_operator\_timeout) | Time in seconds to wait for any individual kubernetes operation | `number` | `600` | no |
| <a name="input_vault_operator_chart_name"></a> [vault\_operator\_chart\_name](#input\_vault\_operator\_chart\_name) | The name of the Helm chart to install | `string` | `"vault-operator"` | no |
| <a name="input_vault_operator_chart_repository"></a> [vault\_operator\_chart\_repository](#input\_vault\_operator\_chart\_repository) | The repository containing the Helm chart to install | `string` | `"https://kubernetes-charts.banzaicloud.com"` | no |
| <a name="input_vault_operator_chart_version"></a> [vault\_operator\_chart\_version](#input\_vault\_operator\_chart\_version) | The version of the Helm chart to install | `string` | `"1.13.0"` | no |
| <a name="input_vault_operator_chart_version"></a> [vault\_operator\_chart\_version](#input\_vault\_operator\_chart\_version) | The version of the Helm chart to install | `string` | `"1.13.2"` | no |
| <a name="input_vault_operator_cleanup_on_fail"></a> [vault\_operator\_cleanup\_on\_fail](#input\_vault\_operator\_cleanup\_on\_fail) | Allow deletion of new resources created in this upgrade when upgrade fails | `bool` | `true` | no |
| <a name="input_vault_operator_namespace"></a> [vault\_operator\_namespace](#input\_vault\_operator\_namespace) | The namespace used for the operator deployment | `string` | `"sn-system"` | no |
| <a name="input_vault_operator_release_name"></a> [vault\_operator\_release\_name](#input\_vault\_operator\_release\_name) | The name of the helm release | `string` | `"vault-operator"` | no |
Expand Down
45 changes: 17 additions & 28 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,74 +17,63 @@
# under the License.
#

####
# This top module is an example of how one might use the sub-modules for individual helm charts used by StreamNative
####

module "function_mesh_operator" {
count = var.enable_function_mesh_operator && var.disable_olm ? 1 : 0
count = var.enable_function_mesh_operator == true && var.enable_olm == false ? 1 : 0
source = "./modules/function-mesh-operator"

chart_name = var.function_mesh_operator_chart_name
chart_repository = var.function_mesh_operator_chart_repository
chart_version = var.function_mesh_operator_chart_version
cleanup_on_fail = var.function_mesh_operator_cleanup_on_fail
namespace = var.function_mesh_operator_namespace
namespace = var.function_mesh_operator_namespace
release_name = var.function_mesh_operator_release_name
settings = coalesce(var.function_mesh_operator_settings, {}) # The empty map is a placeholder value, reserved for future defaults
timeout = var.function_mesh_operator_timeout
}

module "istio_operator" {
count = var.enable_istio_operator ? 1 : 0
count = var.enable_istio_operator ? 1 : 0
source = "./modules/istio-operator"

chart_name = var.istio_operator_chart_name
chart_repository = var.istio_operator_chart_repository
chart_version = var.istio_operator_chart_version
cleanup_on_fail = var.istio_operator_cleanup_on_fail
namespace = var.istio_operator_namespace
release_name = var.istio_operator_release_name
settings = coalesce(var.istio_operator_settings, {}) # The empty map is a placeholder value, reserved for future defaults
timeout = var.istio_operator_timeout
cleanup_on_fail = var.istio_operator_cleanup_on_fail
namespace = var.istio_operator_namespace
release_name = var.istio_operator_release_name
settings = coalesce(var.istio_operator_settings, {}) # The empty map is a placeholder value, reserved for future defaults
timeout = var.istio_operator_timeout
}

module "olm" {
count = var.disable_olm ? 0 : 1
count = var.enable_olm ? 1 : 0
source = "./modules/operator-lifecycle-manager"

olm_namespace = var.olm_namespace
olm_operators_namespace = var.olm_operators_namespace
settings = coalesce(var.olm_settings, {}) # The empty map is a placeholder value, reserved for future defaults

depends_on = [
kubernetes_namespace.sn_system
]
}

module "olm_subscriptions" {
count = var.disable_olm ? 0 : 1
count = var.enable_olm ? 1 : 0
source = "./modules/olm-subscriptions"

catalog_namespace = var.olm_catalog_namespace
namespace = var.olm_namespace
settings = coalesce(var.olm_subscription_settings, {}) # The empty map is a placeholder value, reserved for future defaults
sn_image = var.olm_sn_image
registry = var.olm_registry

depends_on = [
module.olm
]
}

module "prometheus_operator" {
count = var.enable_prometheus_operator && var.disable_olm ? 1 : 0
count = var.enable_prometheus_operator == true && var.enable_olm == false ? 1 : 0
source = "./modules/prometheus-operator"

chart_name = var.prometheus_operator_chart_name
chart_repository = var.prometheus_operator_chart_repository
chart_version = var.prometheus_operator_chart_version
cleanup_on_fail = var.prometheus_operator_cleanup_on_fail
namespace = var.prometheus_operator_namespace
namespace = var.prometheus_operator_namespace
release_name = var.prometheus_operator_release_name

settings = coalesce(var.prometheus_operator_settings, { # Defaults are set to the right. Passing input via var.prometheus_operator_settings will override
Expand All @@ -99,14 +88,14 @@ module "prometheus_operator" {
}

module "pulsar_operator" {
count = var.enable_pulsar_operator && var.disable_olm ? 1 : 0
count = var.enable_pulsar_operator == true && var.enable_olm == false ? 1 : 0
source = "./modules/pulsar-operator"

chart_name = var.pulsar_operator_chart_name
chart_repository = var.pulsar_operator_chart_repository
chart_version = var.pulsar_operator_chart_version
cleanup_on_fail = var.pulsar_operator_cleanup_on_fail
namespace = var.pulsar_operator_namespace
namespace = var.pulsar_operator_namespace
release_name = var.pulsar_operator_release_name
settings = coalesce(var.pulsar_operator_settings, {}) # The empty map is a placeholder value, reserved for future defaults
timeout = var.pulsar_operator_timeout
Expand All @@ -120,8 +109,8 @@ module "vault_operator" {
chart_repository = var.vault_operator_chart_repository
chart_version = var.vault_operator_chart_version
cleanup_on_fail = var.vault_operator_cleanup_on_fail
namespace = var.vault_operator_namespace
namespace = var.vault_operator_namespace
release_name = var.vault_operator_release_name
settings = coalesce(var.vault_operator_settings, {}) # The empty map is a placeholder value, reserved for future defaults
timeout = var.vault_operator_timeout
}
}
6 changes: 2 additions & 4 deletions modules/istio-operator/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@ terraform {

resource "helm_release" "istio_operator" {
atomic = var.atomic
chart = "${path.module}/chart"
chart = "${path.module}/chart"
cleanup_on_fail = var.cleanup_on_fail
name = var.release_name
namespace = var.namespace
# repository = var.chart_repository
timeout = var.timeout
# version = var.chart_version
timeout = var.timeout

dynamic "set" {
for_each = var.settings
Expand Down
2 changes: 1 addition & 1 deletion modules/istio-operator/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ variable "cleanup_on_fail" {
}

variable "namespace" {
description = "The namespace used for the operator deployment"
description = "The namespace used for the helm release. The istio operator itself will be installed"
type = string
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ metadata:
namespace: {{ .Values.catalog_namespace }}
spec:
displayName: StreamNative Operators
image: {{ .Values.sn_image }}
image: {{ .Values.sn_registry }}
publisher: StreamNative.io
sourceType: grpc
updateStrategy:
Expand Down
2 changes: 1 addition & 1 deletion modules/olm-subscriptions/chart/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ catalog_namespace: olm
install_namespace: sn-system
operator_group: sn-operators

sn_image: ""
sn_registry: ""

components:
bookkeeper: true
Expand Down
4 changes: 2 additions & 2 deletions modules/olm-subscriptions/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ resource "helm_release" "olm_subscriptions" {
}

set {
name = "sn_image"
value = var.sn_image
name = "sn_registry"
value = var.registry
type = "string"
}

Expand Down
4 changes: 2 additions & 2 deletions modules/olm-subscriptions/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ variable "settings" {
type = map(any)
}

variable "sn_image" {
description = "The registry containing StreamNative's operator catalog image"
variable "registry" {
description = "The registry containing StreamNative's operator catalog images"
type = string
}

Expand Down
2 changes: 1 addition & 1 deletion modules/vault-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ No modules.
| <a name="input_atomic"></a> [atomic](#input\_atomic) | Purge the chart on a failed installation. Default's to "true". | `bool` | `true` | no |
| <a name="input_chart_name"></a> [chart\_name](#input\_chart\_name) | The name of the Helm chart to install | `string` | `"vault-operator"` | no |
| <a name="input_chart_repository"></a> [chart\_repository](#input\_chart\_repository) | The repository containing the Helm chart to install | `string` | `"https://kubernetes-charts.banzaicloud.com"` | no |
| <a name="input_chart_version"></a> [chart\_version](#input\_chart\_version) | The version of the Helm chart to install | `string` | `"1.13.0"` | no |
| <a name="input_chart_version"></a> [chart\_version](#input\_chart\_version) | The version of the Helm chart to install | `string` | `"1.13.2"` | no |
| <a name="input_cleanup_on_fail"></a> [cleanup\_on\_fail](#input\_cleanup\_on\_fail) | Allow deletion of new resources created in this upgrade when upgrade fails | `bool` | `true` | no |
| <a name="input_create_namespace"></a> [create\_namespace](#input\_create\_namespace) | Create a namespace for the operator. Defaults to "false". As a best practice it is not recommended to not have Helm manage namespaces. | `bool` | `"false"` | no |
| <a name="input_namespace"></a> [namespace](#input\_namespace) | The namespace used for the operator deployment | `string` | n/a | yes |
Expand Down
2 changes: 1 addition & 1 deletion modules/vault-operator/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ variable "create_namespace" {
type = bool
}
variable "chart_version" {
default = "1.13.0"
default = "1.13.2"
description = "The version of the Helm chart to install"
type = string
}
Expand Down
38 changes: 10 additions & 28 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
### Enable/Disable sub-module flags

variable "disable_olm" {
default = true
description = "Enables Operator Lifecycle Manager (OLM), and disables installing operators via Helm. OLM is disabled by default. Set to \"false\" to have OLM manage the operators."
### Enable/Disable sub-modules
variable "enable_olm" {
default = false
description = "Enables Operator Lifecycle Manager (OLM), and disables installing operators via Helm. OLM is disabled by default. Set to \"true\" to have OLM manage the operators."
type = bool
}

Expand Down Expand Up @@ -86,32 +85,14 @@ variable "function_mesh_operator_timeout" {
type = number
}

variable "istio_operator_chart_name" {
default = "istio-operator"
description = "The name of the Helm chart to install"
type = string
}

variable "istio_operator_chart_repository" {
default = "https://kubernetes-charts.banzaicloud.com"
description = "The repository containing the Helm chart to install"
type = string
}

variable "istio_operator_chart_version" {
default = "0.0.88"
description = "The version of the Helm chart to install"
type = string
}

variable "istio_operator_cleanup_on_fail" {
default = true
description = "Allow deletion of new resources created in this upgrade when upgrade fails"
type = bool
}

variable "istio_operator_namespace" {
default = "istio-system"
default = "kube-system"
description = "The namespace used for the operator deployment"
type = string
}
Expand Down Expand Up @@ -158,8 +139,9 @@ variable "olm_settings" {
type = map(any)
}

variable "olm_sn_image" {
description = "The registry containing StreamNative's operator catalog image"
variable "olm_registry" {
default = ""
description = "The registry containing StreamNative's operator catalog images"
type = string
}

Expand Down Expand Up @@ -244,7 +226,7 @@ variable "pulsar_operator_cleanup_on_fail" {
variable "pulsar_operator_namespace" {
default = "sn-system"
description = "The namespace used for the operator deployment"
type = string
type = string
}

variable "pulsar_operator_release_name" {
Expand Down Expand Up @@ -278,7 +260,7 @@ variable "vault_operator_chart_repository" {
}

variable "vault_operator_chart_version" {
default = "1.13.0"
default = "1.13.2"
description = "The version of the Helm chart to install"
type = string
}
Expand Down

0 comments on commit a2441be

Please sign in to comment.