-
Couldn't load subscription status.
- Fork 50
Revamp tutorial section to have a single end-end tutorial #1551
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
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
4b5b056
Revamp tutorial
Reshrahim 28b101a
Revamp tutorial
Reshrahim cb49055
Fix docsy error
Reshrahim eb463f2
Merge branch 're/tutorial' of https://github.com/radius-project/docs …
Reshrahim f362c1c
fix docsy
Reshrahim 3fe4a37
Fix minor things
Reshrahim 2717bfd
Fix minor things
Reshrahim 7a8896a
Address feedback-part1
Reshrahim c0ce03a
Address feedback on tutorial page
Reshrahim bbcc5c4
Update Recipe
Reshrahim e131a76
Add deploy application and other changes
Reshrahim 0266f3e
remove eshop
Reshrahim 1386611
Download from contrib
Reshrahim e2c6dd5
Address feedback
Reshrahim f53e3c0
Address feedback
Reshrahim d46a87c
spell check
Reshrahim 1e4f1a5
Merge branch 'edge' into re/tutorial
Reshrahim 0a7cabb
Apply suggestions from code review
Reshrahim 3f13686
Merge branch 'edge' into re/tutorial
Reshrahim 5410b23
Apply suggestions from code review
Reshrahim 2d017f1
Apply suggestions from code review
Reshrahim e6b0b8e
Update docs/content/tutorials/create-environment/index.md
Reshrahim e46b155
Apply suggestions from code review
Reshrahim e4e47f5
Update install-rad-cli.md
Reshrahim 41c05f8
Apply suggestions from code review
Reshrahim 6e60ff7
Address feedback
Reshrahim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1328,3 +1328,8 @@ Preflight | |
| preflight | ||
| oci | ||
| contrib | ||
| postgreSqlDatabases | ||
| OpenAPI | ||
| Gi | ||
| memoryRequest | ||
| githubusercontent | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| type: docs | ||
| title: "Samples" | ||
| linkTitle: "Samples" | ||
| description: "Reference samples" | ||
| weight: 400 | ||
| --- |
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes
File renamed without changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,22 @@ | ||
| --- | ||
| type: docs | ||
| title: "Tutorials" | ||
| linkTitle: "Tutorials" | ||
| description: "Follow along with a set of tutorials to learn how to use the Radius platform" | ||
| title: "Tutorial" | ||
| linkTitle: "Tutorial" | ||
| description: "End-to-end tutorial to configure Radius and deploy an application" | ||
| weight: 30 | ||
| --- | ||
|
|
||
| This hands-on tutorial guides you through installing Radius, configuring Resource Types, Recipes, and Environments, and finally deploying the Todo List sample application. This tutorial will take approximately 30-60 minutes to complete. | ||
|
|
||
| ## Learning Outcomes | ||
|
|
||
| After completing this tutorial, you will: | ||
|
|
||
| - Understand Radius concepts including Resource Types, Recipes, Environments, and Applications | ||
| - Know how to develop new Radius Resource Types and Recipes | ||
| - Have hands-on experience configuring Radius using the Radius CLI | ||
| - Know how to deploy an Application using Radius | ||
|
|
||
| ## Organization | ||
|
|
||
| This tutorial is organized in five sequential parts. It is important to complete each part in order. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,182 @@ | ||
| --- | ||
| type: docs | ||
| title: "4. Create Environment" | ||
| linkTitle: "4. Create Environment" | ||
| description: "Create a Radius Environment to deploy the Application" | ||
| weight: 400 | ||
| --- | ||
|
|
||
| In part four of this tutorial, you will: | ||
|
|
||
| - Create a Resource Group to contain all your resources | ||
| - Create an Environment that uses the Recipe for the PostgreSQL Resource Type | ||
| - Create a Workspace to configure the local Radius CLI | ||
|
|
||
| ## Create a Resource Group | ||
|
|
||
| All resources, including Environments, are created within a Resource Group. | ||
|
|
||
| Create a Resource Group using the `rad group create`. | ||
|
|
||
| ```bash | ||
| rad group create my-group | ||
| ``` | ||
| You should see output similar to: | ||
|
|
||
| ``` | ||
| creating resource group "my-group" in workspace "my-workspace"... | ||
|
|
||
| resource group "my-group" created | ||
| ``` | ||
|
|
||
| ## Create an Environment | ||
|
|
||
| Radius Environments define where to deploy resources and what Recipes to use during deployment. | ||
|
|
||
| Create an Environment using the `rad environment create` command. | ||
|
|
||
| ```bash | ||
| rad environment create my-env --group my-group | ||
| ``` | ||
|
|
||
| You should see output similar to: | ||
|
|
||
| ``` | ||
Reshrahim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Creating Environment... | ||
| Successfully created environment "my-env" in resource group "my-group" | ||
| ``` | ||
|
|
||
| Inspect the Environment using the `rad environment show` | ||
|
|
||
| ```bash | ||
| rad environment show my-env --output json | ||
| ``` | ||
|
|
||
| You should see output similar to: | ||
|
|
||
| ``` | ||
| { | ||
| "id": "/planes/radius/local/resourcegroups/my-group/providers/Applications.Core/environments/my-env", | ||
| "location": "global", | ||
| "name": "my-env", | ||
| "properties": { | ||
| "compute": { | ||
| "kind": "kubernetes", | ||
| "namespace": "my-env" | ||
| }, | ||
| "provisioningState": "Succeeded" | ||
| }... | ||
| "type": "Applications.Core/environments" | ||
| } | ||
| ``` | ||
|
|
||
| ## Create a Workspace | ||
|
|
||
| A Radius Workspace is a set of configurations for the local Radius CLI. It is a combination of a Kubernetes context, a Radius Environment, and a Resource Group. | ||
|
|
||
| Create a new Workspace using the `rad workspace create` command. | ||
|
|
||
| ```bash | ||
| rad workspace create kubernetes my-workspace \ | ||
| --context $(kubectl config current-context) \ | ||
| --environment my-env \ | ||
| --group my-group | ||
| ``` | ||
|
|
||
| You should see output similar to: | ||
|
|
||
| ``` | ||
| Creating workspace... | ||
| Set "my-workspace" as current workspace. | ||
| ``` | ||
|
|
||
| Show the current workspace. The `--output json` will show the details of the workspace created. | ||
|
|
||
| ```bash | ||
| rad workspace show --output json | ||
| ``` | ||
|
|
||
| You should see output similar to: | ||
|
|
||
| ``` | ||
| { | ||
| "connection": { | ||
| "context": "k3d-k3s-default", | ||
| "kind": "kubernetes" | ||
| }, | ||
| "environment": "/planes/radius/local/resourceGroups/my-group/providers/applications.core/environments/my-env", | ||
| "scope": "/planes/radius/local/resourceGroups/my-group" | ||
| } | ||
| ``` | ||
|
|
||
| You can also view the workspace by inspecting the contents of `~/.rad/config.yaml`. | ||
|
|
||
|
|
||
| ## Update the Environment with the Recipe | ||
|
|
||
| Update the Environment with Terraform or Bicep Recipe based on your preference. | ||
|
|
||
| {{< tabs Terraform Bicep >}}{{% codetab %}} | ||
|
|
||
| ```bash | ||
| rad recipe register default \ | ||
| --environment my-env \ | ||
| --resource-type Radius.Data/postgreSqlDatabases \ | ||
| --template-kind terraform \ | ||
| --template-path git::https://github.com/radius-project/resource-types-contrib.git//Data/postgreSqlDatabases/recipes/kubernetes/terraform | ||
| ``` | ||
|
|
||
| You should see output similar to: | ||
|
|
||
| ``` | ||
| Successfully linked recipe "default" to environment "my-env" | ||
| ``` | ||
|
|
||
| Verify the Recipe is registered using the `rad recipe list` command. | ||
|
|
||
| ```bash | ||
| rad recipe list | ||
| ``` | ||
|
|
||
Reshrahim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| You should see output similar to: | ||
|
|
||
| ``` | ||
| RECIPE TYPE TEMPLATE KIND TEMPLATE VERSION TEMPLATE | ||
| ... | ||
| default Radius.Data/postgreSqlDatabases terraform git::https://github.com/radius-project/resource-types-contrib.git//Data/postgreSqlDatabases/recipes/kubernetes/terraform | ||
| ``` | ||
| {{% /codetab %}} | ||
| {{% codetab %}} | ||
|
|
||
| ```bash | ||
| rad recipe register default \ | ||
| --environment my-env \ | ||
| --resource-type Radius.Data/postgreSqlDatabases \ | ||
| --template-kind bicep \ | ||
| --template-path ghcr.io/radius-project/recipes/kubernetes/postgresql:0.53.0 | ||
| ``` | ||
|
|
||
Reshrahim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| You should see output similar to: | ||
| ``` | ||
| Successfully linked recipe "default" to environment "my-env" | ||
| ``` | ||
|
|
||
| Verify the Recipe is registered using the `rad recipe list` command. | ||
|
|
||
| ```bash | ||
| rad recipe list | ||
| ``` | ||
|
|
||
Reshrahim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| You should see output similar to: | ||
|
|
||
| ``` | ||
| RECIPE TYPE TEMPLATE KIND TEMPLATE VERSION TEMPLATE | ||
| ... | ||
| default Radius.Data/postgreSqlDatabases bicep ghcr.io/radius-project/recipes/kubernetes/postgresql:0.53.0 | ||
| ``` | ||
| {{% /codetab %}} | ||
| {{< /tabs >}} | ||
|
|
||
Reshrahim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| In the final part, you will deploy the Todo List application to the Environment you just created. | ||
| <br><br> | ||
| {{< button text="Next Step: Deploy Application" page="deploy-application" color="primary" >}} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| --- | ||
| type: docs | ||
| title: "3. Create Recipes" | ||
| linkTitle: "3. Create Recipes" | ||
| description: "Create Bicep or Terraform Recipes that implement the Resource Type" | ||
| weight: 300 | ||
| --- | ||
|
|
||
| Recipes define how a resource is deployed. In part three of this tutorial, you will create a Terraform or Bicep Recipe for the PostgreSQL Resource Type. | ||
|
|
||
| ## Create a Recipe for the PostgreSQL Resource Type | ||
|
|
||
| Recipes can be either Terraform configurations or Bicep templates. Select the tab for the IaC language you prefer. | ||
|
|
||
| {{< tabs Terraform Bicep >}}{{% codetab %}} | ||
|
|
||
| Terraform configuration are stored in a Git repository for Radius to access the Recipe. For this tutorial, the Terraform Recipe has already been created and stored in the Radius [resource-types-contrib](https://github.com/radius-project/resource-types-contrib/blob/main/Data/postgreSqlDatabases/recipes/kubernetes/terraform/main.tf) repository. Hence, there are no actual steps to complete for this section of the tutorial. What follows is a walkthrough of the Radius-specific aspects of the Terraform configuration. | ||
|
|
||
| 1. **Radius metadata via `context` variable** | ||
|
|
||
Reshrahim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Radius automatically injects a variable called `context`. The context variable contains the Resource Type's and the Environment's properties. To use this metadata within the Terraform configuration, a variable must be defined within the `main.tf` or `variables.tf` file. | ||
|
|
||
| ```tf | ||
| variable "context" { | ||
| description = "Radius-provided object containing information about the resource calling the Recipe." | ||
| type = any | ||
| } | ||
| ``` | ||
| Refer to the [context schema]({{< ref context-schema>}}) for the available properties. | ||
|
|
||
| 1. **Variables for Recipe customization** | ||
|
|
||
| The `memory` variable allows customizing the memory request for the PostgreSQL container based on the `size` property defined in the Resource Type. | ||
| ```tf | ||
Reshrahim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| variable "memory" { | ||
| description = "Memory limits for the PostgreSQL container" | ||
| type = map(object({ | ||
| memoryRequest = string | ||
| })) | ||
| default = { | ||
| S = { | ||
| memoryRequest = "512Mi" | ||
| }, | ||
| M = { | ||
| memoryRequest = "1Gi" | ||
| } | ||
| L = { | ||
| memoryRequest = "2Gi" | ||
| } | ||
|
|
||
| } | ||
| ``` | ||
| It is then used in the Kubernetes Deployment: | ||
|
|
||
| ```tf | ||
| resources { | ||
| requests = { | ||
| memory = var.memory[var.context.resource.properties.size].memoryRequest | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| 1. **Result output** | ||
|
|
||
| Radius requires Terraform configuration to have a `result` output defined which provides Radius with the values for each read-only property on the Resource Type. Since the postgreSqlDatabases Resource Type has five read-only properties, each are specified within the `result`. | ||
|
|
||
| ```tf | ||
| output "result" { | ||
| value = { | ||
| values = { | ||
| host = "${kubernetes_service.postgres.metadata[0].name}.${kubernetes_service.postgres.metadata[0].namespace}.svc.cluster.local" | ||
| port = local.port | ||
| database = "postgres_db" | ||
| username = "postgres" | ||
| password = random_password.password.result | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| {{% /codetab %}} | ||
| {{% codetab %}} | ||
|
|
||
| Bicep templates are stored in an OCI registry for Radius to access the Recipe. For this tutorial, the [Bicep Recipe](https://github.com/radius-project/resource-types-contrib/blob/main/Data/postgreSqlDatabases/recipes/kubernetes/bicep/kubernetes-postgresql.bicep) has already been created and stored in the Radius OCI registry. Hence, there are no actual steps to complete for this section of the tutorial. What follows is a walkthrough of the Radius-specific aspects of the Bicep template. | ||
|
|
||
| 1. **Radius metadata via `context` variable** | ||
|
|
||
Reshrahim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| Radius automatically injects a `context` parameter. The context parameter contains the Resource Type's and the Environment's properties. To use this metadata within the Bicep template, a `context` parameter must be defined. | ||
|
|
||
| ```bicep | ||
| @description('Information about what resource is calling this Recipe. Generated by Radius.') | ||
| param context object | ||
| ``` | ||
| Refer to the [context schema]({{< ref context-schema>}}) for the available properties. | ||
|
|
||
| 1. **Variables for Recipe customization** | ||
|
|
||
Reshrahim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| The `memory` variable allows customizing the memory request for the PostgreSQL container based on the `size` property defined in the Resource Type. | ||
|
|
||
| ```bicep | ||
| @description('Memory limits for the PostgreSQL container') | ||
| var memory ={ | ||
| S: { | ||
| memoryRequest: '512Mi' | ||
| } | ||
| M: { | ||
| memoryRequest: '1Gi' | ||
| } | ||
| L: { | ||
| memoryRequest: '2Gi' | ||
| } | ||
| } | ||
| ``` | ||
| It is then used in the Kubernetes Deployment: | ||
|
|
||
| ```bicep | ||
| resources: { | ||
| requests: { | ||
| memory: memory[context.resource.properties.size].memoryRequest | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| 1. **Result output** | ||
|
|
||
| Radius requires Bicep templates to have a `result` output defined which provides Radius with the values for each read-only property on the Resource Type. Since the postgreSqlDatabases Resource Type has five read-only properties, each are specified within the `result`. | ||
|
|
||
| ```bicep | ||
| output result object = { | ||
| values: { | ||
| host: '${svc.metadata.name}.${svc.metadata.namespace}.svc.cluster.local' | ||
| port: port | ||
| database: database | ||
| username: user | ||
| password: password | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| {{% /codetab %}} | ||
| {{< /tabs >}} | ||
|
|
||
| In part four, you will create an Environment which uses the new Recipe. | ||
| <br><br> | ||
| {{< button text="Next step: Create Environment" page="create-environment" color="primary" >}} | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.