Skip to content

Commit a8ea83a

Browse files
authored
doc: Update documentation related to secrets (#217)
1 parent ac2b6b7 commit a8ea83a

File tree

6 files changed

+89
-50
lines changed

6 files changed

+89
-50
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ You can find more about this project in Anton Babenko stream:
7979

8080
## FAQ: Frequently Asked Questions
8181

82-
[FAQ](docs/FAQ.md): Frequently Asked Questions
82+
[FAQ](docs/FAQ.md): Frequently Asked Questions and **HOW TO**
8383

8484
## Architecture diagram
8585

@@ -444,6 +444,9 @@ This boiler installs all basic and necessary components. However, we also provid
444444
* layer1-aws: search `***_enable` variables and set them to **true**
445445
* layer2-k8s: check `helm-releases.yaml` file and set **enabled: true** or **enabled:false** for components that you want to **deploy** or to **unistall**
446446
447+
Notes:
448+
* [Gitlab-runner](docs/FAQ.md#gitlab-runner)
449+
447450
## TFSEC
448451
449452
[TFSEC](docs/TFSEC.md): Notes related to tfsec ignores

docs/FAQ.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,12 @@ module "test_namespace" {
155155
}
156156
```
157157

158-
## How to add more restrictions for Gitlab-Runner
158+
## Gitlab-runner
159+
Gitlab-runner installation requieres `registration token`.
160+
* How to generate token see [here](https://docs.gitlab.com/runner/register/#requirements).
161+
* Set `gitlab_runner_registration_token` variable in [AWS Secrets Manager](https://console.aws.amazon.com/secretsmanager/home?region=us-east-1#!/home) secret with the pattern `/${local.name_wo_region}/infra/layer2-k8s`.
162+
163+
### How to add more restrictions for Gitlab-Runner
159164
By default Gitlab-Runner can deploy into any namespaces. If you want to allow Gitlab-Runner to deploy only into specific namespaces, then do these:
160165
* Create new Service Account:
161166
```
@@ -220,5 +225,33 @@ By default we install Grafana without integrating it with GitHub or Gitlab and u
220225
* See [this instruction](https://grafana.com/docs/grafana/latest/auth/gitlab/#gitlab-oauth2-authentication) and generate necessary tokens.
221226
* Set `grafana_gitlab_client_id`, `grafana_gitlab_client_secret`, `grafana_gitlab_group` variables in [AWS Secrets Manager](https://console.aws.amazon.com/secretsmanager/home?region=us-east-1#!/home) secret with the pattern `/${local.name_wo_region}/infra/layer2-k8s`.
222227
3. **GitHub**:
223-
* See [this instruction](https://grafana.com/docs/grafana/latest/auth/github/#github-oauth2-authentication)
224-
* Set `grafana_github_client_id`, `grafana_github_client_secret`, `grafana_github_team_ids`, `grafana_github_allowed_organizations` variables in [AWS Secrets Manager](https://console.aws.amazon.com/secretsmanager/home?region=us-east-1#!/home) secret with the pattern `/${local.name_wo_region}/infra/layer2-k8s`.
228+
* See [this instruction](https://grafana.com/docs/grafana/latest/auth/github/#github-oauth2-authentication) and generate necessary tokens.
229+
* Set `grafana_github_client_id`, `grafana_github_client_secret`, `grafana_github_team_ids`, `grafana_github_allowed_organizations` variables in [AWS Secrets Manager](https://console.aws.amazon.com/secretsmanager/home?region=us-east-1#!/home) secret with the pattern `/${local.name_wo_region}/infra/layer2-k8s`.
230+
231+
## Alertmanager
232+
Alertmanager is disabled in default installation. If you want to enable it, then do next:
233+
1. Open file layer2-k8s/eks-kube-prometheus-stack.tf and change :
234+
```yaml
235+
locals {
236+
....
237+
kube_prometheus_stack_alertmanager_values = <<VALUES
238+
# Alertmanager parameters
239+
alertmanager:
240+
enabled: false
241+
....
242+
}
243+
244+
to
245+
246+
locals {
247+
....
248+
kube_prometheus_stack_alertmanager_values = <<VALUES
249+
# Alertmanager parameters
250+
alertmanager:
251+
enabled: true
252+
....
253+
}
254+
```
255+
### If you want to receive alerts **via Slack**, then do next:
256+
* See [this instruction](https://slack.com/help/articles/115005265063-Incoming-webhooks-for-Slack) and generate Slack Incoming Webhook
257+
* Set `alertmanager_slack_webhook`, `alertmanager_slack_channel` variables in [AWS Secrets Manager](https://console.aws.amazon.com/secretsmanager/home?region=us-east-1#!/home) secret with the pattern `/${local.name_wo_region}/infra/layer2-k8s`.

terraform/layer2-k8s/README.md

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
| <a name="provider_helm"></a> [helm](#provider\_helm) | 2.4.1 |
6363
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | 2.6.1 |
6464
| <a name="provider_random"></a> [random](#provider\_random) | 3.1.0 |
65-
| <a name="provider_template"></a> [template](#provider\_template) | 2.2.0 |
6665
| <a name="provider_terraform"></a> [terraform](#provider\_terraform) | n/a |
6766
| <a name="provider_time"></a> [time](#provider\_time) | 0.7.2 |
6867

@@ -139,38 +138,27 @@
139138
| [aws_eks_cluster_auth.main](https://registry.terraform.io/providers/aws/3.64.2/docs/data-sources/eks_cluster_auth) | data source |
140139
| [aws_secretsmanager_secret.infra](https://registry.terraform.io/providers/aws/3.64.2/docs/data-sources/secretsmanager_secret) | data source |
141140
| [aws_secretsmanager_secret_version.infra](https://registry.terraform.io/providers/aws/3.64.2/docs/data-sources/secretsmanager_secret_version) | data source |
142-
| [template_file.cert_manager](https://registry.terraform.io/providers/hashicorp/template/latest/docs/data-sources/file) | data source |
143-
| [template_file.certificate](https://registry.terraform.io/providers/hashicorp/template/latest/docs/data-sources/file) | data source |
144-
| [template_file.cluster_autoscaler](https://registry.terraform.io/providers/hashicorp/template/latest/docs/data-sources/file) | data source |
145-
| [template_file.cluster_issuer](https://registry.terraform.io/providers/hashicorp/template/latest/docs/data-sources/file) | data source |
146-
| [template_file.elk](https://registry.terraform.io/providers/hashicorp/template/latest/docs/data-sources/file) | data source |
147-
| [template_file.external_dns](https://registry.terraform.io/providers/hashicorp/template/latest/docs/data-sources/file) | data source |
148-
| [template_file.external_secrets](https://registry.terraform.io/providers/hashicorp/template/latest/docs/data-sources/file) | data source |
149-
| [template_file.ingress_nginx](https://registry.terraform.io/providers/hashicorp/template/latest/docs/data-sources/file) | data source |
150141
| [terraform_remote_state.layer1-aws](https://registry.terraform.io/providers/hashicorp/terraform/latest/docs/data-sources/remote_state) | data source |
151142

152143
## Inputs
153144

154-
| Name | Description | Type | Default | Required |
155-
| ---------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------- | -------------- | :------: |
156-
| <a name="input_additional_allowed_ips"></a> [additional\_allowed\_ips](#input\_additional\_allowed\_ips) | IP addresses allowed to connect to private resources | `list(any)` | `[]` | no |
157-
| <a name="input_allowed_account_ids"></a> [allowed\_account\_ids](#input\_allowed\_account\_ids) | List of allowed AWS account IDs | `list` | `[]` | no |
158-
| <a name="input_aws_loadbalancer_controller_enable"></a> [aws\_loadbalancer\_controller\_enable](#input\_aws\_loadbalancer\_controller\_enable) | Disable or Enable aws-loadbalancer-controller. You need to enable it if you want to use Fargate | `bool` | `false` | no |
159-
| <a name="input_cluster_autoscaler_version"></a> [cluster\_autoscaler\_version](#input\_cluster\_autoscaler\_version) | Version of cluster autoscaler | `string` | `"v1.21.0"` | no |
160-
| <a name="input_elk_index_retention_days"></a> [elk\_index\_retention\_days](#input\_elk\_index\_retention\_days) | Days before remove index from system elasticsearch | `number` | `14` | no |
161-
| <a name="input_elk_snapshot_retention_days"></a> [elk\_snapshot\_retention\_days](#input\_elk\_snapshot\_retention\_days) | Days to capture index in snapshot | `number` | `90` | no |
162-
| <a name="input_helm_release_history_size"></a> [helm\_release\_history\_size](#input\_helm\_release\_history\_size) | How much helm releases to store | `number` | `5` | no |
163-
| <a name="input_nginx_ingress_ssl_terminator"></a> [nginx\_ingress\_ssl\_terminator](#input\_nginx\_ingress\_ssl\_terminator) | Select SSL termination type | `string` | `"lb"` | no |
164-
| <a name="input_region"></a> [region](#input\_region) | Default infrastructure region | `string` | `"us-east-1"` | no |
165-
| <a name="input_remote_state_bucket"></a> [remote\_state\_bucket](#input\_remote\_state\_bucket) | Name of the bucket for terraform state | `string` | n/a | yes |
166-
| <a name="input_remote_state_key"></a> [remote\_state\_key](#input\_remote\_state\_key) | Key of the remote state for terraform\_remote\_state | `string` | `"layer1-aws"` | no |
145+
| Name | Description | Type | Default | Required |
146+
| ---------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------- | ----------- | -------------- | :------: |
147+
| <a name="input_additional_allowed_ips"></a> [additional\_allowed\_ips](#input\_additional\_allowed\_ips) | IP addresses allowed to connect to private resources | `list(any)` | `[]` | no |
148+
| <a name="input_allowed_account_ids"></a> [allowed\_account\_ids](#input\_allowed\_account\_ids) | List of allowed AWS account IDs | `list` | `[]` | no |
149+
| <a name="input_cluster_autoscaler_version"></a> [cluster\_autoscaler\_version](#input\_cluster\_autoscaler\_version) | Version of cluster autoscaler | `string` | `"v1.21.0"` | no |
150+
| <a name="input_helm_release_history_size"></a> [helm\_release\_history\_size](#input\_helm\_release\_history\_size) | How much helm releases to store | `number` | `5` | no |
151+
| <a name="input_nginx_ingress_ssl_terminator"></a> [nginx\_ingress\_ssl\_terminator](#input\_nginx\_ingress\_ssl\_terminator) | Select SSL termination type | `string` | `"lb"` | no |
152+
| <a name="input_region"></a> [region](#input\_region) | Default infrastructure region | `string` | `"us-east-1"` | no |
153+
| <a name="input_remote_state_bucket"></a> [remote\_state\_bucket](#input\_remote\_state\_bucket) | Name of the bucket for terraform state | `string` | n/a | yes |
154+
| <a name="input_remote_state_key"></a> [remote\_state\_key](#input\_remote\_state\_key) | Key of the remote state for terraform\_remote\_state | `string` | `"layer1-aws"` | no |
167155

168156
## Outputs
169157

170158
| Name | Description |
171159
| ----------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------- |
172160
| <a name="output_alertmanager_domain_name"></a> [alertmanager\_domain\_name](#output\_alertmanager\_domain\_name) | Alertmanager ui address |
173-
| <a name="output_apm_domain_name"></a> [apm\_domain\_name](#output\_apm\_domain\_name) | n/a |
161+
| <a name="output_apm_domain_name"></a> [apm\_domain\_name](#output\_apm\_domain\_name) | APM domain name |
174162
| <a name="output_elastic_stack_bucket_name"></a> [elastic\_stack\_bucket\_name](#output\_elastic\_stack\_bucket\_name) | Name of the bucket for ELKS snapshots |
175163
| <a name="output_elasticsearch_elastic_password"></a> [elasticsearch\_elastic\_password](#output\_elasticsearch\_elastic\_password) | Password of the superuser 'elastic' |
176164
| <a name="output_get_grafana_admin_password"></a> [get\_grafana\_admin\_password](#output\_get\_grafana\_admin\_password) | Command which gets admin password from kubernetes secret |

terraform/layer2-k8s/aws-sm-secrets.tf

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
locals {
2-
kibana_gitlab_client_id = lookup(jsondecode(data.aws_secretsmanager_secret_version.infra.secret_string), "kibana_gitlab_client_id", "mock_value")
3-
kibana_gitlab_client_secret = lookup(jsondecode(data.aws_secretsmanager_secret_version.infra.secret_string), "kibana_gitlab_client_secret", "mock_value")
4-
kibana_gitlab_group = lookup(jsondecode(data.aws_secretsmanager_secret_version.infra.secret_string), "kibana_gitlab_group", "mock_value")
5-
gitlab_registration_token = lookup(jsondecode(data.aws_secretsmanager_secret_version.infra.secret_string), "gitlab_registration_token", "mock_value")
6-
alertmanager_slack_url = lookup(jsondecode(data.aws_secretsmanager_secret_version.infra.secret_string), "alertmanager_slack_url", "mock_value")
7-
alertmanager_slack_channel = lookup(jsondecode(data.aws_secretsmanager_secret_version.infra.secret_string), "alertmanager_slack_channel", "mock_value")
8-
}
9-
101
data "aws_secretsmanager_secret" "infra" {
112
name = "/${local.name_wo_region}/infra/layer2-k8s"
123
}

terraform/layer2-k8s/eks-gitlab-runner.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ locals {
77
chart_version = local.helm_releases[index(local.helm_releases.*.id, "gitlab-runner")].chart_version
88
namespace = local.helm_releases[index(local.helm_releases.*.id, "gitlab-runner")].namespace
99
}
10-
gitlab_runner_values = <<VALUES
10+
gitlab_runner_registration_token = lookup(jsondecode(data.aws_secretsmanager_secret_version.infra.secret_string), "gitlab_runner_registration_token", "")
11+
gitlab_runner_values = <<VALUES
1112
gitlabUrl: "https://gitlab.com/"
12-
runnerRegistrationToken: "${local.gitlab_registration_token}"
13+
runnerRegistrationToken: "${local.gitlab_runner_registration_token}"
1314
concurrent: 4
1415
checkInterval: 30
1516

terraform/layer2-k8s/eks-kube-prometheus-stack.tf

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ locals {
1616
grafana_github_client_secret = lookup(jsondecode(data.aws_secretsmanager_secret_version.infra.secret_string), "grafana_github_client_secret", "")
1717
grafana_github_team_ids = lookup(jsondecode(data.aws_secretsmanager_secret_version.infra.secret_string), "grafana_github_team_ids", "")
1818
grafana_github_allowed_organizations = lookup(jsondecode(data.aws_secretsmanager_secret_version.infra.secret_string), "grafana_github_allowed_organizations", "")
19+
alertmanager_slack_webhook = lookup(jsondecode(data.aws_secretsmanager_secret_version.infra.secret_string), "alertmanager_slack_webhook", "")
20+
alertmanager_slack_channel = lookup(jsondecode(data.aws_secretsmanager_secret_version.infra.secret_string), "alertmanager_slack_channel", "")
1921
grafana_domain_name = "grafana-${local.domain_suffix}"
2022
prometheus_domain_name = "prometheus-${local.domain_suffix}"
2123
alertmanager_domain_name = "alertmanager-${local.domain_suffix}"
@@ -221,16 +223,46 @@ alertmanager:
221223
resources:
222224
requests:
223225
storage: 10Gi
226+
resources:
227+
requests:
228+
cpu: 100m
229+
memory: 128Mi
230+
limits:
231+
cpu: 200m
232+
memory: 256Mi
224233
config:
225234
global:
226235
resolve_timeout: 5m
227-
slack_api_url: ${local.alertmanager_slack_url}
228236
route:
229237
group_by: ['job']
230238
group_wait: 30s
231239
group_interval: 5m
232240
repeat_interval: 12h
233241
receiver: 'null'
242+
routes:
243+
- match:
244+
alertname: Watchdog
245+
receiver: 'null'
246+
receivers:
247+
- name: 'null'
248+
249+
affinity:
250+
nodeAffinity:
251+
requiredDuringSchedulingIgnoredDuringExecution:
252+
nodeSelectorTerms:
253+
- matchExpressions:
254+
- key: eks.amazonaws.com/capacityType
255+
operator: In
256+
values:
257+
- ON_DEMAND
258+
VALUES
259+
kube_prometheus_stack_alertmanager_slack_values = <<VALUES
260+
# Alertmanager parameters
261+
alertmanager:
262+
config:
263+
global:
264+
slack_api_url: ${local.alertmanager_slack_webhook}
265+
route:
234266
routes:
235267
- match:
236268
alertname: Watchdog
@@ -257,16 +289,6 @@ alertmanager:
257289
{{ end }}
258290
{{ end }}
259291
icon_emoji: '{{ template "slack.default.iconemoji" . }}'
260-
261-
affinity:
262-
nodeAffinity:
263-
requiredDuringSchedulingIgnoredDuringExecution:
264-
nodeSelectorTerms:
265-
- matchExpressions:
266-
- key: eks.amazonaws.com/capacityType
267-
operator: In
268-
values:
269-
- ON_DEMAND
270292
VALUES
271293
}
272294

@@ -422,7 +444,8 @@ resource "helm_release" "prometheus_operator" {
422444
local.kube_prometheus_stack_grafana_values,
423445
local.grafana_oauth_type == "gitlab" ? local.kube_prometheus_stack_grafana_gitlab_oauth_values : null,
424446
local.grafana_oauth_type == "github" ? local.kube_prometheus_stack_grafana_github_oauth_values : null,
425-
local.kube_prometheus_stack_alertmanager_values
447+
local.kube_prometheus_stack_alertmanager_values,
448+
local.alertmanager_slack_webhook != "" ? local.kube_prometheus_stack_alertmanager_slack_values : null
426449
])
427450

428451
}

0 commit comments

Comments
 (0)