mirror of
https://github.com/dat515-2025/Group-8.git
synced 2026-03-22 15:12:08 +01:00
feat(infrastructure): add redis sentinel cluster
This commit is contained in:
14
tofu/main.tf
14
tofu/main.tf
@@ -16,6 +16,10 @@ terraform {
|
|||||||
source = "kbst/kustomization"
|
source = "kbst/kustomization"
|
||||||
version = "0.9.6"
|
version = "0.9.6"
|
||||||
}
|
}
|
||||||
|
time = {
|
||||||
|
source = "hashicorp/time"
|
||||||
|
version = "0.13.1"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,7 +84,7 @@ module "database" {
|
|||||||
secondary_ip = var.metallb_secondary_ip
|
secondary_ip = var.metallb_secondary_ip
|
||||||
|
|
||||||
phpmyadmin_enabled = var.phpmyadmin_enabled
|
phpmyadmin_enabled = var.phpmyadmin_enabled
|
||||||
cloudflare_domain = var.cloudflare_domain
|
cloudflare_domain = var.cloudflare_domain
|
||||||
}
|
}
|
||||||
|
|
||||||
module "argocd" {
|
module "argocd" {
|
||||||
@@ -88,5 +92,11 @@ module "argocd" {
|
|||||||
depends_on = [module.storage, module.loadbalancer, module.cloudflare]
|
depends_on = [module.storage, module.loadbalancer, module.cloudflare]
|
||||||
|
|
||||||
argocd_admin_password = var.argocd_admin_password
|
argocd_admin_password = var.argocd_admin_password
|
||||||
cloudflare_domain = var.cloudflare_domain
|
cloudflare_domain = var.cloudflare_domain
|
||||||
|
}
|
||||||
|
|
||||||
|
module "redis" {
|
||||||
|
source = "${path.module}/modules/redis"
|
||||||
|
depends_on = [module.storage]
|
||||||
|
cloudflare_base_domain = var.cloudflare_domain
|
||||||
}
|
}
|
||||||
@@ -27,10 +27,6 @@ resource "helm_release" "argocd" {
|
|||||||
repository = "https://argoproj.github.io/argo-helm"
|
repository = "https://argoproj.github.io/argo-helm"
|
||||||
chart = "argo-cd"
|
chart = "argo-cd"
|
||||||
depends_on = [kubernetes_namespace.argocd]
|
depends_on = [kubernetes_namespace.argocd]
|
||||||
|
|
||||||
set = [
|
|
||||||
{ name = "configs.secret.argocdServerAdminPassword", value = bcrypt(var.argocd_admin_password) },
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resource "kubectl_manifest" "argocd-tunnel-bind" {
|
resource "kubectl_manifest" "argocd-tunnel-bind" {
|
||||||
|
|||||||
68
tofu/modules/redis/main.tf
Normal file
68
tofu/modules/redis/main.tf
Normal 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
|
||||||
|
})
|
||||||
|
}
|
||||||
14
tofu/modules/redis/redis-ui.yaml
Normal file
14
tofu/modules/redis/redis-ui.yaml
Normal 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
|
||||||
28
tofu/modules/redis/replication.yaml
Normal file
28
tofu/modules/redis/replication.yaml
Normal 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
|
||||||
22
tofu/modules/redis/sentinel.yaml
Normal file
22
tofu/modules/redis/sentinel.yaml
Normal 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
|
||||||
5
tofu/modules/redis/variables.tf
Normal file
5
tofu/modules/redis/variables.tf
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
variable "cloudflare_base_domain" {
|
||||||
|
type = string
|
||||||
|
description = "Base domain for Cloudflare DNS records"
|
||||||
|
nullable = false
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user