feat(infrastructure): add redis sentinel cluster

This commit is contained in:
2025-09-23 10:48:40 +02:00
parent 812042576a
commit d3cfaba274
7 changed files with 150 additions and 7 deletions

View File

@@ -27,10 +27,6 @@ resource "helm_release" "argocd" {
repository = "https://argoproj.github.io/argo-helm"
chart = "argo-cd"
depends_on = [kubernetes_namespace.argocd]
set = [
{ name = "configs.secret.argocdServerAdminPassword", value = bcrypt(var.argocd_admin_password) },
]
}
resource "kubectl_manifest" "argocd-tunnel-bind" {

View File

@@ -0,0 +1,68 @@
terraform {
required_providers {
kubectl = {
source = "gavinbunney/kubectl"
version = "1.19.0"
}
helm = {
source = "hashicorp/helm"
version = "3.0.2"
}
kubernetes = {
source = "hashicorp/kubernetes"
version = "2.38.0"
}
kustomization = {
source = "kbst/kustomization"
version = "0.9.6"
}
time = {
source = "hashicorp/time"
version = "0.13.1"
}
}
}
resource "helm_release" "redis_operator" {
name = "redis-operator"
repository = "https://ot-container-kit.github.io/helm-charts/"
chart = "redis-operator"
namespace = "ot-operators"
create_namespace = true
}
resource "kubectl_manifest" "replication" {
yaml_body = templatefile("${path.module}/replication.yaml", {})
depends_on = [helm_release.redis_operator]
}
resource "kubectl_manifest" "sentinel" {
yaml_body = templatefile("${path.module}/sentinel.yaml", {})
depends_on = [kubectl_manifest.replication]
}
resource "helm_release" "redisinsight_gui" {
name = "redisinsight-gui"
repository = "https://mrnim94.github.io/redisinsight/"
chart = "redisinsight"
namespace = "ot-operators"
create_namespace = false
version = "1.3.1" # ověř verzi podle ArtifactHub / podle toho koho chceš použít
depends_on = [kubectl_manifest.sentinel]
# případně values
# values = [file("${path.module}/values-redisinsight.yaml")]
set = [{
#name = "persistence.storageClassName"
#value = "longhorn"
name = "persistence.enabled"
value = "false"
}]
}
resource "kubectl_manifest" "redis-ui" {
yaml_body = templatefile("${path.module}/redis-ui.yaml", {
base_domain = var.cloudflare_base_domain
})
}

View File

@@ -0,0 +1,14 @@
apiVersion: networking.cfargotunnel.com/v1alpha1
kind: TunnelBinding
metadata:
name: argocd-tunnel-binding
namespace: ot-operators
subjects:
- name: redis-gui
spec:
target: http://redisinsight-gui.ot-operators.svc.cluster.local:5540
fqdn: redis.${base_domain}
noTlsVerify: true
tunnelRef:
kind: ClusterTunnel
name: cluster-tunnel

View File

@@ -0,0 +1,28 @@
apiVersion: redis.redis.opstreelabs.in/v1beta2
kind: RedisReplication
metadata:
name: redis-replication
namespace: ot-operators
spec:
clusterSize: 3
podSecurityContext:
runAsUser: 1000
fsGroup: 1000
kubernetesConfig:
image: quay.io/opstree/redis:v8.2.1
imagePullPolicy: IfNotPresent
resources:
requests:
cpu: 101m
memory: 128Mi
limits:
cpu: 101m
memory: 128Mi
storage:
volumeClaimTemplate:
spec:
storageClassName: longhorn
accessModes: ["ReadWriteOnce"]
resources:
requests:
storage: 5Gi

View File

@@ -0,0 +1,22 @@
apiVersion: redis.redis.opstreelabs.in/v1beta2
kind: RedisSentinel
metadata:
name: redis-sentinel
namespace: ot-operators
spec:
clusterSize: 3
podSecurityContext:
runAsUser: 1000
fsGroup: 1000
redisSentinelConfig:
redisReplicationName : redis-replication
kubernetesConfig:
image: quay.io/opstree/redis-sentinel:v8.2.1
imagePullPolicy: IfNotPresent
resources:
requests:
cpu: 101m
memory: 128Mi
limits:
cpu: 101m
memory: 128Mi

View File

@@ -0,0 +1,5 @@
variable "cloudflare_base_domain" {
type = string
description = "Base domain for Cloudflare DNS records"
nullable = false
}