Skip to content

Commit

Permalink
Pass custom values to Chart through helm_config code block (#7)
Browse files Browse the repository at this point in the history
* code changes passing custom values through helm_config

Signed-off-by: pragrawal10 <[email protected]>

* Example correction

Signed-off-by: pragrawal10 <[email protected]>

Signed-off-by: pragrawal10 <[email protected]>
  • Loading branch information
pragrawal-px authored Oct 10, 2022
1 parent 33509e5 commit a64ec66
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 74 deletions.
41 changes: 28 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,18 @@ export TF_VAR_aws_secret_access_key=<access-key-secret>
```
enable_portworx = true
portworx_chart_values ={
awsAccessKeyId = var.aws_access_key_id
awsSecretAccessKey = var.aws_secret_access_key
# other custom values for Portworx configuration
}
portworx_helm_config = {
set_sensitive = [
{
name = "awsAccessKeyId"
value = var.aws_access_key_id
},
{
name = "awsSecretAccessKey"
value = var.aws_secret_access_key
}
]
}
```

Expand Down Expand Up @@ -142,14 +148,24 @@ module "eks_blueprints_kubernetes_addons" {
}
```

To customize Portworx installation, pass the configuration parameter as an object as shown below:
To customize Portworx installation, pass the configuration parameter as an list of objects as shown below:

```
enable_portworx = true
portworx_chart_values ={
clusterName="testCluster"
imageVersion="2.11.1"
}
portworx_helm_config = {
set_sensitive = [
{
name = "clusterName"
value = "testCluster"
},
{
name = "imageVersion"
value = "2.11.1"
}
]
}
}
```

Expand Down Expand Up @@ -180,13 +196,12 @@ To customize Portworx installation, pass the configuration parameter as an objec
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_addon_context"></a> [addon\_context](#input\_addon\_context) | Input configuration for the addon | <pre>object({<br> aws_caller_identity_account_id = string<br> aws_caller_identity_arn = string<br> aws_eks_cluster_endpoint = string<br> aws_partition_id = string<br> aws_region_name = string<br> eks_cluster_id = string<br> eks_oidc_issuer_url = string<br> eks_oidc_provider_arn = string<br> tags = map(string)<br> })</pre> | n/a | yes |
| <a name="input_chart_values"></a> [chart\_values](#input\_chart\_values) | Custom values for the Portworx Helm chart | `any` | `{}` | no |
| <a name="input_helm_config"></a> [helm\_config](#input\_helm\_config) | Helm provider config for the Portworx | `any` | `{}` | no |
| <a name="input_set_values"></a> [set\_values](#input\_set\_values) | Forced set values for Portworx Helm chart | `any` | `[]` | no |
| <a name="input_set_sensitive_values"></a> [set\_sensitive\_values](#input\_set\_sensitive\_values) | Forced set sensitive values for Portworx Helm chart | `any` | `[]` | no |
| <a name="input_irsa_permissions_boundary"></a> [irsa\_permissions\_boundary](#input\_irsa\_permissions\_boundary) | IAM Policy ARN for IRSA IAM role permissions boundary | `string` | `""` | no |
| <a name="input_irsa_policies"></a> [irsa\_policies](#input\_irsa\_policies) | IAM policy ARNs for Portworx IRSA | `list(string)` | `[]` | no |
| <a name="input_manage_via_gitops"></a> [manage\_via\_gitops](#input\_manage\_via\_gitops) | Determines if the add-on should be managed via GitOps. | `bool` | `false` | no |
<!-- | <a name="input_manage_via_gitops"></a> [manage\_via\_gitops](#input\_manage\_via\_gitops) | Determines if the add-on should be managed via GitOps. | `bool` | `false` | no | -->

<!-- ## Outputs
Expand Down
9 changes: 6 additions & 3 deletions blueprint/getting_started/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,12 @@ This section describes how to uninstall Portworx and remove its Kubernetes specs
1. Start by choosing between one of two deleteStrategy option and updating the terraform script.

```
portworx_chart_values = {
deleteType = # Valid values: "Uninstall" and "UninstallAndWipe"
# other custom values
portworx_helm_config = {
set = [
{
name= "deleteType"
value= "UninstallAndWipe" # Valid values: "Uninstall" and "UninstallAndWipe"
}]
}
```

Expand Down
16 changes: 12 additions & 4 deletions blueprint/getting_started/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,18 @@ module "eks_blueprints_kubernetes_addons" {


enable_portworx = true
portworx_chart_values ={
awsAccessKeyId = var.aws_access_key_id
awsSecretAccessKey = var.aws_secret_access_key
# other custom values

portworx_helm_config = {
set = [
{
name = "awsAccessKeyId"
value = var.aws_access_key_id
},
{
name= "awsSecretAccessKey"
value= var.aws_secret_access_key
}
]
}

tags = local.tags
Expand Down
9 changes: 6 additions & 3 deletions blueprint/portworx_with_iam_policy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,12 @@ This section describes how to uninstall Portworx and remove its Kubernetes specs
1. Start by choosing between one of two deleteStrategy option and updating the terraform script.

```
portworx_chart_values = {
deleteType = # Valid values: "Uninstall" and "UninstallAndWipe"
# other custom values
portworx_helm_config = {
set = [
{
name= "deleteType"
value= "UninstallAndWipe" # Valid values: "Uninstall" and "UninstallAndWipe"
}]
}
```

Expand Down
11 changes: 8 additions & 3 deletions blueprint/portworx_with_iam_policy/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,14 @@ module "eks_blueprints_kubernetes_addons" {
eks_cluster_version = module.eks_blueprints.eks_cluster_version

enable_portworx = true
portworx_chart_values={
clusterName = "test-1"
imageVersion = "2.11.2"
portworx_helm_config = {
set = [
{
name = "imageVersion"
value = "2.11.2"
}
]
}

tags = local.tags
}
28 changes: 14 additions & 14 deletions locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@ locals {
name = "portworx-${random_string.id.result}"
namespace = "kube-system"
service_account_name = "${local.name}-sa-${random_string.id.result}"

aws_marketplace_config = try(var.helm_config["set"][index(var.helm_config.set.*.name, "useAWSMarketplace")], null)
use_aws_marketplace = local.aws_marketplace_config != null ? local.aws_marketplace_config["value"] : false

set_values = var.set_values
set_sensitive_values = var.set_sensitive_values
set_values = [
{
name = "useAWSMarketplace"
value = local.use_aws_marketplace
}
]


default_helm_config = {
name = local.name
description = "A Helm chart for portworx"
Expand All @@ -19,16 +27,14 @@ locals {
version = "2.11.0"
namespace = local.namespace
values = local.default_helm_values
set_values = []
set_sensitive_values = null
}

helm_config = merge(
local.default_helm_config,
var.helm_config
)

irsa_iam_policies_list= try(var.chart_values.useAWSMarketplace, false) ? concat([aws_iam_policy.portworx_eksblueprint_metering[0].arn], var.irsa_policies) : var.irsa_policies
irsa_iam_policies_list= local.use_aws_marketplace != false ? [aws_iam_policy.portworx_eksblueprint_metering[0].arn] : []

irsa_config = {
create_kubernetes_namespace = false
Expand All @@ -38,12 +44,7 @@ locals {
irsa_iam_policies = local.irsa_iam_policies_list
}

argocd_gitops_config = {
enable = false
serviceAccountName = local.service_account_name
}

default_helm_values = [templatefile("${path.module}/values.yaml", merge({
default_helm_values = [templatefile("${path.module}/values.yaml",{
imageVersion = "2.11.0"
clusterName = local.name
drives = "type=gp2,size=200"
Expand All @@ -65,16 +66,15 @@ locals {
enableAutopilot = false
KVDBauthSecretName = ""
eksServiceAccount = "${local.service_account_name}"
useAWSMarketplace = false
awsAccessKeyId = ""
awsSecretAccessKey = ""
deleteType = "UninstallAndWipe"
},var.chart_values)
}
)]
}

resource "aws_iam_policy" "portworx_eksblueprint_metering" {
count = try(var.chart_values.useAWSMarketplace, false)? 1 : 0
count = try(local.use_aws_marketplace, false)? 1 : 0
name = "portworx_eksblueprint_metering-${random_string.id.result}"

policy = jsonencode({
Expand Down
3 changes: 0 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
module "helm_addon"{
source = "github.com/aws-ia/terraform-aws-eks-blueprints//modules/kubernetes-addons/helm-addon?ref=v4.7.0"
manage_via_gitops = var.manage_via_gitops
addon_context = var.addon_context

set_values = local.set_values
set_sensitive_values = local.set_sensitive_values
helm_config = local.helm_config
irsa_config = local.irsa_config
}
2 changes: 1 addition & 1 deletion values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ serviceAccount:
name:

aws:
marketplace: ${useAWSMarketplace}
marketplace:
eksServiceAccount: ${eksServiceAccount}
accessKeyId: ${awsAccessKeyId}
secretAccessKey: ${awsSecretAccessKey}
Expand Down
30 changes: 0 additions & 30 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,6 @@ variable "helm_config" {
default = {}
}

variable "chart_values" {
description = "custom values for the chart"
type = any
default = {}
}

variable "set_values" {
description = "Forced set values"
type = any
default = []
}

variable "set_sensitive_values" {
description = "Forced set_sensitive values"
type = any
default = []
}

variable "manage_via_gitops" {
description = "Determines if the add-on should be managed via GitOps"
type = bool
default = false
}

variable "irsa_policies" {
description = "Additional IAM policy ARNs for Portworx IRSA"
type = list(string)
default = []
}

variable "irsa_config" {
description = "Input configuration for IRSA module"
type = object({
Expand Down

0 comments on commit a64ec66

Please sign in to comment.