Skip to content

Commit 9f2a2a1

Browse files
authored
Merge pull request #33 from walkline/irsa
Replace Secrets Store + Secrets Manager with IRSA
2 parents a70fee0 + 00dc97d commit 9f2a2a1

28 files changed

+447
-287
lines changed

.header.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ Before you can provision your Mendix environments on Amazon EKS, you must instal
8383
domain_name = "project-name-example.com"
8484
certificate_expiration_email = "[email protected]"
8585
s3_bucket_name = "project-name"
86-
cluster_id = ""
87-
cluster_secret = ""
86+
namespace_id = ""
87+
namespace_secret = ""
8888
environments_internal_names = ["app1", "app2", "app3"]
8989
```
9090
@@ -117,11 +117,7 @@ The internal name must match the name that you specify in the `environments_inte
117117
118118
4. Depending on your provider, update **External Domain Name Registrar** or **Route53 registered domain** with the *aws_route53_zone_name_servers* values. For more information, refer to [Configuring Amazon Route 53 as your DNS service](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/dns-configuring.html).
119119
120-
5. In the developer portal, choose **Cluster Manager**, then choose the **Customization** tab. Enable **External Secrets Store**.
121-
122-
![Customization tab](https://raw.githubusercontent.com/aws-ia/terraform-aws-mendix-private-cloud/main/doc/deployment_guide/images/secrets-store.png)
123-
124-
6. If you're deploying more than three apps, change the default instance type of the `eks_node_instance_type` variable. By default, the instance type for the Kubernetes nodes is optimized to support up to three apps. Deploying more than three apps with the default instance type may affect the performance of your applications. For more information, refer to [Choosing an Amazon EC2 instance type](https://docs.aws.amazon.com/eks/latest/userguide/choosing-instance-type.html) in the Amazon EKS User Guide.
120+
5. If you're deploying more than three apps, change the default instance type of the `eks_node_instance_type` variable. By default, the instance type for the Kubernetes nodes is optimized to support up to three apps. Deploying more than three apps with the default instance type may affect the performance of your applications. For more information, refer to [Choosing an Amazon EC2 instance type](https://docs.aws.amazon.com/eks/latest/userguide/choosing-instance-type.html) in the Amazon EKS User Guide.
125121
126122
## Security
127123
@@ -206,6 +202,9 @@ In the Mendix Private Cloud portal, in the Cluster Manager, the status of your c
206202
207203
## Cleanup
208204
205+
Before cleaning up, make sure that you have deleted Mendix App environments.
206+
Otherwise, you will need to manually remove some finalizers in the namespace and detach some roles from policies in AWS IAM.
207+
209208
To clean up your environment, run the following commands:
210209
211210
```

README.md

+20-14
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ Before you can provision your Mendix environments on Amazon EKS, you must instal
8484
domain_name = "project-name-example.com"
8585
certificate_expiration_email = "[email protected]"
8686
s3_bucket_name = "project-name"
87-
cluster_id = ""
88-
cluster_secret = ""
87+
namespace_id = ""
88+
namespace_secret = ""
8989
environments_internal_names = ["app1", "app2", "app3"]
9090
```
9191
@@ -118,11 +118,7 @@ The internal name must match the name that you specify in the `environments_inte
118118
119119
4. Depending on your provider, update **External Domain Name Registrar** or **Route53 registered domain** with the *aws\_route53\_zone\_name\_servers* values. For more information, refer to [Configuring Amazon Route 53 as your DNS service](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/dns-configuring.html).
120120
121-
5. In the developer portal, choose **Cluster Manager**, then choose the **Customization** tab. Enable **External Secrets Store**.
122-
123-
![Customization tab](https://raw.githubusercontent.com/aws-ia/terraform-aws-mendix-private-cloud/main/doc/deployment_guide/images/secrets-store.png)
124-
125-
6. If you're deploying more than three apps, change the default instance type of the `eks_node_instance_type` variable. By default, the instance type for the Kubernetes nodes is optimized to support up to three apps. Deploying more than three apps with the default instance type may affect the performance of your applications. For more information, refer to [Choosing an Amazon EC2 instance type](https://docs.aws.amazon.com/eks/latest/userguide/choosing-instance-type.html) in the Amazon EKS User Guide.
121+
5. If you're deploying more than three apps, change the default instance type of the `eks_node_instance_type` variable. By default, the instance type for the Kubernetes nodes is optimized to support up to three apps. Deploying more than three apps with the default instance type may affect the performance of your applications. For more information, refer to [Choosing an Amazon EC2 instance type](https://docs.aws.amazon.com/eks/latest/userguide/choosing-instance-type.html) in the Amazon EKS User Guide.
126122
127123
## Security
128124
@@ -207,6 +203,9 @@ In the Mendix Private Cloud portal, in the Cluster Manager, the status of your c
207203
208204
## Cleanup
209205
206+
Before cleaning up, make sure that you have deleted Mendix App environments.
207+
Otherwise, you will need to manually remove some finalizers in the namespace and detach some roles from policies in AWS IAM.
208+
210209
To clean up your environment, run the following commands:
211210
212211
```
@@ -231,7 +230,7 @@ After you deploy this Partner Solution, confirm that your resources and services
231230
| Name | Version |
232231
|------|---------|
233232
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.14 |
234-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.35 |
233+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.10 |
235234
| <a name="requirement_helm"></a> [helm](#requirement\_helm) | >= 2.7.1 |
236235
| <a name="requirement_kubectl"></a> [kubectl](#requirement\_kubectl) | >= 1.14 |
237236
| <a name="requirement_kubernetes"></a> [kubernetes](#requirement\_kubernetes) | >= 2.16.1 |
@@ -242,18 +241,19 @@ After you deploy this Partner Solution, confirm that your resources and services
242241
243242
| Name | Version |
244243
|------|---------|
245-
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.35 |
244+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.10 |
246245
| <a name="provider_helm"></a> [helm](#provider\_helm) | >= 2.7.1 |
247246
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | >= 2.16.1 |
247+
| <a name="provider_random"></a> [random](#provider\_random) | >= 3.4.3 |
248248
249249
## Modules
250250
251251
| Name | Source | Version |
252252
|------|--------|---------|
253253
| <a name="module_container_registry"></a> [container\_registry](#module\_container\_registry) | ./modules/container-registry | n/a |
254254
| <a name="module_databases"></a> [databases](#module\_databases) | ./modules/databases | n/a |
255-
| <a name="module_eks_blueprints"></a> [eks\_blueprints](#module\_eks\_blueprints) | github.com/aws-ia/terraform-aws-eks-blueprints | v4.28.0 |
256-
| <a name="module_eks_blueprints_kubernetes_addons"></a> [eks\_blueprints\_kubernetes\_addons](#module\_eks\_blueprints\_kubernetes\_addons) | github.com/aws-ia/terraform-aws-eks-blueprints//modules/kubernetes-addons | v4.28.0 |
255+
| <a name="module_eks_blueprints"></a> [eks\_blueprints](#module\_eks\_blueprints) | github.com/aws-ia/terraform-aws-eks-blueprints | v4.32.1 |
256+
| <a name="module_eks_blueprints_kubernetes_addons"></a> [eks\_blueprints\_kubernetes\_addons](#module\_eks\_blueprints\_kubernetes\_addons) | github.com/aws-ia/terraform-aws-eks-blueprints//modules/kubernetes-addons | v4.32.1 |
257257
| <a name="module_file_storage"></a> [file\_storage](#module\_file\_storage) | ./modules/file-storage | n/a |
258258
| <a name="module_monitoring"></a> [monitoring](#module\_monitoring) | ./modules/monitoring | n/a |
259259
| <a name="module_vpc"></a> [vpc](#module\_vpc) | ./modules/vpc | n/a |
@@ -263,9 +263,13 @@ After you deploy this Partner Solution, confirm that your resources and services
263263
| Name | Type |
264264
|------|------|
265265
| [aws_ebs_encryption_by_default.ebs_encryption](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/ebs_encryption_by_default) | resource |
266+
| [aws_iam_policy.environment_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
267+
| [aws_iam_policy.provisioner_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
268+
| [aws_iam_role.storage_provisioner_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
266269
| [aws_route53_zone.cluster_dns](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/route53_zone) | resource |
267270
| [helm_release.mendix_installer](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |
268271
| [kubernetes_namespace.mendix](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/namespace) | resource |
272+
| [random_string.random_eks_suffix](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string) | resource |
269273
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
270274
| [aws_eks_cluster_auth.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_cluster_auth) | data source |
271275
@@ -275,14 +279,16 @@ After you deploy this Partner Solution, confirm that your resources and services
275279
|------|-------------|------|---------|:--------:|
276280
| <a name="input_aws_region"></a> [aws\_region](#input\_aws\_region) | AWS Region name | `string` | n/a | yes |
277281
| <a name="input_certificate_expiration_email"></a> [certificate\_expiration\_email](#input\_certificate\_expiration\_email) | Let's Encrypt certificate expiration email | `string` | n/a | yes |
278-
| <a name="input_cluster_id"></a> [cluster\_id](#input\_cluster\_id) | Mendix Private Cloud Cluster ID | `string` | n/a | yes |
279-
| <a name="input_cluster_secret"></a> [cluster\_secret](#input\_cluster\_secret) | Mendix Private Cloud Cluster Secret | `string` | n/a | yes |
280282
| <a name="input_domain_name"></a> [domain\_name](#input\_domain\_name) | Domain name | `string` | n/a | yes |
283+
| <a name="input_namespace_id"></a> [namespace\_id](#input\_namespace\_id) | Mendix Private Cloud Namespace ID | `string` | n/a | yes |
284+
| <a name="input_namespace_secret"></a> [namespace\_secret](#input\_namespace\_secret) | Mendix Private Cloud Namespace Secret | `string` | n/a | yes |
281285
| <a name="input_s3_bucket_name"></a> [s3\_bucket\_name](#input\_s3\_bucket\_name) | S3 bucket name | `string` | n/a | yes |
282286
| <a name="input_allowed_ips"></a> [allowed\_ips](#input\_allowed\_ips) | List of IP adresses allowed to access EKS cluster endpoint | `list(string)` | <pre>[<br> "0.0.0.0/0"<br>]</pre> | no |
287+
| <a name="input_eks_cluster_name_prefix"></a> [eks\_cluster\_name\_prefix](#input\_eks\_cluster\_name\_prefix) | EKS name prefix for the new cluster | `string` | `"mendix-eks"` | no |
283288
| <a name="input_eks_node_instance_type"></a> [eks\_node\_instance\_type](#input\_eks\_node\_instance\_type) | EKS instance type | `string` | `"t3.medium"` | no |
284289
| <a name="input_environments_internal_names"></a> [environments\_internal\_names](#input\_environments\_internal\_names) | List of internal environments names | `list(string)` | <pre>[<br> "app1"<br>]</pre> | no |
285-
| <a name="input_mendix_operator_version"></a> [mendix\_operator\_version](#input\_mendix\_operator\_version) | Mendix Private Cloud Operator version | `string` | `"2.10.0"` | no |
290+
| <a name="input_mendix_operator_version"></a> [mendix\_operator\_version](#input\_mendix\_operator\_version) | Mendix Private Cloud Operator version | `string` | `"2.12.0"` | no |
291+
| <a name="input_postgres_version"></a> [postgres\_version](#input\_postgres\_version) | The version of Postgres that terraform would create. | `string` | `"14.8"` | no |
286292
287293
## Outputs
288294

charts/mendix-installer/templates/apps-secretproviderclass.yaml

-35
This file was deleted.

charts/mendix-installer/templates/apps-serviceaccount.yaml

-12
This file was deleted.

charts/mendix-installer/templates/mendix-installer-configmap.yaml

+20-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,28 @@ metadata:
66
data:
77
mxpc-cli-installer-script: |
88
#/bin/sh
9+
910
wget https://cdn.mendix.com/mendix-for-private-cloud/mxpc-cli/mxpc-cli-{{ .Values.mendixOperatorVersion }}-linux-amd64.tar.gz
1011
tar xvf mxpc-cli-{{ .Values.mendixOperatorVersion }}-linux-amd64.tar.gz
11-
./mxpc-cli base-install --namespace mendix -i {{ .Values.clusterID }} -s {{ .Values.clusterSecret }} --clusterMode connected --clusterType generic
12-
./mxpc-cli apply-config -i {{ .Values.clusterID }} -s {{ .Values.clusterSecret }} --file mendix-installer-config-file/mendix-installer-config-file
12+
./mxpc-cli base-install --namespace mendix -i {{ .Values.namespaceID }} -s {{ .Values.namespaceSecret }} --clusterMode connected --clusterType generic --clusterTag="aws-reference-deployment"
13+
14+
wget --output-document=custom.crt https://truststore.pki.rds.amazonaws.com/global/global-bundle.pem
15+
kubectl -n mendix create secret generic mendix-custom-tls --from-file=custom.crt=custom.crt
16+
17+
./mxpc-cli apply-config -i {{ .Values.namespaceID }} -s {{ .Values.namespaceSecret }} --file mendix-installer-config-file/mendix-installer-config-file
18+
19+
{{- range $.Values.database_plans }}
20+
./mxpc-cli apply-config -i {{ $.Values.namespaceID }} -s {{ $.Values.namespaceSecret }} --file mendix-installer-config-db-{{ .name }}/mendix-installer-config-file
21+
22+
export PGUSER={{ .user }}
23+
export PGHOST={{ .host }}
24+
export PGPASSWORD=$(cat mendix-rds-master-pass-{{ .name }}/rds-password)
25+
26+
psql -c 'GRANT rds_iam TO {{ .user }};'
27+
28+
kubectl -n mendix delete secret mendix-rds-master-pass-{{ .name }}
29+
{{- end }}
30+
1331
kubectl -n mendix patch OperatorConfiguration mendix-operator-configuration --type merge --patch '{"spec":{"endpoint":{"ingress":{"annotations":{"cert-manager.io/cluster-issuer":"letsencrypt-prod"}}}}}'
1432
kubectl -n mendix patch OperatorConfiguration mendix-operator-configuration --type merge --patch '{"spec":{"endpoint":{"ingress":{"tlsSecretName":"tls-{{ .Values.appName }}"}}}}'
1533
kubectl -n mendix patch OperatorConfiguration mendix-operator-configuration --type merge --patch '{"spec":{"runtimeAutomountServiceAccountToken":true,"runtimeDeploymentPodAnnotations":{"linkerd.io/inject":"enabled","prometheus.io/path":"/metrics","prometheus.io/port":"8900","prometheus.io/scrape":"true"}}}'

charts/mendix-installer/templates/mendix-installer-job.yaml

+17-1
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,22 @@ spec:
1010
containers:
1111
- name: mxpc-cli-installer
1212
image: alpine
13-
command: ["/bin/sh", "-c", "wget https://dl.k8s.io/release/v1.25.0/bin/linux/amd64/kubectl; mv kubectl /usr/bin/kubectl; chmod +x /usr/bin/kubectl; /mxpc-cli-installer-script;"]
13+
command: ["/bin/sh", "-c", "apk --update add postgresql-client; wget https://dl.k8s.io/release/v1.25.0/bin/linux/amd64/kubectl; mv kubectl /usr/bin/kubectl; chmod +x /usr/bin/kubectl; /mxpc-cli-installer-script;"]
1414
volumeMounts:
1515
- name: mxpc-cli-installer-script
1616
mountPath: /mxpc-cli-installer-script
1717
subPath: mxpc-cli-installer-script
1818
- name: mendix-installer-config-file
1919
mountPath: mendix-installer-config-file
2020
readOnly: true
21+
{{- range $.Values.database_plans }}
22+
- name: "mendix-installer-config-db-{{ .name }}"
23+
mountPath: "mendix-installer-config-db-{{ .name }}"
24+
readOnly: true
25+
- name: "mendix-rds-master-pass-{{ .name }}"
26+
mountPath: "mendix-rds-master-pass-{{ .name }}"
27+
readOnly: true
28+
{{- end }}
2129
volumes:
2230
- name: mxpc-cli-installer-script
2331
configMap:
@@ -26,4 +34,12 @@ spec:
2634
- name: mendix-installer-config-file
2735
secret:
2836
secretName: mendix-installer-config-file
37+
{{- range $.Values.database_plans }}
38+
- name: "mendix-installer-config-db-{{ .name }}"
39+
secret:
40+
secretName: "mendix-installer-config-db-{{ .name }}"
41+
- name: "mendix-rds-master-pass-{{ .name }}"
42+
secret:
43+
secretName: "mendix-rds-master-pass-{{ .name }}"
44+
{{- end }}
2945
restartPolicy: Never

charts/mendix-installer/templates/mendix-installer-secret.yaml

+63-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ stringData:
1010
cluster_mode: connected
1111
mask:
1212
database_plan: false
13-
storage_plan: false
13+
storage_plan: true
1414
ingress: true
1515
registry: true
1616
proxy: false
17-
custom_tls: false
17+
custom_tls: true
1818
ingress:
1919
type: kubernetes-ingress
2020
enable_tls: true
@@ -34,3 +34,64 @@ stringData:
3434
is_static_credential: false
3535
aws_iam_role: "{{ .Values.registry.iamRole }}"
3636
kubernetes_service_account: "mendix-builder"
37+
storage_plan:
38+
name: s3
39+
type: amazon-s3
40+
s3:
41+
irsa_authentication: true
42+
create_bucket: false
43+
create_user: false
44+
create_inline_policy: false
45+
existing_bucket: "{{ .Values.storage_plan.existing_bucket }}"
46+
existing_policy: "{{ .Values.storage_plan.existing_policy }}"
47+
bucket_autogen_prefix: true
48+
region: "{{ .Values.awsRegion }}"
49+
admin_iam_role: "{{ .Values.storage_plan.admin_iam_role }}"
50+
kubernetes_service_account: "{{ .Values.storage_plan.kubernetes_service_account }}"
51+
oidc_url: "{{ .Values.storage_plan.oidc_url }}"
52+
custom_tls:
53+
ca_certificates_secret_name: mendix-custom-tls
54+
55+
{{- range $.Values.database_plans }}
56+
---
57+
apiVersion: v1
58+
kind: Secret
59+
metadata:
60+
name: "mendix-installer-config-db-{{ .name }}"
61+
namespace: mendix
62+
type: Opaque
63+
stringData:
64+
mendix-installer-config-file: |
65+
namespace: mendix
66+
cluster_mode: connected
67+
mask:
68+
database_plan: true
69+
storage_plan: false
70+
ingress: false
71+
registry: false
72+
proxy: false
73+
custom_tls: false
74+
database_plan:
75+
name: "{{ .name }}"
76+
type: postgres
77+
postgres:
78+
databaseprops:
79+
host: "{{ .host }}"
80+
port: {{ .port }}
81+
user: "{{ .user }}"
82+
password: ""
83+
strict_tls: true
84+
db_name: "{{ .db_name }}"
85+
authentication_mode: aws-iam
86+
aws_iam_role: "{{ .aws_iam_role }}"
87+
kubernetes_service_account: "{{ .kubernetes_service_account }}"
88+
---
89+
apiVersion: v1
90+
kind: Secret
91+
metadata:
92+
name: "mendix-rds-master-pass-{{ .name }}"
93+
namespace: mendix
94+
type: Opaque
95+
stringData:
96+
rds-password: "{{ .master_password }}"
97+
{{- end }}

0 commit comments

Comments
 (0)