mirror of
https://gitlab.sarex.io/infra/terraform-contour-mirror.git
synced 2026-08-05 18:31:00 +03:00
++ minio host configurable in yaml, incluster runner
This commit is contained in:
parent
461981e4eb
commit
973a9dc6a5
@ -38,7 +38,7 @@ env:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
validate:
|
validate:
|
||||||
runs-on: ${{ vars.RUNNER_LABEL || 'ubuntu-latest' }}
|
runs-on: ${{ vars.RUNNER_LABEL || 'incluster' }}
|
||||||
container:
|
container:
|
||||||
image: ${{ vars.RUNNER_IMAGE || 'cr.yandex/crp3ccidau046kdj8g9q/terraform/terragrunt:v9.11' }}
|
image: ${{ vars.RUNNER_IMAGE || 'cr.yandex/crp3ccidau046kdj8g9q/terraform/terragrunt:v9.11' }}
|
||||||
env:
|
env:
|
||||||
@ -88,7 +88,7 @@ jobs:
|
|||||||
|
|
||||||
plan:
|
plan:
|
||||||
needs: [validate]
|
needs: [validate]
|
||||||
runs-on: ${{ vars.RUNNER_LABEL || 'ubuntu-latest' }}
|
runs-on: ${{ vars.RUNNER_LABEL || 'incluster' }}
|
||||||
container:
|
container:
|
||||||
image: ${{ vars.RUNNER_IMAGE || 'cr.yandex/crp3ccidau046kdj8g9q/terraform/terragrunt:v9.11' }}
|
image: ${{ vars.RUNNER_IMAGE || 'cr.yandex/crp3ccidau046kdj8g9q/terraform/terragrunt:v9.11' }}
|
||||||
env:
|
env:
|
||||||
@ -137,7 +137,7 @@ jobs:
|
|||||||
apply:
|
apply:
|
||||||
needs: [plan]
|
needs: [plan]
|
||||||
if: github.event_name == 'push'
|
if: github.event_name == 'push'
|
||||||
runs-on: ${{ vars.RUNNER_LABEL || 'ubuntu-latest' }}
|
runs-on: ${{ vars.RUNNER_LABEL || 'incluster' }}
|
||||||
container:
|
container:
|
||||||
image: ${{ vars.RUNNER_IMAGE || 'cr.yandex/crp3ccidau046kdj8g9q/terraform/terragrunt:v9.11' }}
|
image: ${{ vars.RUNNER_IMAGE || 'cr.yandex/crp3ccidau046kdj8g9q/terraform/terragrunt:v9.11' }}
|
||||||
env:
|
env:
|
||||||
|
|||||||
@ -15,6 +15,11 @@ environments:
|
|||||||
annotations:
|
annotations:
|
||||||
managed-by: terraform
|
managed-by: terraform
|
||||||
|
|
||||||
|
# MinIO endpoint (declarative). Exposed externally on this contour; scheme
|
||||||
|
# decides TLS. Admin creds are injected from Vault (secrets/minio/admin).
|
||||||
|
minio:
|
||||||
|
endpoint: https://minio.contour.infra.sarex.tech
|
||||||
|
|
||||||
# In-cluster MinIO. Bucket + dedicated access user (access_key/secret_key).
|
# In-cluster MinIO. Bucket + dedicated access user (access_key/secret_key).
|
||||||
buckets:
|
buckets:
|
||||||
- name: test-bucket
|
- name: test-bucket
|
||||||
|
|||||||
@ -45,4 +45,9 @@ terraform {
|
|||||||
|
|
||||||
inputs = {
|
inputs = {
|
||||||
buckets = try(local.env_config.buckets, [])
|
buckets = try(local.env_config.buckets, [])
|
||||||
|
|
||||||
|
# MinIO endpoint is declarative (infrastructure.yaml); admin creds come from Vault.
|
||||||
|
minio_endpoint = try(local.env_config.minio.endpoint, "http://minio.minio.svc.cluster.local:9000")
|
||||||
|
minio_user = get_env("MINIO_ADMIN_USER", "")
|
||||||
|
minio_password = get_env("MINIO_ADMIN_PASSWORD", "")
|
||||||
}
|
}
|
||||||
|
|||||||
@ -122,7 +122,7 @@ inputs = {
|
|||||||
|
|
||||||
# In-cluster constants (contour). No managed-YC CA; in-cluster pgbouncer/pg on 5432.
|
# In-cluster constants (contour). No managed-YC CA; in-cluster pgbouncer/pg on 5432.
|
||||||
constants = {
|
constants = {
|
||||||
s3_endpoint = get_env("MINIO_PUBLIC_ENDPOINT", "http://minio.minio.svc.cluster.local:9000")
|
s3_endpoint = try(local.infra_config.environments[local.env_name].minio.endpoint, "http://minio.minio.svc.cluster.local:9000")
|
||||||
postgres_port = "5432"
|
postgres_port = "5432"
|
||||||
postgres_ca = ""
|
postgres_ca = ""
|
||||||
valkey_port = "6379"
|
valkey_port = "6379"
|
||||||
|
|||||||
@ -94,12 +94,8 @@ provider "kafka" {
|
|||||||
# RabbitMQ provider is configured INSIDE modules/rabbitmq (from its management_*
|
# RabbitMQ provider is configured INSIDE modules/rabbitmq (from its management_*
|
||||||
# inputs), so it is intentionally NOT generated here to avoid a duplicate config.
|
# inputs), so it is intentionally NOT generated here to avoid a duplicate config.
|
||||||
|
|
||||||
# In-cluster MinIO S3 API. Admin from Vault secrets/minio/admin.
|
# MinIO provider is configured INSIDE modules/minio-buckets (endpoint from
|
||||||
provider "minio" {
|
# infrastructure.yaml, admin creds from Vault via the s3 unit), so it is not
|
||||||
minio_server = "${get_env("MINIO_ENDPOINT", "minio.minio.svc.cluster.local:9000")}"
|
# generated here.
|
||||||
minio_user = "${get_env("MINIO_ADMIN_USER", "")}"
|
|
||||||
minio_password = "${get_env("MINIO_ADMIN_PASSWORD", "")}"
|
|
||||||
minio_ssl = false
|
|
||||||
}
|
|
||||||
EOF_PROVIDER
|
EOF_PROVIDER
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,18 @@
|
|||||||
|
# Self-configured MinIO provider (like modules/rabbitmq): the endpoint comes from
|
||||||
|
# infrastructure.yaml, so the host is declarative; admin creds are injected from
|
||||||
|
# Vault via the s3 unit. Scheme in minio_endpoint decides TLS.
|
||||||
|
locals {
|
||||||
|
minio_ssl = can(regex("^https://", var.minio_endpoint))
|
||||||
|
minio_server = replace(replace(trimsuffix(var.minio_endpoint, "/"), "https://", ""), "http://", "")
|
||||||
|
}
|
||||||
|
|
||||||
|
provider "minio" {
|
||||||
|
minio_server = local.minio_server
|
||||||
|
minio_user = var.minio_user
|
||||||
|
minio_password = var.minio_password
|
||||||
|
minio_ssl = local.minio_ssl
|
||||||
|
}
|
||||||
|
|
||||||
# In-cluster MinIO implementation of the `buckets` entity contract. Per bucket:
|
# In-cluster MinIO implementation of the `buckets` entity contract. Per bucket:
|
||||||
# create the bucket, a dedicated access user (access_key/secret_key) and a policy
|
# create the bucket, a dedicated access user (access_key/secret_key) and a policy
|
||||||
# granting that user full access to only its bucket — mirroring yc-s3, which
|
# granting that user full access to only its bucket — mirroring yc-s3, which
|
||||||
@ -63,6 +78,6 @@ resource "minio_iam_policy" "this" {
|
|||||||
resource "minio_iam_user_policy_attachment" "this" {
|
resource "minio_iam_user_policy_attachment" "this" {
|
||||||
for_each = local.buckets_map
|
for_each = local.buckets_map
|
||||||
|
|
||||||
user_name = minio_iam_user.this[each.key].name
|
user_name = minio_iam_user.this[each.key].name
|
||||||
policy_name = minio_iam_policy.this[each.key].name
|
policy_name = minio_iam_policy.this[each.key].name
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,3 +28,21 @@ variable "user_suffix" {
|
|||||||
type = string
|
type = string
|
||||||
default = "-sa"
|
default = "-sa"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
variable "minio_endpoint" {
|
||||||
|
description = "MinIO S3 endpoint URL (scheme decides ssl). E.g. https://minio.contour.infra.sarex.tech"
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "minio_user" {
|
||||||
|
description = "MinIO admin access key."
|
||||||
|
type = string
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "minio_password" {
|
||||||
|
description = "MinIO admin secret key."
|
||||||
|
type = string
|
||||||
|
default = ""
|
||||||
|
sensitive = true
|
||||||
|
}
|
||||||
|
|||||||
@ -12,7 +12,7 @@ set -eu
|
|||||||
|
|
||||||
_kv() {
|
_kv() {
|
||||||
# $1=path $2=key -> value on stdout; loud diagnostic to stderr on http error
|
# $1=path $2=key -> value on stdout; loud diagnostic to stderr on http error
|
||||||
_code=$(curl -s -o /tmp/_kv.json -w '%{http_code}' -H "X-Vault-Token: ${VAULT_TOKEN}" "${VAULT_ADDR}/v1/secrets/data/$1" || echo 000)
|
_code=$(curl -s -o /tmp/_kv.json -w '%{http_code}' -H "X-Vault-Token: ${VAULT_TOKEN}" "${VAULT_ADDR}/v1/secrets/data/$1") || true
|
||||||
if [ "$_code" != "200" ]; then
|
if [ "$_code" != "200" ]; then
|
||||||
echo "load_admin_creds: cannot read secrets/$1 (http ${_code}) — check VAULT_TOKEN policy and VAULT_ADDR" >&2
|
echo "load_admin_creds: cannot read secrets/$1 (http ${_code}) — check VAULT_TOKEN policy and VAULT_ADDR" >&2
|
||||||
printf ''
|
printf ''
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user