Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Introduce possibility to install VictoriaMetrics or Prometheus #222

Merged
merged 10 commits into from
Nov 25, 2021
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ This boiler installs all basic and necessary components. However, we also provid

Notes:
* [Gitlab-runner](docs/FAQ.md#gitlab-runner)
* [Monitoring](docs/FAQ.md#monitoring)

## TFSEC

Expand Down
36 changes: 34 additions & 2 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,17 @@ runners:
...
```

## Monitoring
This boilerplate provides two solutions for monitoring:
1. VictoriaMetrics based on [victoria-metrics-k8s-stack](https://github.com/VictoriaMetrics/helm-charts/tree/master/charts/victoria-metrics-k8s-stack)
2. Prometheus based on [kube-prometheus-stack](https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-prometheus-stack)

VictoriaMetrics is installed by default. However, you can easily switch to Prometheus just **enabling** it and **disabling** VictoriaMetrics in `terraform/layer2-k8s/helm-releases.yaml`. You need to do it before first applying the layer2-k8s.
mglotov marked this conversation as resolved.
Show resolved Hide resolved
VictoriaMetrics Operator supports several [Prometheus objects](https://github.com/VictoriaMetrics/operator#overview). For example, Servicemonitor, PrometheusRule. However, we need to somehow install necessary Prometheus CRDs in a k8s cluster. So, it's done in the `eks-prometheus-operator-crds.tf` file, where we install Prometheus' CRDs separately from kube-prometheus-stack.

## Grafana: How to add GitHub/Gitlab OAuth2 Authentication:
By default we install Grafana without integrating it with GitHub or Gitlab and use basic authentication (login/password). If you want to integrate it to use OAuth2, then do next:
1. Set `grafana_oauth_type` variable in the `terraform/layer2-k8s/eks-kube-prometheus-stack.tf` to the desired value (github or gitlab).
1. Set `grafana_oauth_type` variable in the `terraform/layer2-k8s/eks-victoria-metrics-k8s-stack.tf`/`terraform/layer2-k8s/eks-kube-prometheus-stack.tf` to the desired value (github or gitlab).
mglotov marked this conversation as resolved.
Show resolved Hide resolved
2. **Gitlab**:
* See [this instruction](https://grafana.com/docs/grafana/latest/auth/gitlab/#gitlab-oauth2-authentication) and generate necessary tokens.
* 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`.
Expand All @@ -230,7 +238,31 @@ By default we install Grafana without integrating it with GitHub or Gitlab and u

## Alertmanager
Alertmanager is disabled in default installation. If you want to enable it, then do next:
1. Open file layer2-k8s/eks-kube-prometheus-stack.tf and change :
1. VictoriaMetrics:
Open file layer2-k8s/eks-victoria-metrics-k8s-stack.tf and change :
```yaml
locals {
....
victoria_metrics_k8s_stack_alertmanager_values = <<VALUES
# Alertmanager parameters
alertmanager:
enabled: false
....
}

to

locals {
....
victoria_metrics_k8s_stack_alertmanager_values = <<VALUES
# Alertmanager parameters
alertmanager:
enabled: true
....
}
```
2. Prometheus:
Open file layer2-k8s/eks-kube-prometheus-stack.tf and change :
```yaml
locals {
....
Expand Down
36 changes: 36 additions & 0 deletions terraform/layer2-k8s/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion terraform/layer2-k8s/eks-cluster-autoscaler.tf
Original file line number Diff line number Diff line change
Expand Up @@ -184,5 +184,5 @@ resource "helm_release" "cluster_autoscaler" {
local.cluster_autoscaler_values
]

depends_on = [helm_release.prometheus_operator]
depends_on = [kubectl_manifest.kube_prometheus_stack_operator_crds]
}
2 changes: 1 addition & 1 deletion terraform/layer2-k8s/eks-ingress-nginx-controller.tf
Original file line number Diff line number Diff line change
Expand Up @@ -227,5 +227,5 @@ resource "helm_release" "ingress_nginx" {
var.nginx_ingress_ssl_terminator == "lb" ? local.ingress_loadbalancer_ssl_termination_values : local.ingress_pod_ssl_termination_values
]

depends_on = [helm_release.prometheus_operator]
depends_on = [kubectl_manifest.kube_prometheus_stack_operator_crds]
}
4 changes: 2 additions & 2 deletions terraform/layer2-k8s/eks-istio.tf
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ resource "helm_release" "istio_operator_resources" {
local.istio_operator_default_profile_values
]

depends_on = [helm_release.istio_operator, helm_release.prometheus_operator]
depends_on = [helm_release.istio_operator, kubectl_manifest.kube_prometheus_stack_operator_crds]
}

resource "time_sleep" "wait_10_seconds" {
Expand Down Expand Up @@ -205,5 +205,5 @@ resource "helm_release" "kiali" {
local.kiali_server_values
]

depends_on = [helm_release.istio_operator, helm_release.prometheus_operator]
depends_on = [helm_release.istio_operator, kubectl_manifest.kube_prometheus_stack_operator_crds]
}
2 changes: 1 addition & 1 deletion terraform/layer2-k8s/eks-keda.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ locals {
enabled = local.helm_releases[index(local.helm_releases.*.id, "keda")].enabled
chart = local.helm_releases[index(local.helm_releases.*.id, "keda")].chart
repository = local.helm_releases[index(local.helm_releases.*.id, "keda")].repository
chart_version = local.helm_releases[index(local.helm_releases.*.id, "keda")].version
chart_version = local.helm_releases[index(local.helm_releases.*.id, "keda")].chart_version
namespace = local.helm_releases[index(local.helm_releases.*.id, "keda")].namespace
}
}
Expand Down
Loading