First commit
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
**/*.auto.tfvars
|
||||||
22
helm_values/postgresql.yaml
Normal file
22
helm_values/postgresql.yaml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
global:
|
||||||
|
defaultStorageClass: standard
|
||||||
|
postgresql:
|
||||||
|
auth:
|
||||||
|
username: ${postgres_user}
|
||||||
|
password: ${postgres_password}
|
||||||
|
primary:
|
||||||
|
extraEnvVars:
|
||||||
|
- name: VELA_USER
|
||||||
|
value: ${vela_user}
|
||||||
|
- name: VELA_PASSWORD
|
||||||
|
value: ${vela_password}
|
||||||
|
initdb:
|
||||||
|
scripts:
|
||||||
|
user: ${postgres_user}
|
||||||
|
password: ${postgres_password}
|
||||||
|
db_init_script.sh: |
|
||||||
|
PGPASSWORD=$${POSTGRES_PASSWORD} psql -U $${POSTGRES_USER} <<-END
|
||||||
|
CREATE USER $${VELA_USER} WITH PASSWORD '$${VELA_PASSWORD}';
|
||||||
|
SELECT 'CREATE DATABASE vela WITH OWNER $${VELA_USER}' WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname = 'vela')\gexec
|
||||||
|
GRANT ALL PRIVILEGES ON DATABASE vela TO $${VELA_USER};
|
||||||
|
END
|
||||||
15
postgres.tf
Normal file
15
postgres.tf
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
resource "helm_release" "postgresql" {
|
||||||
|
name = "postgresql"
|
||||||
|
repository = "https://charts.bitnami.com/bitnami"
|
||||||
|
chart = "postgresql"
|
||||||
|
namespace = "default"
|
||||||
|
create_namespace = false
|
||||||
|
version = "15.5.23"
|
||||||
|
|
||||||
|
values = [templatefile("${path.module}/helm_values/postgresql.yaml", {
|
||||||
|
postgres_user = "${var.POSTGRES_USER}"
|
||||||
|
postgres_password = "${var.POSTGRES_PASSWORD}"
|
||||||
|
vela_user = "${var.VELA_USER}"
|
||||||
|
vela_password = "${var.VELA_PASSWORD}"
|
||||||
|
})]
|
||||||
|
}
|
||||||
16
providers.tf
Normal file
16
providers.tf
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
provider "helm" {
|
||||||
|
kubernetes {
|
||||||
|
config_path = "~/.kube/config"
|
||||||
|
config_context = "minikube"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
provider "kubectl" {
|
||||||
|
config_path = "~/.kube/conifg"
|
||||||
|
config_context = "minikube"
|
||||||
|
}
|
||||||
|
|
||||||
|
provider kubernetes {
|
||||||
|
config_path = "~/.kube/config"
|
||||||
|
config_context = "minikube"
|
||||||
|
}
|
||||||
15
terraform.tf
Normal file
15
terraform.tf
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
terraform {
|
||||||
|
required_providers {
|
||||||
|
helm = {
|
||||||
|
source = "hashicorp/helm"
|
||||||
|
}
|
||||||
|
|
||||||
|
kubectl = {
|
||||||
|
source = "gavinbunney/kubectl"
|
||||||
|
}
|
||||||
|
|
||||||
|
kubernetes = {
|
||||||
|
source = "hashicorp/kubernetes"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
15
variables.tf
Normal file
15
variables.tf
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
variable "POSTGRES_USER" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "POSTGRES_PASSWORD" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "VELA_USER" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "VELA_PASSWORD" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user