init
This commit is contained in:
26
terraform/modules/k8s/crunchy-data/operator/helm.tf
Normal file
26
terraform/modules/k8s/crunchy-data/operator/helm.tf
Normal file
@@ -0,0 +1,26 @@
|
||||
resource "helm_release" "pgo" {
|
||||
name = var.release_name
|
||||
namespace = kubernetes_namespace_v1.this.metadata[0].name
|
||||
|
||||
# Crunchy публикует Helm chart в OCI registry
|
||||
# helm install pgo oci://registry.developers.crunchydata.com/crunchydata/pgo :contentReference[oaicite:2]{index=2}
|
||||
repository = "oci://registry.developers.crunchydata.com/crunchydata"
|
||||
chart = "pgo"
|
||||
version = var.chart_version
|
||||
|
||||
create_namespace = false
|
||||
|
||||
values = [
|
||||
yamlencode({
|
||||
# безопасные дефолты, без лишней магии
|
||||
debug = var.debug
|
||||
replicas = var.replicas
|
||||
|
||||
# Если хочешь ограничить оператор только этим namespace:
|
||||
# singleNamespace = true
|
||||
singleNamespace = var.single_namespace
|
||||
|
||||
installCRDs = true
|
||||
})
|
||||
]
|
||||
}
|
||||
5
terraform/modules/k8s/crunchy-data/operator/namespace.tf
Normal file
5
terraform/modules/k8s/crunchy-data/operator/namespace.tf
Normal file
@@ -0,0 +1,5 @@
|
||||
resource "kubernetes_namespace_v1" "this" {
|
||||
metadata {
|
||||
name = var.namespace
|
||||
}
|
||||
}
|
||||
7
terraform/modules/k8s/crunchy-data/operator/outputs.tf
Normal file
7
terraform/modules/k8s/crunchy-data/operator/outputs.tf
Normal file
@@ -0,0 +1,7 @@
|
||||
output "namespace" {
|
||||
value = kubernetes_namespace_v1.this.metadata[0].name
|
||||
}
|
||||
|
||||
output "release_name" {
|
||||
value = helm_release.pgo.name
|
||||
}
|
||||
33
terraform/modules/k8s/crunchy-data/operator/variables.tf
Normal file
33
terraform/modules/k8s/crunchy-data/operator/variables.tf
Normal file
@@ -0,0 +1,33 @@
|
||||
variable "namespace" {
|
||||
type = string
|
||||
description = "Namespace, куда ставим Crunchy operator"
|
||||
default = "postgres-operator"
|
||||
}
|
||||
|
||||
variable "release_name" {
|
||||
type = string
|
||||
description = "Helm release name"
|
||||
default = "pgo"
|
||||
}
|
||||
|
||||
variable "chart_version" {
|
||||
type = string
|
||||
description = "Версия чарта pgo (пинить обязательно для воспроизводимости)"
|
||||
default = "6.0.0"
|
||||
}
|
||||
|
||||
variable "debug" {
|
||||
type = bool
|
||||
default = false
|
||||
}
|
||||
|
||||
variable "replicas" {
|
||||
type = number
|
||||
default = 1
|
||||
}
|
||||
|
||||
variable "single_namespace" {
|
||||
type = bool
|
||||
description = "Если true — оператор управляет кластерами только в этом namespace"
|
||||
default = true
|
||||
}
|
||||
6
terraform/modules/k8s/crunchy-data/operator/versions.tf
Normal file
6
terraform/modules/k8s/crunchy-data/operator/versions.tf
Normal file
@@ -0,0 +1,6 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
helm = { source = "hashicorp/helm" }
|
||||
kubernetes = { source = "hashicorp/kubernetes" }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
resource "kubernetes_manifest" "postgres_cluster" {
|
||||
manifest = {
|
||||
apiVersion = "postgres-operator.crunchydata.com/v1beta1"
|
||||
kind = "PostgresCluster"
|
||||
|
||||
metadata = {
|
||||
name = var.name
|
||||
namespace = var.namespace
|
||||
}
|
||||
|
||||
spec = {
|
||||
postgresVersion = var.postgres_version
|
||||
|
||||
instances = [
|
||||
{
|
||||
name = "instance1"
|
||||
dataVolumeClaimSpec = {
|
||||
storageClassName = var.storage_class_name
|
||||
accessModes = ["ReadWriteOnce"]
|
||||
resources = {
|
||||
requests = {
|
||||
storage = var.instance_storage
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
backups = {
|
||||
pgbackrest = {
|
||||
repos = [
|
||||
{
|
||||
name = "repo1"
|
||||
volume = {
|
||||
volumeClaimSpec = {
|
||||
storageClassName = var.storage_class_name
|
||||
accessModes = ["ReadWriteOnce"]
|
||||
resources = {
|
||||
requests = {
|
||||
storage = var.backup_storage
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
users = [
|
||||
{
|
||||
name = var.gitlab_db_user
|
||||
databases = [
|
||||
var.gitlab_db_name
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
output "cluster_name" {
|
||||
value = kubernetes_manifest.postgres_cluster.manifest["metadata"]["name"]
|
||||
}
|
||||
|
||||
output "namespace" {
|
||||
value = kubernetes_manifest.postgres_cluster.manifest["metadata"]["namespace"]
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
variable "namespace" {
|
||||
type = string
|
||||
description = "Namespace, где будет PostgresCluster"
|
||||
default = "postgres-operator"
|
||||
}
|
||||
|
||||
variable "name" {
|
||||
type = string
|
||||
description = "Имя PostgresCluster"
|
||||
default = "hippo"
|
||||
}
|
||||
|
||||
variable "storage_class_name" {
|
||||
type = string
|
||||
description = "StorageClass для PVC (твой Ceph CSI RBD), например: ceph-rbd"
|
||||
default = "ceph-rbd"
|
||||
}
|
||||
|
||||
variable "postgres_version" {
|
||||
type = number
|
||||
description = "Major версия PostgreSQL (ставь ту, которую поддерживает твой CPK)"
|
||||
default = 16
|
||||
}
|
||||
|
||||
variable "instance_storage" {
|
||||
type = string
|
||||
description = "Размер диска под data"
|
||||
default = "10Gi"
|
||||
}
|
||||
|
||||
variable "backup_storage" {
|
||||
type = string
|
||||
description = "Размер диска под pgBackRest repo"
|
||||
default = "10Gi"
|
||||
}
|
||||
|
||||
variable "gitlab_db_user" {
|
||||
type = string
|
||||
default = "gitlab"
|
||||
}
|
||||
|
||||
variable "gitlab_db_name" {
|
||||
type = string
|
||||
default = "gitlabhq_production"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
kubernetes = {
|
||||
source = "hashicorp/kubernetes"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user