Skip to content

Commit

Permalink
feat: Add support for mimir on gcp (#885)
Browse files Browse the repository at this point in the history
* Add support for mimir on gcp

Will use this to test grafana agent on our cd-demo cluster

* add more bucket tf config
  • Loading branch information
michaeljguarino authored Nov 16, 2023
1 parent ae12190 commit 64a3dd9
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mimir/helm/mimir/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: mimir
description: helm chart for mimir
type: application
version: 0.1.6
version: 0.1.7
appVersion: 2.7.1
dependencies:
- name: mimir-distributed
Expand Down
5 changes: 5 additions & 0 deletions mimir/helm/mimir/values.yaml.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ mimir-distributed:
annotations:
eks.amazonaws.com/role-arn: {{ importValue "Terraform" "iam_role_arn" }}
{{- end }}
{{- if $isGcp }}
serviceAccount:
annotations:
iam.gke.io/gcp-service-account: {{ importValue "Terraform" "service_account_email" }}
{{ end }}
{{- if and .Values.basicAuth .Values.hostname (not $traceShield) }}
gateway:
enabledNonEnterprise: true
Expand Down
1 change: 0 additions & 1 deletion mimir/plural/recipes/mimir-gcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: mimir-gcp
description: Installs mimir on an aws eks cluster
provider: GCP
primary: true
private: true
dependencies:
- repo: bootstrap
name: gcp-k8s
Expand Down
6 changes: 4 additions & 2 deletions mimir/terraform/gcp/deps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ apiVersion: plural.sh/v1alpha1
kind: Dependencies
metadata:
description: mimir gcp setup
version: 0.1.0
version: 0.1.1
spec:
dependencies:
- name: gcp-bootstrap
repo: bootstrap
type: terraform
version: '>= 0.1.1'
providers:
- gcp
- gcp
outputs:
service_account_email: service_account_email
20 changes: 20 additions & 0 deletions mimir/terraform/gcp/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,23 @@ resource "kubernetes_namespace" "mimir" {
}
}


module "mimir-workload-identity" {
source = "terraform-google-modules/kubernetes-engine/google//modules/workload-identity"
name = "${var.cluster_name}-mimir-sa"
namespace = var.namespace
project_id = var.project_id
use_existing_k8s_sa = true
annotate_k8s_sa = false
k8s_sa_name = var.mimir_serviceaccount
roles = ["roles/storage.admin"]
}

module "gcs_buckets" {
source = "github.com/pluralsh/module-library//terraform/gcs-buckets"

project_id = var.project_id
bucket_names = [var.mimir_blocks_bucket, var.mimir_alert_bucket, var.mimir_ruler_bucket]
service_account_email = module.mimir-workload-identity.gcp_service_account_email
location = var.bucket_location
}
3 changes: 3 additions & 0 deletions mimir/terraform/gcp/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "service_account_email" {
value = module.mimir-workload-identity.gcp_service_account_email
}
6 changes: 5 additions & 1 deletion mimir/terraform/gcp/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
namespace = {{ .Namespace | quote }}
cluster_name = {{ .Cluster | quote }}
cluster_name = {{ .Cluster | quote }}
mimir_blocks_bucket = {{ .Values.mimirBlocksBucket | quote }}
mimir_alert_bucket = {{ .Values.mimirAlertBucket | quote }}
mimir_ruler_bucket = {{ .Values.mimirRulerBucket | quote }}
bucket_location = {{ .Context.BucketLocation | quote }}
21 changes: 21 additions & 0 deletions mimir/terraform/gcp/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,24 @@ variable "namespace" {
variable "cluster_name" {
type = string
}

variable "mimir_serviceaccount" {
type = string
default = "mimir"
}

variable "mimir_blocks_bucket" {
type = string
}

variable "mimir_alert_bucket" {
type = string
}

variable "mimir_ruler_bucket" {
type = string
}

variable "bucket_location" {
type = string
}

0 comments on commit 64a3dd9

Please sign in to comment.