Skip to content

Commit abd4152

Browse files
committed
add data
Signed-off-by: willdavsmith <willdavsmith@gmail.com>
1 parent e5e7423 commit abd4152

3 files changed

Lines changed: 306 additions & 1 deletion

File tree

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
namespace: Radius.Data
2+
location:
3+
global: "http://localhost:8082"
4+
types:
5+
mySqlDatabases:
6+
description: |
7+
The Radius.Data/mySqlDatabases Resource Type deploys a MySQL database. To deploy a new MySQL database, first add a secret resource with the database credentials to the application definition Bicep file, then add a mySqlDatabases resource referencing the secret name.
8+
```
9+
resource mysql 'Radius.Data/mySqlDatabases@2025-08-01-preview' = {
10+
name: 'mysql'
11+
properties: {
12+
environment: environment
13+
application: myApplication.id
14+
secretName: dbCredentials.name
15+
}
16+
}
17+
18+
resource dbCredentials 'Radius.Security/secrets@2025-08-01-preview' = {
19+
name: 'db-creds'
20+
properties: {
21+
environment: environment
22+
application: myApplication.id
23+
data: {
24+
USERNAME: {
25+
value: 'admin'
26+
}
27+
PASSWORD: {
28+
# From password parameter passed in via CLI
29+
value: password
30+
}
31+
}
32+
}
33+
}
34+
```
35+
36+
When deploying the application definition, provide the database password value as a parameter. It is recommended to use a password generator such as `openssl` or equivalent. For example, `rad deploy app.bicep -p password=$(openssl rand -hex 16)`.
37+
38+
To connect your container to the database, create a connection from the Container resource to the database as shown below.
39+
```
40+
resource myApplication 'Radius.Core/Applications@2025-08-01-preview' = { ... }
41+
42+
resource frontend 'Radius.Compute/containers@2025-08-01-preview' = {
43+
name: 'frontend'
44+
properties: {
45+
application: myApplication.id
46+
environment: environment
47+
container: {
48+
image: 'frontend:1.25'
49+
ports: {
50+
web: {
51+
containerPort: 8080
52+
}
53+
}
54+
}
55+
connections: {
56+
mysqldb: {
57+
source: database.id
58+
}
59+
}
60+
}
61+
}
62+
```
63+
64+
The connection automatically injects environment variables into the container for all properties from the database. The environment variables are named `CONNECTION_<CONNECTION-NAME>_<PROPERTY-NAME>`. In this example, the connection name is `mysqldb` so the environment variables will be:
65+
66+
- CONNECTION_MYSQLDB_DATABASE
67+
- CONNECTION_MYSQLDB_HOST
68+
- CONNECTION_MYSQLDB_PORT
69+
70+
apiVersions:
71+
'2025-08-01-preview':
72+
schema:
73+
type: object
74+
properties:
75+
environment:
76+
type: string
77+
description: "(Required) The Radius EnvironmentID. Typically set by the rad CLI. Typically value should be `environment`"
78+
application:
79+
type: string
80+
description: "(Optional) The Radius Application ID. `myApplication.id` for example."
81+
database:
82+
type: string
83+
description: "(Optional) The name of the database. Defaults to `mysql_db` if not provided."
84+
secretName:
85+
type: string
86+
description: "(Required) The name of the secret containing the database credentials."
87+
version:
88+
type: string
89+
enum: ['5.7', '8.0', '8.4']
90+
description: "(Optional) The major MySQL server version in the X.Y format. Assumed to be 8.4 if not specified."
91+
host:
92+
type: string
93+
description: "(Read-only) The host name used to connect to the database."
94+
readOnly: true
95+
port:
96+
type: integer
97+
description: "(Read-only) The port number used to connect to the database."
98+
readOnly: true
99+
required: [environment,secretName]

‎deploy/manifest/built-in-providers/self-hosted/radius_compute.yaml‎

Lines changed: 108 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace: Radius.Compute
22
location:
3-
global: "http://dynamic-rp.radius-system:8082"
3+
global: "http://localhost:8082"
44
types:
55
containers:
66
description: |
@@ -727,3 +727,110 @@ types:
727727
enum: [ReadWriteOnce, ReadOnlyMany, ReadWriteMany]
728728
description: (Optional) The access modes which are permitted to be requested by a Container. Assumed to be all modes if not specified.
729729
required: [environment, sizeInGib]
730+
containerImages:
731+
description: |
732+
The Radius.Compute/containerImages Resource Type builds a container image from source and pushes it to a container registry. It is always part of a Radius Application.
733+
734+
This resource type is designed for local development workflows where the source code is available on the Kubernetes node filesystem (e.g., via kind `extraMounts` or k3d `-v` flags). It uses BuildKit to build and push the image.
735+
736+
To build and push a container image, add a containerImages resource to your application definition Bicep file:
737+
738+
extension radius
739+
extension containerImages
740+
741+
param environment string
742+
743+
resource myApp 'Radius.Core/applications@2025-08-01-preview' = {
744+
name: 'myApp'
745+
properties: {
746+
environment: environment
747+
}
748+
}
749+
750+
resource myImage 'Radius.Compute/containerImages@2025-08-01-preview' = {
751+
name: 'myImage'
752+
properties: {
753+
environment: environment
754+
application: myApp.id
755+
image: 'ghcr.io/myorg/myapp:latest'
756+
build: {
757+
context: '/app/src/myapp'
758+
}
759+
}
760+
}
761+
762+
Registry credentials are configured by the platform engineer when registering the recipe. Developers do not need to manage credentials.
763+
764+
To reference the built image in a Container resource:
765+
766+
resource myContainer 'Radius.Compute/containers@2025-08-01-preview' = {
767+
name: 'myContainer'
768+
properties: {
769+
environment: environment
770+
application: myApp.id
771+
containers: {
772+
app: {
773+
image: myImage.properties.image
774+
ports: {
775+
web: {
776+
containerPort: 3000
777+
}
778+
}
779+
}
780+
}
781+
}
782+
}
783+
784+
Prerequisites:
785+
786+
1. The Kubernetes cluster must have the source directory available on the node. For kind, use `extraMounts`. For k3d, use `-v` flags.
787+
788+
2. Registry credentials must be configured as recipe parameters when registering the recipe:
789+
790+
rad recipe register default --resource-type Radius.Compute/containerImages --template-kind terraform --template-path git::https://github.com/radius-project/resource-types-contrib.git//Compute/containerImages/recipes/kubernetes/terraform --parameters ghcr_username=USERNAME --parameters ghcr_token=PAT
791+
792+
apiVersions:
793+
'2025-08-01-preview':
794+
schema:
795+
type: object
796+
properties:
797+
environment:
798+
type: string
799+
description: (Required) The Radius Environment ID. Typically set by the rad CLI. Typically value should be `environment`.
800+
application:
801+
type: string
802+
description: (Required) The Radius Application ID. `myApplication.id` for example.
803+
image:
804+
type: string
805+
description: (Required) The full container image reference including registry, repository, and tag. `ghcr.io/myorg/myapp:latest` for example. Must be lowercase.
806+
build:
807+
type: object
808+
description: (Required) Build configuration for the container image.
809+
properties:
810+
context:
811+
type: string
812+
description: (Required) The path to the build context directory on the Kubernetes node. This must be a path available on the node, for example via kind extraMounts or k3d volume flags. `/app/src/myapp` for example.
813+
dockerfile:
814+
type: string
815+
description: (Optional) The path to the Dockerfile relative to the build context. If not specified, `Dockerfile` is assumed.
816+
required:
817+
- context
818+
registry:
819+
type: object
820+
description: (Optional) Registry authentication overrides. If not specified, the recipe uses credentials configured by the platform engineer as recipe parameters.
821+
properties:
822+
server:
823+
type: string
824+
description: (Optional) The registry server address. If not specified, `ghcr.io` is assumed.
825+
username:
826+
type: string
827+
description: (Optional) The registry username.
828+
token:
829+
type: string
830+
description: (Optional) The registry token or PAT.
831+
x-radius-sensitive: true
832+
required:
833+
- environment
834+
- application
835+
- image
836+
- build
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
namespace: Radius.Data
2+
location:
3+
global: "http://localhost:8082"
4+
types:
5+
mySqlDatabases:
6+
description: |
7+
The Radius.Data/mySqlDatabases Resource Type deploys a MySQL database. To deploy a new MySQL database, first add a secret resource with the database credentials to the application definition Bicep file, then add a mySqlDatabases resource referencing the secret name.
8+
```
9+
resource mysql 'Radius.Data/mySqlDatabases@2025-08-01-preview' = {
10+
name: 'mysql'
11+
properties: {
12+
environment: environment
13+
application: myApplication.id
14+
secretName: dbCredentials.name
15+
}
16+
}
17+
18+
resource dbCredentials 'Radius.Security/secrets@2025-08-01-preview' = {
19+
name: 'db-creds'
20+
properties: {
21+
environment: environment
22+
application: myApplication.id
23+
data: {
24+
USERNAME: {
25+
value: 'admin'
26+
}
27+
PASSWORD: {
28+
# From password parameter passed in via CLI
29+
value: password
30+
}
31+
}
32+
}
33+
}
34+
```
35+
36+
When deploying the application definition, provide the database password value as a parameter. It is recommended to use a password generator such as `openssl` or equivalent. For example, `rad deploy app.bicep -p password=$(openssl rand -hex 16)`.
37+
38+
To connect your container to the database, create a connection from the Container resource to the database as shown below.
39+
```
40+
resource myApplication 'Radius.Core/Applications@2025-08-01-preview' = { ... }
41+
42+
resource frontend 'Radius.Compute/containers@2025-08-01-preview' = {
43+
name: 'frontend'
44+
properties: {
45+
application: myApplication.id
46+
environment: environment
47+
container: {
48+
image: 'frontend:1.25'
49+
ports: {
50+
web: {
51+
containerPort: 8080
52+
}
53+
}
54+
}
55+
connections: {
56+
mysqldb: {
57+
source: database.id
58+
}
59+
}
60+
}
61+
}
62+
```
63+
64+
The connection automatically injects environment variables into the container for all properties from the database. The environment variables are named `CONNECTION_<CONNECTION-NAME>_<PROPERTY-NAME>`. In this example, the connection name is `mysqldb` so the environment variables will be:
65+
66+
- CONNECTION_MYSQLDB_DATABASE
67+
- CONNECTION_MYSQLDB_HOST
68+
- CONNECTION_MYSQLDB_PORT
69+
70+
apiVersions:
71+
'2025-08-01-preview':
72+
schema:
73+
type: object
74+
properties:
75+
environment:
76+
type: string
77+
description: "(Required) The Radius EnvironmentID. Typically set by the rad CLI. Typically value should be `environment`"
78+
application:
79+
type: string
80+
description: "(Optional) The Radius Application ID. `myApplication.id` for example."
81+
database:
82+
type: string
83+
description: "(Optional) The name of the database. Defaults to `mysql_db` if not provided."
84+
secretName:
85+
type: string
86+
description: "(Required) The name of the secret containing the database credentials."
87+
version:
88+
type: string
89+
enum: ['5.7', '8.0', '8.4']
90+
description: "(Optional) The major MySQL server version in the X.Y format. Assumed to be 8.4 if not specified."
91+
host:
92+
type: string
93+
description: "(Read-only) The host name used to connect to the database."
94+
readOnly: true
95+
port:
96+
type: integer
97+
description: "(Read-only) The port number used to connect to the database."
98+
readOnly: true
99+
required: [environment,secretName]

0 commit comments

Comments
 (0)