Skip to content

Commit

Permalink
unsaved files
Browse files Browse the repository at this point in the history
  • Loading branch information
lakshmimsft committed Jul 24, 2024
1 parent 4add8fe commit b492f4a
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 52 deletions.
4 changes: 4 additions & 0 deletions .github/config/en-custom.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1249,3 +1249,7 @@ azwi
Entra
ServiceAccounts
pluggable
cyrilgdn
secretStore
postgreSQL
postgres
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
//SECRETSTORE
import radius as radius

@description('Required value, refers to the personal access token or password of the git platform')
@description('username for postgres db')
@secure()
param pat string
param username string

resource secretStoreGit 'Applications.Core/secretStores@2023-10-01-preview' = {
name: 'my-git-secret-store'
@description('password for postgres db')
@secure()
param password string

resource pgsSecretStore 'Applications.Core/secretStores@2023-10-01-preview' = {
name: 'my-secret-store'
properties: {
resource: 'my-secret-namespace/github'
resource: 'my-secret-namespace/my-secret-store'
type: 'generic'
data: {
pat: {
value: pat
username: {
value: username
}
password: {
value: password
}
}
}
Expand All @@ -25,27 +32,37 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = {
properties: {
compute: {
kind: 'kubernetes'
resourceId: 'self'
namespace: 'my-namespace'
}
recipeConfig: {
terraform: {
authentication: {
git: {
pat: {
// The hostname of your git platform, such as 'dev.azure.com' or 'github.com'
'github.com':{
secret: secretStoreGit.id
terraform:{
providers:{
postgresql:[{
sslmode: 'disable'
port: 5432
secrets: {
username: {
source: pgsSecretStore.id
key: username
}
password: {
source: pgsSecretStore.id
key: password
}
}
}
}]
}
}
env: {
PGHOST: 'postgres.corerp-resources-terraform-pg-app.svc.cluster.local'
}
}
recipes: {
'Applications.Datastores/redisCaches': {
default: {
'Applications.Core/extenders': {
defaultpostgres: {
templateKind: 'terraform'
// Git template path
// Recipe template path
templatePath:'git::https://github.com/my-org/my-repo'
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//SECRETSTORE
import radius as radius

@description('username for postgres db')
@description('username for PostgreSQL db')
@secure()
param username string

@description('password for postgres db')
@description('password for PostgreSQL db')
@secure()
param password string

Expand All @@ -27,30 +27,6 @@ resource pgsSecretStore 'Applications.Core/secretStores@2023-10-01-preview' = {
//SECRETSTORE

//ENV
resource env 'Applications.Core/environments@2023-10-01-preview' = {
name: 'my-env'
properties: {
compute: {
kind: 'kubernetes'
namespace: 'my-namespace'
}
recipeConfig: {
terraform: {
authentication: {
git: {
pat: {
// The hostname of your git platform, such as 'dev.azure.com' or 'github.com'
'github.com':{
secret: secretStoreGit.id
}
}
}
}
}
}
}
}

resource env 'Applications.Core/environments@2023-10-01-preview' = {
name: 'my-env'
properties: {
Expand Down Expand Up @@ -82,14 +58,6 @@ resource env 'Applications.Core/environments@2023-10-01-preview' = {
PGHOST: 'postgres.corerp-resources-terraform-pg-app.svc.cluster.local'
}
}
recipes: {
'Applications.Core/extenders': {
defaultpostgres: {
templateKind: 'terraform'
templatePath: 'git::https://github.com/lakshmimsft/lak-temp-public//postgres2'
}
}
}
}
}
//ENV
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
terraform {
required_providers {
kubernetes = {
source = "hashicorp/kubernetes"
version = ">= 2.0"
}
postgresql = {
source = "cyrilgdn/postgresql"
version = "1.16.0"
}
}
}

variable "context" {
description = "This variable contains Radius recipe context."
type = any
}

variable "password" {
description = "The password for the PostgreSQL database"
type = string
}

resource "kubernetes_deployment" "postgres" {
metadata {
name = "postgres"
namespace = var.context.runtime.kubernetes.namespace
}

spec {
selector {
match_labels = {
app = "postgres"
}
}

template {
metadata {
labels = {
app = "postgres"
}
}

spec {
container {
image = "postgres:latest"
name = "postgres"

env {
name = "POSTGRES_PASSWORD"
value = var.password
}

port {
container_port = 5432
}
}
}
}
}
}

resource "kubernetes_service" "postgres" {
metadata {
name = "postgres"
namespace = var.context.runtime.kubernetes.namespace
}

spec {
selector = {
app = "postgres"
}

port {
port = 5432
target_port = 5432
}
}
}

resource "time_sleep" "wait_20_seconds" {
depends_on = [kubernetes_service.postgres]
create_duration = "20s"
}

resource postgresql_database "pg_db_test" {
depends_on = [time_sleep.wait_20_seconds]
name = "pg_db_test"
}

0 comments on commit b492f4a

Please sign in to comment.