-
Notifications
You must be signed in to change notification settings - Fork 14
Model secrets as a property of PostgreSql Databases #95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
9290024
3a5a62e
3da10b6
09530c9
680e24c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,21 +1,26 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||
| @description('Information about what resource is calling this Recipe. Generated by Radius.') | ||||||||||||||||||||||||||||||||||||||||||||||||
| param context object | ||||||||||||||||||||||||||||||||||||||||||||||||
| extension kubernetes with { | ||||||||||||||||||||||||||||||||||||||||||||||||
| kubeConfig: '' | ||||||||||||||||||||||||||||||||||||||||||||||||
| namespace: context.runtime.kubernetes.namespace | ||||||||||||||||||||||||||||||||||||||||||||||||
| } as kubernetes | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| @description('Name of the PostgreSQL database. Defaults to the name of the Radius resource.') | ||||||||||||||||||||||||||||||||||||||||||||||||
| param database string = context.resource.name | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| @description('PostgreSQL username') | ||||||||||||||||||||||||||||||||||||||||||||||||
| param user string = 'postgres' | ||||||||||||||||||||||||||||||||||||||||||||||||
| ////////////////////////////////////////// | ||||||||||||||||||||||||||||||||||||||||||||||||
| // Common Radius variables | ||||||||||||||||||||||||||||||||||||||||||||||||
| ////////////////////////////////////////// | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| @description('PostgreSQL password') | ||||||||||||||||||||||||||||||||||||||||||||||||
| @secure() | ||||||||||||||||||||||||||||||||||||||||||||||||
| #disable-next-line secure-parameter-default | ||||||||||||||||||||||||||||||||||||||||||||||||
| param password string = uniqueString(context.resource.id) | ||||||||||||||||||||||||||||||||||||||||||||||||
| @description('Information about what resource is calling this Recipe. Generated by Radius.') | ||||||||||||||||||||||||||||||||||||||||||||||||
| param context object | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| @description('Tag to pull for the postgres container image.') | ||||||||||||||||||||||||||||||||||||||||||||||||
| param tag string = '16-alpine' | ||||||||||||||||||||||||||||||||||||||||||||||||
| ////////////////////////////////////////// | ||||||||||||||||||||||||||||||||||||||||||||||||
| // PostgreSQL variables | ||||||||||||||||||||||||||||||||||||||||||||||||
| ////////////////////////////////////////// | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| @description('Memory limits for the PostgreSQL container') | ||||||||||||||||||||||||||||||||||||||||||||||||
| var resourceName = context.resource.name | ||||||||||||||||||||||||||||||||||||||||||||||||
| var namespace = context.runtime.kubernetes.namespace | ||||||||||||||||||||||||||||||||||||||||||||||||
| var dbSecretName = context.resource.properties.secretName | ||||||||||||||||||||||||||||||||||||||||||||||||
| var database string = 'postgres_db' | ||||||||||||||||||||||||||||||||||||||||||||||||
| var tag string = '16-alpine' | ||||||||||||||||||||||||||||||||||||||||||||||||
| var port = 5432 | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should all of these be populated when deploying Recipes? I think we should prioritize this issue -#60 and not have users write so much code to get Radius metadata. |
||||||||||||||||||||||||||||||||||||||||||||||||
| var memory ={ | ||||||||||||||||||||||||||||||||||||||||||||||||
| S: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| memoryRequest: '512Mi' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -28,33 +33,26 @@ var memory ={ | |||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| extension kubernetes with { | ||||||||||||||||||||||||||||||||||||||||||||||||
| kubeConfig: '' | ||||||||||||||||||||||||||||||||||||||||||||||||
| namespace: context.runtime.kubernetes.namespace | ||||||||||||||||||||||||||||||||||||||||||||||||
| } as kubernetes | ||||||||||||||||||||||||||||||||||||||||||||||||
| ////////////////////////////////////////// | ||||||||||||||||||||||||||||||||||||||||||||||||
| // PostgreSQL Deployment | ||||||||||||||||||||||||||||||||||||||||||||||||
| ////////////////////////////////////////// | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| var uniqueName = 'postgres-${uniqueString(context.resource.id)}' | ||||||||||||||||||||||||||||||||||||||||||||||||
| var port = 5432 | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| // Based on https://hub.docker.com/_/postgres/ | ||||||||||||||||||||||||||||||||||||||||||||||||
| resource postgresql 'apps/Deployment@v1' = { | ||||||||||||||||||||||||||||||||||||||||||||||||
| metadata: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| name: uniqueName | ||||||||||||||||||||||||||||||||||||||||||||||||
| name: resourceName | ||||||||||||||||||||||||||||||||||||||||||||||||
| namespace: namespace | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| spec: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| selector: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| matchLabels: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| app: 'postgresql' | ||||||||||||||||||||||||||||||||||||||||||||||||
| resource: context.resource.name | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| template: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| metadata: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| labels: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| app: 'postgresql' | ||||||||||||||||||||||||||||||||||||||||||||||||
| resource: context.resource.name | ||||||||||||||||||||||||||||||||||||||||||||||||
| // Label pods with the application name so `rad run` can find the logs. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 'radapp.io/application': context.application == null ? '' : context.application.name | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| spec: { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -76,11 +74,21 @@ resource postgresql 'apps/Deployment@v1' = { | |||||||||||||||||||||||||||||||||||||||||||||||
| env: [ | ||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||
| name: 'POSTGRES_USER' | ||||||||||||||||||||||||||||||||||||||||||||||||
| value: user | ||||||||||||||||||||||||||||||||||||||||||||||||
| valueFrom: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| secretKeyRef: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| name: dbSecretName | ||||||||||||||||||||||||||||||||||||||||||||||||
| key: 'username' | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||
| name: 'POSTGRES_PASSWORD' | ||||||||||||||||||||||||||||||||||||||||||||||||
| value: password | ||||||||||||||||||||||||||||||||||||||||||||||||
| valueFrom: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| secretKeyRef: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| name: dbSecretName | ||||||||||||||||||||||||||||||||||||||||||||||||
| key: 'password' | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||
| name: 'POSTGRES_DB' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -96,16 +104,13 @@ resource postgresql 'apps/Deployment@v1' = { | |||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| resource svc 'core/Service@v1' = { | ||||||||||||||||||||||||||||||||||||||||||||||||
| metadata: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| name: uniqueName | ||||||||||||||||||||||||||||||||||||||||||||||||
| labels: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| name: uniqueName | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| name: resourceName | ||||||||||||||||||||||||||||||||||||||||||||||||
| namespace: namespace | ||||||||||||||||||||||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| spec: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| type: 'ClusterIP' | ||||||||||||||||||||||||||||||||||||||||||||||||
| selector: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| app: 'postgresql' | ||||||||||||||||||||||||||||||||||||||||||||||||
| resource: context.resource.name | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| ports: [ | ||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -115,6 +120,10 @@ resource svc 'core/Service@v1' = { | |||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| ////////////////////////////////////////// | ||||||||||||||||||||||||||||||||||||||||||||||||
| // Output Radius result | ||||||||||||||||||||||||||||||||||||||||||||||||
| ////////////////////////////////////////// | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||
| output result object = { | ||||||||||||||||||||||||||||||||||||||||||||||||
| resources: [ | ||||||||||||||||||||||||||||||||||||||||||||||||
| '/planes/kubernetes/local/namespaces/${svc.metadata.namespace}/providers/core/Service/${svc.metadata.name}' | ||||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -124,10 +133,5 @@ output result object = { | |||||||||||||||||||||||||||||||||||||||||||||||
| host: '${svc.metadata.name}.${svc.metadata.namespace}.svc.cluster.local' | ||||||||||||||||||||||||||||||||||||||||||||||||
| port: port | ||||||||||||||||||||||||||||||||||||||||||||||||
| database: database | ||||||||||||||||||||||||||||||||||||||||||||||||
| username: user | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| secrets: { | ||||||||||||||||||||||||||||||||||||||||||||||||
| #disable-next-line outputs-should-not-contain-secrets | ||||||||||||||||||||||||||||||||||||||||||||||||
| password: password | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be