-
Notifications
You must be signed in to change notification settings - Fork 44
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
Add how-to guide on Connect to dependencies #807
Merged
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
f3d0056
Add supported resource types
Reshrahim 96850dd
Merge branch 'edge' of https://github.com/radius-project/docs into edge
Reshrahim 37969c2
Merge branch 'edge' of https://github.com/radius-project/docs into edge
Reshrahim 582b65e
Merge branch 'edge' of https://github.com/radius-project/docs into edge
Reshrahim 29eb96f
Add how-to guide on connect to dependencies
Reshrahim 21d0583
Remove link references
Reshrahim a91765e
Add connections step
Reshrahim adbc507
Fix spelling
Reshrahim 5e67fc1
Merge branch 'edge' of https://github.com/radius-project/docs into edge
Reshrahim 30d0730
Merge branch 'edge' of https://github.com/radius-project/docs into edge
Reshrahim e8379af
Merge branch 'edge' of https://github.com/radius-project/docs into edge
Reshrahim d4abfae
Address feedback
Reshrahim 8ce197e
Address feedback
Reshrahim ffd2696
Remove env variables quickstart
Reshrahim 13d782b
Fix ref faiure
Reshrahim 1179473
Merge branch 'edge' into reshma/con
Reshrahim eb906f1
Address feedback
Reshrahim 78d26fe
Remove spelling fix
Reshrahim cdcb8df
Merge branch 'edge' into reshma/con
Reshrahim 124fe17
remove spelling fix
Reshrahim c911d29
resolve conflicts
Reshrahim ea38be3
Fix image to latest
Reshrahim 3cb7111
Minor tweaks
Reshrahim c553a9f
Apply suggestions from code review
Reshrahim 89f7be1
Update docs/content/guides/author-apps/containers/howto-connect-depen…
Reshrahim 8f0b8d6
Resolve merge conflicts
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 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
Binary file added
BIN
+145 KB
...uthor-apps/containers/howto-connect-dependencies/demo-with-redis-screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
90 changes: 90 additions & 0 deletions
90
docs/content/guides/author-apps/containers/howto-connect-dependencies/index.md
This file contains 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,90 @@ | ||
--- | ||
type: docs | ||
title: "How-To: Connect to dependencies" | ||
linkTitle: "Connect to dependencies" | ||
description: "Learn how to connect to dependencies in your application via connections" | ||
weight: 200 | ||
categories: "How-To" | ||
tags: ["containers"] | ||
--- | ||
|
||
This how-to guide will teach how to connect to your dependencies via [connections]({{< ref "guides/author-apps/containers#connections" >}}) | ||
|
||
## Prerequisites | ||
|
||
- [Radius CLI]({{< ref "installation#step-1-install-the-rad-cli" >}}) | ||
- [Radius environment]({{< ref "installation#step-3-initialize-the-radius-control-plane-and-the-radius-environment" >}}) | ||
|
||
## Step 1: View the container definition | ||
|
||
Open the `app.bicep` and view the [container]({{< ref "guides/author-apps/containers" >}}): | ||
|
||
{{< rad file="snippets/app.bicep" embed=true >}} | ||
|
||
## Step 2: Add a Redis cache as a dependency | ||
|
||
Next, add to `app.bicep` a [Redis cache]({{< ref "/guides/author-apps/portable-resources/overview" >}}), leveraging the default "local-dev" Recipe: | ||
|
||
{{< rad file="snippets/app-with-redis.bicep" embed=true marker="//DB" >}} | ||
|
||
## Step 3: Connect to the Redis cache | ||
|
||
Connections from a container to a resource result in environment variables for connection information automatically being set on the container. Update your container definition to add a connection to the new Redis cache: | ||
|
||
{{< rad file="snippets/app-with-redis.bicep" embed=true marker="//CONTAINER" markdownConfig="{linenos=table,hl_lines=[\"13-17\"],linenostart=7}" >}} | ||
|
||
## Step 4: Deploy your app | ||
|
||
1. Run your application in your environment: | ||
|
||
```bash | ||
rad run ./app.bicep -a demo | ||
``` | ||
1. Visit [localhost:3000](http://localhost:3000) in your browser. You should see the following page, now showing injected environment variables: | ||
|
||
<img src="./demo-with-redis-screenshot.png" alt="Screenshot of the demo app with all environment variables" width=1000px /> | ||
|
||
Reshrahim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
## Step 5: View the Application Connections | ||
|
||
Radius Connections are more than just environment variables and configuration. You can also access the "application graph" and understand the connections within your application with the following command: | ||
|
||
```bash | ||
rad app connections | ||
``` | ||
|
||
You should see the following output, detailing the connections between the `demo` container and the `db` Redis cache, along with information about the underlying Kubernetes resources running the app: | ||
|
||
``` | ||
Displaying application: demo | ||
|
||
Name: demo (Applications.Core/containers) | ||
Connections: | ||
demo -> db (Applications.Datastores/redisCaches) | ||
Resources: | ||
demo (kubernetes: apps/Deployment) | ||
demo (kubernetes: core/Secret) | ||
demo (kubernetes: core/Service) | ||
demo (kubernetes: core/ServiceAccount) | ||
demo (kubernetes: rbac.authorization.k8s.io/Role) | ||
demo (kubernetes: rbac.authorization.k8s.io/RoleBinding) | ||
|
||
Name: db (Applications.Datastores/redisCaches) | ||
Connections: | ||
demo (Applications.Core/containers) -> db | ||
Resources: | ||
redis-r5tcrra3d7uh6 (kubernetes: apps/Deployment) | ||
redis-r5tcrra3d7uh6 (kubernetes: core/Service) | ||
``` | ||
|
||
## Cleanup | ||
|
||
Run `rad app delete` to cleanup your Radius application, container, and Redis cache: | ||
|
||
```bash | ||
rad app delete -a demo | ||
``` | ||
Reshrahim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Further reading | ||
|
||
- [Connections]({{< ref "guides/author-apps/containers/overview#connections" >}}) | ||
- [Container schema]({{< ref container-schema >}}) |
40 changes: 40 additions & 0 deletions
40
...nt/guides/author-apps/containers/howto-connect-dependencies/snippets/app-with-redis.bicep
This file contains 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,40 @@ | ||
// Import the set of Radius resources (Applications.*) into Bicep | ||
import radius as radius | ||
|
||
@description('The app ID of your Radius Application. Set automatically by the rad CLI.') | ||
param application string | ||
|
||
//CONTAINER | ||
resource demo 'Applications.Core/containers@2023-10-01-preview' = { | ||
name: 'demo' | ||
properties: { | ||
application: application | ||
container: { | ||
image: 'radius.azurecr.io/samples/demo:latest' | ||
ports: { | ||
web: { | ||
containerPort: 3000 | ||
} | ||
} | ||
} | ||
connections: { | ||
redis: { | ||
source: db.id | ||
} | ||
} | ||
} | ||
} | ||
//CONTAINER | ||
|
||
//DB | ||
@description('The env ID of your Radius Environment. Set automatically by the rad CLI.') | ||
param environment string | ||
Reshrahim marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
resource db 'Applications.Datastores/redisCaches@2023-10-01-preview' = { | ||
name: 'db' | ||
properties: { | ||
application: application | ||
environment: environment | ||
} | ||
} | ||
//DB |
14 changes: 14 additions & 0 deletions
14
docs/content/guides/author-apps/containers/howto-connect-dependencies/snippets/app.bicep
This file contains 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,14 @@ | ||
import radius as rad | ||
|
||
@description('The app ID of your Radius application. Set automatically by the rad CLI.') | ||
param application string | ||
|
||
resource container 'Applications.Core/containers@2023-10-01-preview' = { | ||
name: 'demo' | ||
properties: { | ||
application: application | ||
container: { | ||
image: 'radius.azurecr.io/samples/demo:latest' | ||
} | ||
} | ||
} |
Binary file removed
BIN
-2 KB
docs/content/guides/author-apps/containers/howto-environment-variables/icon.png
Binary file not shown.
88 changes: 0 additions & 88 deletions
88
docs/content/guides/author-apps/containers/howto-environment-variables/index.md
This file was deleted.
Oops, something went wrong.
Binary file removed
BIN
-120 KB
...nt/guides/author-apps/containers/howto-environment-variables/screenshot-all.jpg
Binary file not shown.
Binary file removed
BIN
-91.5 KB
...ontent/guides/author-apps/containers/howto-environment-variables/screenshot.jpg
Binary file not shown.
20 changes: 0 additions & 20 deletions
20
docs/content/guides/author-apps/containers/howto-environment-variables/snippets/1-app.bicep
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
docs/content/guides/author-apps/containers/howto-environment-variables/snippets/2-app.bicep
This file was deleted.
Oops, something went wrong.
42 changes: 0 additions & 42 deletions
42
docs/content/guides/author-apps/containers/howto-environment-variables/snippets/3-app.bicep
This file was deleted.
Oops, something went wrong.
This file contains 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
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.
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.
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.
The user would create a Radius environment as part of the prereqs where they select
yes
to set up the app. So the app.bicep will have the demo container definition