Skip to content

Commit

Permalink
feat: add victoriametrics read endpoint (#296)
Browse files Browse the repository at this point in the history
* chore: refactor vmetrics endpoint configuration to single file

* chore: clean up vm endpoint configuration

* feat: add victoriametrics read endpoint
  • Loading branch information
bo0tzz authored Dec 5, 2024
1 parent 46e4f6f commit 310dd81
Show file tree
Hide file tree
Showing 13 changed files with 196 additions and 82 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./secret.yaml
- ./vmuser.yaml
- ./vmauth.yaml
- ./write.yaml
- ./read.yaml
42 changes: 42 additions & 0 deletions kubernetes/apps/monitoring-dev/victoria-metrics/ingress/read.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: onepassword.com/v1
kind: OnePasswordItem
metadata:
name: vmetrics-read-token
namespace: monitoring-dev
spec:
itemPath: "vaults/Kubernetes/items/vmetrics_read_token"
---
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMUser
metadata:
name: read
namespace: monitoring-dev
labels:
vm-user: "read"
spec:
tokenRef:
name: vmetrics-read-token
key: token
targetRefs:
- crd:
kind: VMSingle
name: vmetrics-dev
namespace: monitoring-dev
paths: ["/targets/api/v1","/targets","/metrics"]
---
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMAuth
metadata:
name: vmetrics-read-ingress
namespace: monitoring-dev
spec:
userSelector:
matchLabels:
vm-user: "read"
ingress:
tlsSecretName: vmetrics-read-tls
annotations:
cert-manager.io/cluster-issuer: letsencrypt-production
class_name: nginx
tlsHosts:
- read.monitoring.dev.immich.cloud

This file was deleted.

This file was deleted.

This file was deleted.

43 changes: 43 additions & 0 deletions kubernetes/apps/monitoring-dev/victoria-metrics/ingress/write.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: onepassword.com/v1
kind: OnePasswordItem
metadata:
name: vmetrics-write-token
namespace: monitoring-dev
spec:
itemPath: "vaults/Kubernetes/items/vmetrics_write_token"
---
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMUser
metadata:
name: write
namespace: monitoring-dev
labels:
vm-user: "write"
spec:
tokenRef:
name: vmetrics-write-token
key: token
targetRefs:
- crd:
kind: VMSingle
name: vmetrics-dev
namespace: monitoring-dev
paths: ["/write"]
---
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMAuth
metadata:
name: vmetrics-write-ingress
namespace: monitoring-dev
spec:
userSelector:
matchLabels:
vm-user: "write"
ingress:
tlsSecretName: vmetrics-write-tls
annotations:
cert-manager.io/cluster-issuer: letsencrypt-production
class_name: nginx
tlsHosts:
- write.monitoring.dev.immich.cloud
- cf-workers.monitoring.dev.immich.cloud
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./secret.yaml
- ./vmuser.yaml
- ./vmauth.yaml
- ./write.yaml
- ./read.yaml
42 changes: 42 additions & 0 deletions kubernetes/apps/monitoring/victoria-metrics/ingress/read.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: onepassword.com/v1
kind: OnePasswordItem
metadata:
name: vmetrics-read-token
namespace: monitoring
spec:
itemPath: "vaults/Kubernetes/items/vmetrics_read_token"
---
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMUser
metadata:
name: read
namespace: monitoring
labels:
vm-user: "read"
spec:
tokenRef:
name: vmetrics-read-token
key: token
targetRefs:
- crd:
kind: VMSingle
name: vmetrics
namespace: monitoring
paths: ["/targets/api/v1","/targets","/metrics"]
---
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMAuth
metadata:
name: vmetrics-read-ingress
namespace: monitoring
spec:
userSelector:
matchLabels:
vm-user: "read"
ingress:
tlsSecretName: vmetrics-read-tls
annotations:
cert-manager.io/cluster-issuer: letsencrypt-production
class_name: nginx
tlsHosts:
- read.monitoring.immich.cloud

This file was deleted.

16 changes: 0 additions & 16 deletions kubernetes/apps/monitoring/victoria-metrics/ingress/vmauth.yaml

This file was deleted.

15 changes: 0 additions & 15 deletions kubernetes/apps/monitoring/victoria-metrics/ingress/vmuser.yaml

This file was deleted.

43 changes: 43 additions & 0 deletions kubernetes/apps/monitoring/victoria-metrics/ingress/write.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
apiVersion: onepassword.com/v1
kind: OnePasswordItem
metadata:
name: vmetrics-write-token
namespace: monitoring
spec:
itemPath: "vaults/Kubernetes/items/vmetrics_write_token"
---
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMUser
metadata:
name: write
namespace: monitoring
labels:
vm-user: "write"
spec:
tokenRef:
name: vmetrics-write-token
key: token
targetRefs:
- crd:
kind: VMSingle
name: vmetrics
namespace: monitoring
paths: ["/write"]
---
apiVersion: operator.victoriametrics.com/v1beta1
kind: VMAuth
metadata:
name: vmetrics-write-ingress
namespace: monitoring
spec:
userSelector:
matchLabels:
vm-user: "write"
ingress:
tlsSecretName: vmetrics-write-tls
annotations:
cert-manager.io/cluster-issuer: letsencrypt-production
class_name: nginx
tlsHosts:
- write.monitoring.immich.cloud
- cf-workers.monitoring.immich.cloud
22 changes: 22 additions & 0 deletions tf/deployment/modules/1password/account/k8s-secrets.tf
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,28 @@ resource "onepassword_item" "vmetrics_write_token" {
}
}

resource "random_password" "vmetrics_read_token" {
length = 40
special = false
}

resource "onepassword_item" "vmetrics_read_token" {
for_each = { for vault in [data.onepassword_vault.kubernetes, data.onepassword_vault.tf_dev, data.onepassword_vault.tf_prod] : vault.name => vault }
vault = each.value.uuid
title = "vmetrics_read_token"
category = "secure_note"

section {
label = "Victoria Metrics read token"

field {
label = "token"
type = "CONCEALED"
value = random_password.vmetrics_read_token.result
}
}
}

resource "random_password" "bot_github_webhook_slug" {
length = 40
special = false
Expand Down

0 comments on commit 310dd81

Please sign in to comment.