Skip to content

Commit a561bee

Browse files
committed
#25 removed plugins for grafana, removed labels for service monitors, disable serviceMonitorSelectorNilUsesHelmValues
2 parents 7defbea + 0e49a46 commit a561bee

17 files changed

+51
-58
lines changed

README-RU.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,17 @@
2222

2323
## Описание
2424

25-
В данном репозитории собраны наработки команды Mad Devs для быстрого развертывания Kubernetes кластера, вспомогательных сервисов и нижележащей инфраструктуры в облаке Amazon. Основным инструментом разработки и поставки является [terraform](https://www.terraform.io/)
25+
В данном репозитории собраны наработки команды Mad Devs для быстрого развертывания Kubernetes кластера, вспомогательных сервисов и нижележащей инфраструктуры в облаке Amazon. Основным инструментом разработки и поставки является [terraform](https://www.terraform.io/).
2626

27-
За время работы компании мы перепробовали много инфраструктурных решений и сервисов, и прошли путь от on-premise железа до serverless. В итоге на текущий момент нашей стандартной платформой для развертывания приложений стал Kubernetes, а основным облаком - AWS. Тут стоит отметить, что несмотря на то, что 90% наших и клиентских проектов хостится на AWS, а в качестве Kubernetes платформы используется [AWS EKS](https://aws.amazon.com/eks/), мы не упираемся рогом, не тащим все подряд в Kubernetes и не заставляем хостится в AWS. Kubernetes предлагается только после сбора и анализа требований к архитектуре сервиса. А далее при выборе Kubernetes - приложениям почти не важно, как создан сам кластер - вручную, через kops или используя managed услуги облачных провайдеров - в своей основе платформа Kubernetes везде одинакова. И выбор конкретного провайдера уже складывается из дополнительный требований, экспертизы и т.д.
27+
За время работы компании мы перепробовали много инфраструктурных решений и сервисов, и прошли путь от on-premise железа до serverless. В итоге на текущий момент нашей стандартной платформой для развертывания приложений стал Kubernetes, а основным облаком - AWS.
2828

29-
Мы знаем, что текущая реализация далеко не идеальна. Например, в кластер мы деплоим сервисы с помощью `terraform` - это довольно топорно и против подходов кубера, но это удобно для бутстрапа - т.к. используя стейт и интерполяцию, мы передаем необходимые `ids`, `arns` и другие указатели на ресурсы и имена или секреты в шаблоны и генерим из них `values` для нужных чартов, не выходя за пределы терраформа. Есть более специфичные минусы: ресурсы `data "template_file"`, которые мы использовали для большинства шаблонов, крайне неудобны для разработки и отладки, особенно если это такие 500+ строчные рулоны, типа `terraform/layer2-k8s/templates/elk-values.yaml`. Также, смотря на `helm3` и избавление от `tiller` - большое количество helm-релизов все равно в какой-то момент приводит к зависанию плана. Частично, но не всегда решается путем таргетированного апплая `terraform apply -target`, но для консистентности стейта желательно выполнять `plan` и `apply` целиком на всей конфигурации. Если собираетесь использовать данный бойлер, желательно разбить слой `terraform/layer2-k8s` на несколько, вынеся крупные и комплексные релизы в отдельные подслои.
29+
Тут стоит отметить, что несмотря на то, что 90% наших и клиентских проектов хостится на AWS, а в качестве Kubernetes платформы используется [AWS EKS](https://aws.amazon.com/eks/), мы не упираемся рогом, не тащим все подряд в Kubernetes и не заставляем хостится в AWS. Kubernetes предлагается только после сбора и анализа требований к архитектуре сервиса.
30+
31+
А далее при выборе Kubernetes - приложениям почти не важно, как создан сам кластер - вручную, через kops или используя managed услуги облачных провайдеров - в своей основе платформа Kubernetes везде одинакова. И выбор конкретного провайдера уже складывается из дополнительных требований, экспертизы и т.д.
32+
33+
Мы знаем, что текущая реализация далеко не идеальна. Например, в кластер мы деплоим сервисы с помощью `terraform` - это довольно топорно и против подходов кубера, но это удобно для бутстрапа - т.к. используя стейт и интерполяцию, мы передаем необходимые `ids`, `arns` и другие указатели на ресурсы и имена или секреты в шаблоны и генерим из них `values` для нужных чартов, не выходя за пределы терраформа.
34+
35+
Есть более специфичные минусы: ресурсы `data "template_file"`, которые мы использовали для большинства шаблонов, крайне неудобны для разработки и отладки, особенно если это такие 500+ строчные рулоны, типа `terraform/layer2-k8s/templates/elk-values.yaml`. Также, смотря на `helm3` и избавление от `tiller` - большое количество helm-релизов все равно в какой-то момент приводит к зависанию плана. Частично, но не всегда решается путем таргетированного апплая `terraform apply -target`, но для консистентности стейта желательно выполнять `plan` и `apply` целиком на всей конфигурации. Если собираетесь использовать данный бойлер, желательно разбить слой `terraform/layer2-k8s` на несколько, вынеся крупные и комплексные релизы в отдельные подслои.
3036

3137
Могут возникнуть справедливые вопросы к количеству `.tf` файлов. Оно конечно просится на рефакторинг и "обмодуливание". Чем мы и займемся в ближайшее время, разбивая этот монолит на микромодули и вводя `terragrunt`, попутно решая озвученные проблемы выше.
3238

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,19 @@
2222

2323
## Description
2424

25-
This repository contains the know-how of the Mad Devs team for the rapid deployment of a Kubernetes cluster, supporting services, and the underlying infrastructure in the Amazon cloud. The main development and delivery tool is [terraform](https://www.terraform.io/)
25+
This repository contains the know-how of the Mad Devs team for the rapid deployment of a Kubernetes cluster, supporting services, and the underlying infrastructure in the Amazon cloud. The main development and delivery tool is [terraform](https://www.terraform.io/).
2626

27-
In our company’s work, we have tried many infrastructure solutions and services and traveled the path from on-premise hardware to serverless. As of today, Kubernetes has become our standard platform for deploying applications, and AWS has become the main cloud. It is worth noting here that although 90% of our and our clients’ projects are hosted on AWS and [AWS EKS](https://aws.amazon.com/eks/) is used as the Kubernetes platform, we do not insist, do not drag everything to Kubernetes, and do not force anyone to be hosted on AWS. Kubernetes is offered only after the collection and analysis of service architecture requirements. And then, when choosing Kubernetes, it makes almost no difference to applications how the cluster itself is created—manually, through kops or using managed services from cloud providers—in essence, the Kubernetes platform is the same everywhere. So the choice of a particular provider is then made based on additional requirements, expertise, etc.
27+
In our company’s work, we have tried many infrastructure solutions and services and traveled the path from on-premise hardware to serverless. As of today, Kubernetes has become our standard platform for deploying applications, and AWS has become the main cloud.
2828

29-
We know that the current implementation is far from being perfect. For example, we deploy services to the cluster using `terraform`: it is rather clumsy and against the Kuber approaches, but it is convenient for bootstrap because, by using state and interpolation, we convey proper `IDs`, `ARNs`, and other attributes to resources and names or secrets to templates and generate values ​​from them for the required charts all within terraform. There are more specific drawbacks: the `data "template_file"` resources that we used for most templates are extremely inconvenient for development and debugging, especially if there are 500+ line rolls like `terraform/layer2-k8s/templates/elk-values.yaml`. Also, despite `helm3` got rid of the `tiller`, a large number of helm releases still at some point leads to plan hanging. Partially, but not always, it can be solved by `terraform apply -target`, but for the consistency of the state, it is desirable to execute `plan` and `apply` on the entire configuration. If you are going to use this boilerplate, it is advisable to split the `terraform/layer2-k8s` layer into several ones, taking out large and complex releases into separate modules.
29+
It is worth noting here that although 90% of our and our clients’ projects are hosted on AWS and [AWS EKS](https://aws.amazon.com/eks/) is used as the Kubernetes platform, we do not insist, do not drag everything to Kubernetes, and do not force anyone to be hosted on AWS. Kubernetes is offered only after the collection and analysis of service architecture requirements.
3030

31-
You may reasonably question the number of `.tf` files. This monolith certainly should be refactored and split into many micro-modules adopting `terragrunt` approach. This is exactly what we will do in the near future, solving along the way the problems described above.
31+
And then, when choosing Kubernetes, it makes almost no difference to applications how the cluster itself is created—manually, through kops or using managed services from cloud providers—in essence, the Kubernetes platform is the same everywhere. So the choice of a particular provider is then made based on additional requirements, expertise, etc.
32+
33+
We know that the current implementation is far from being perfect. For example, we deploy services to the cluster using `terraform`: it is rather clumsy and against the Kuber approaches, but it is convenient for bootstrap because, by using state and interpolation, we convey proper `IDs`, `ARNs`, and other attributes to resources and names or secrets to templates and generate values ​​from them for the required charts all within terraform.
34+
35+
There are more specific drawbacks: the `data "template_file"` resources that we used for most templates are extremely inconvenient for development and debugging, especially if there are 500+ line rolls like `terraform/layer2-k8s/templates/elk-values.yaml`. Also, despite `helm3` got rid of the `tiller`, a large number of helm releases still at some point leads to plan hanging. Partially, but not always, it can be solved by `terraform apply -target`, but for the consistency of the state, it is desirable to execute `plan` and `apply` on the entire configuration. If you are going to use this boilerplate, it is advisable to split the `terraform/layer2-k8s` layer into several ones, taking out large and complex releases into separate modules.
36+
37+
You may reasonably question the number of .tf files. This monolith certainly should be refactored and split into many micro-modules adopting terragrunt approach. This is exactly what we will do in the near future, solving along the way the problems described above.
3238

3339
## Table of contents
3440

terraform/layer1-aws/aws-eks.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module "eks" {
22
source = "terraform-aws-modules/eks/aws"
3-
version = "14.0.0"
3+
version = "15.1.0"
44

55
cluster_name = local.name
66
cluster_version = var.eks_cluster_version

terraform/layer1-aws/demo.tfvars.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ single_nat_gateway = true
1818
##########
1919
# EKS
2020
##########
21-
eks_cluster_version = "1.18"
21+
eks_cluster_version = "1.19"
2222

2323
eks_worker_groups = {
2424
spot = {

terraform/layer1-aws/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ variable "single_nat_gateway" {
9191

9292
# EKS
9393
variable "eks_cluster_version" {
94-
default = "1.18"
94+
default = "1.19"
9595
description = "Version of the EKS K8S cluster"
9696
}
9797

terraform/layer2-k8s/README.md

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,18 @@
2424
| additional\_allowed\_ips | IP addresses allowed to connect to private resources | `list(any)` | `[]` | no |
2525
| alb\_ingress\_chart\_version | Version of alb-ingress helm chart | `string` | `"1.0.4"` | no |
2626
| alb\_ingress\_image\_tag | Tag of docker image for alb-ingress controller | `string` | `"v1.1.5"` | no |
27-
| alertmanager\_slack\_channel | Slack channel for alertmanager alerts | `string` | `"madops-demo-alerts"` | no |
2827
| allowed\_account\_ids | List of allowed AWS account IDs | `list` | `[]` | no |
2928
| aws\_node\_termination\_handler\_version | Version of aws-node-termination-handler helm chart | `string` | `"0.13.3"` | no |
3029
| calico\_daemonset | Version of calico helm chart | `string` | `"0.3.4"` | no |
3130
| cert\_manager\_version | Version of cert-manager helm chart | `string` | `"1.1.0"` | no |
32-
| cluster\_autoscaler\_version | Version of autoscaler helm chart | `string` | `"1.1.0"` | no |
31+
| cluster\_autoscaler\_chart\_version | Version of cluster autoscaler helm chart | `string` | `"9.9.2"` | no |
32+
| cluster\_autoscaler\_version | Version of cluster autoscaler | `string` | `"v1.19.0"` | no |
3333
| elk\_index\_retention\_days | Days before remove index from system elasticsearch | `number` | `14` | no |
3434
| elk\_snapshot\_retention\_days | Days to capture index in snapshot | `number` | `90` | no |
3535
| elk\_version | Version of ELK helm chart | `string` | `"7.8.0"` | no |
3636
| external\_dns\_version | Version of external-dns helm chart | `string` | `"4.9.4"` | no |
3737
| external\_secrets\_version | Version of external-secrets helm chart | `string` | `"6.3.0"` | no |
3838
| gitlab\_runner\_version | Version of gitlab runner helm chart | `string` | `"0.26.0"` | no |
39-
| grafana\_gitlab\_group | Gitlab group for grafana oauth | `string` | `"madops"` | no |
40-
| kibana\_gitlab\_group | Gitlab group for kibana oauth2 | `string` | `"madops"` | no |
41-
| loki\_datasource\_for\_prometheus\_stack | Enable Loki Datasource in prometheus stack chart | `bool` | `false` | no |
4239
| loki\_stack | Version of Loki Stack helm chart | `string` | `"2.3.1"` | no |
4340
| nginx\_ingress\_controller\_version | Version of nginx-ingress helm chart | `string` | `"3.23.0"` | no |
4441
| nginx\_ingress\_ssl\_terminator | Select SSL termination type | `string` | `"lb"` | no |
@@ -48,7 +45,7 @@
4845
| redis\_version | Version of redis helm chart | `string` | `"12.7.3"` | no |
4946
| region | Default infrastructure region | `string` | `"us-east-1"` | no |
5047
| reloader\_version | Version of reloader helm chart | `string` | `"0.0.81"` | no |
51-
| remote\_state\_bucket | Name of the bucket with the state | `string` | `"madops-terraform-state-us-east-1"` | no |
48+
| remote\_state\_bucket | Name of the bucket for terraform state | `string` | n/a | yes |
5249
| remote\_state\_key | Key of the remote state for terraform\_remote\_state | `string` | `"layer1-aws"` | no |
5350

5451
## Outputs

terraform/layer2-k8s/eks-cluster-autoscaler.tf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ data "template_file" "cluster_autoscaler" {
1414
role_arn = module.aws_iam_autoscaler.role_arn
1515
region = local.region
1616
cluster_name = local.eks_cluster_id
17+
version = var.cluster_autoscaler_version
1718
}
1819
}
1920

2021
resource "helm_release" "cluster_autoscaler" {
21-
name = "cluster-autoscaler-chart"
22-
chart = "cluster-autoscaler-chart"
22+
name = "cluster-autoscaler"
23+
chart = "cluster-autoscaler"
2324
repository = local.helm_repo_cluster_autoscaler
24-
version = var.cluster_autoscaler_version
25+
version = var.cluster_autoscaler_chart_version
2526
namespace = kubernetes_namespace.sys.id
2627

2728
values = [

terraform/layer2-k8s/eks-loki-stack.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ resource "helm_release" "loki_stack" {
2222
values = [
2323
local.loki_stack_template
2424
]
25+
2526
}
2627

2728
resource "random_string" "grafana_loki_password" {

terraform/layer2-k8s/templates/cluster-autoscaler-values.yaml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
image:
2+
tag: ${version}
3+
14
awsRegion: ${region}
25

36
rbac:
@@ -13,9 +16,6 @@ serviceMonitor:
1316
enabled: true
1417
interval: 10s
1518
namespace: monitoring
16-
selector:
17-
app: kube-prometheus-stack-operator
18-
release: kube-prometheus-stack
1919
path: /metrics
2020

2121
affinity:
@@ -27,4 +27,3 @@ affinity:
2727
operator: In
2828
values:
2929
- ondemand
30-

terraform/layer2-k8s/templates/external-dns.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,6 @@ metrics:
1818
serviceMonitor:
1919
enabled: false
2020
namespace: monitoring
21-
selector:
22-
app: kube-prometheus-stack-operator
23-
release: kube-prometheus-stack
2421

2522
sources:
2623
- service

0 commit comments

Comments
 (0)