From 52e9eb0b50931d9baea8d4e86b86f178613fe51c Mon Sep 17 00:00:00 2001 From: Will Tsai <28876888+willtsai@users.noreply.github.com> Date: Mon, 23 Oct 2023 16:54:01 -0700 Subject: [PATCH] correct alignments Signed-off-by: Will Tsai <28876888+willtsai@users.noreply.github.com> --- docs/content/tutorials/helm/index.md | 802 +++++++++++++-------------- 1 file changed, 401 insertions(+), 401 deletions(-) diff --git a/docs/content/tutorials/helm/index.md b/docs/content/tutorials/helm/index.md index b294f1a01..c09089fdb 100644 --- a/docs/content/tutorials/helm/index.md +++ b/docs/content/tutorials/helm/index.md @@ -63,106 +63,106 @@ rad init 1. Navigate to the `./Chart` folder and browse its contents. This contains a Helm chart for the application that you will modify. - Here are the contents of `./demo/Chart/templates/app.yaml`. This file is part of the Helm chart, and describes the container used for this tutorial: - - ```yaml - apiVersion: apps/v1 - kind: Deployment - metadata: - name: webapp - namespace: {{ .Release.Namespace }} - spec: - selector: - matchLabels: - app: webapp - template: - metadata: - labels: + Here are the contents of `./demo/Chart/templates/app.yaml`. This file is part of the Helm chart, and describes the container used for this tutorial: + + ```yaml + apiVersion: apps/v1 + kind: Deployment + metadata: + name: webapp + namespace: {{ .Release.Namespace }} + spec: + selector: + matchLabels: app: webapp - spec: - containers: - - name: webapp - image: {{ .Values.image.repository }}:{{ .Values.image.tag }} - env: - - name: CONNECTION_REDIS_URL - valueFrom: - secretKeyRef: - name: redis-secret - key: url - ports: - - containerPort: 3000 - ``` - - The container that you will be working with is a ToDo application that uses Redis as a database. - - - The container is configured to listen on port 3000. - - The container will use the environment variable `CONNECTION_REDIS_URL` to connect to Redis. - - This `CONNECTION_REDIS_URL` environment variable is populated by a Kubernetes Secret. - -2. You can deploy this application for the first time by following these steps: - - - Create the Kubernetes namespace `demo` - - Create the Kubernetes Secret `redis-secret` containing the Redis URL. - - Install the Helm chart. - - {{< alert title="💡 Redis" color="info" >}} - For now you're not going to actually deploy Redis and the URL in this step is fake. You will deploy Redis using a Recipe later in the tutorial that will replace the fake URL contained within `redis-secret` with an actual container and URL. - {{< /alert >}} - - Complete these steps by running the following commands: - - ```bash - kubectl create namespace demo - kubectl create secret generic --namespace demo --from-literal=url=redis://fake-server redis-secret - helm upgrade demo ./Chart -n demo --install - ``` - - The output should look similar to the following: - - ``` - > kubectl create namespace demo - namespace/demo created - - > kubectl create secret generic --namespace demo --from-literal=url=redis://fake-server redis-secret - secret/redis-secret created - - > helm upgrade demo ./Chart -n demo --install - Release "demo" does not exist. Installing it now. - NAME: demo - LAST DEPLOYED: Wed Sep 13 01:05:19 2023 - NAMESPACE: demo - STATUS: deployed - REVISION: 1 - TEST SUITE: None - ``` - - {{< alert title="⚠️ Chart Directory" color="warning" >}} - If you see an error message like **Error: path "./Chart" not found** then you are in the wrong directory. Make sure your terminal is in the `./demo` directory of the `samples` repository. - {{< /alert >}} + template: + metadata: + labels: + app: webapp + spec: + containers: + - name: webapp + image: {{ .Values.image.repository }}:{{ .Values.image.tag }} + env: + - name: CONNECTION_REDIS_URL + valueFrom: + secretKeyRef: + name: redis-secret + key: url + ports: + - containerPort: 3000 + ``` + + The container that you will be working with is a ToDo application that uses Redis as a database. + + - The container is configured to listen on port 3000. + - The container will use the environment variable `CONNECTION_REDIS_URL` to connect to Redis. + - This `CONNECTION_REDIS_URL` environment variable is populated by a Kubernetes Secret. + + You can deploy this application for the first time by following these steps: + + - Create the Kubernetes namespace `demo` + - Create the Kubernetes Secret `redis-secret` containing the Redis URL. + - Install the Helm chart. + + {{< alert title="💡 Redis" color="info" >}} + For now you're not going to actually deploy Redis and the URL in this step is fake. You will deploy Redis using a Recipe later in the tutorial that will replace the fake URL contained within `redis-secret` with an actual container and URL. + {{< /alert >}} + +2. Complete these steps by running the following commands: + + ```bash + kubectl create namespace demo + kubectl create secret generic --namespace demo --from-literal=url=redis://fake-server redis-secret + helm upgrade demo ./Chart -n demo --install + ``` + + The output should look similar to the following: + + ``` + > kubectl create namespace demo + namespace/demo created + + > kubectl create secret generic --namespace demo --from-literal=url=redis://fake-server redis-secret + secret/redis-secret created + + > helm upgrade demo ./Chart -n demo --install + Release "demo" does not exist. Installing it now. + NAME: demo + LAST DEPLOYED: Wed Sep 13 01:05:19 2023 + NAMESPACE: demo + STATUS: deployed + REVISION: 1 + TEST SUITE: None + ``` + + {{< alert title="⚠️ Chart Directory" color="warning" >}} + If you see an error message like **Error: path "./Chart" not found** then you are in the wrong directory. Make sure your terminal is in the `./demo` directory of the `samples` repository. + {{< /alert >}} 3. Run the following command to check if everything is running: - ```bash - kubectl get all -n demo - ``` + ```bash + kubectl get all -n demo + ``` - The output should look similar to the following: + The output should look similar to the following: - ``` - > kubectl get all -n demo - NAME READY STATUS RESTARTS AGE - pod/webapp-79d5dfb99-vhj9g 1/1 Running 0 2m48s + ``` + > kubectl get all -n demo + NAME READY STATUS RESTARTS AGE + pod/webapp-79d5dfb99-vhj9g 1/1 Running 0 2m48s - NAME READY UP-TO-DATE AVAILABLE AGE - deployment.apps/webapp 1/1 1 1 2m49s + NAME READY UP-TO-DATE AVAILABLE AGE + deployment.apps/webapp 1/1 1 1 2m49s - NAME DESIRED CURRENT READY AGE - replicaset.apps/webapp-79d5dfb99 1 1 1 2m49s - ``` + NAME DESIRED CURRENT READY AGE + replicaset.apps/webapp-79d5dfb99 1 1 1 2m49s + ``` - > The generated names and ages of the objects will be different in your output. Make sure you see the status of `Running` for the `pod/webapp-...` entry. If the status is not `Running`, try repeating the `kubectl get all -n demo` after waiting. + > The generated names and ages of the objects will be different in your output. Make sure you see the status of `Running` for the `pod/webapp-...` entry. If the status is not `Running`, try repeating the `kubectl get all -n demo` after waiting. - At this point you've deployed the application but you have not actually used Radius yet. You will start doing that in the next step, as well as set up and use Redis. + At this point you've deployed the application but you have not actually used Radius yet. You will start doing that in the next step, as well as set up and use Redis. The steps so far are similar to how many applications are managed today: @@ -182,90 +182,90 @@ From here you will go through a series of steps to incrementally add more Radius 1. Make sure the `app.yaml` file from `./demo/Chart/templates/app.yaml` is open in your editor. You will make some edits to this file to enable Radius. - Add the `annotations` property to `metadata`, and then add the `radapp.io/enabled: 'true'` annotation. The `'true'` must be surrounded in quotes. + Add the `annotations` property to `metadata`, and then add the `radapp.io/enabled: 'true'` annotation. The `'true'` must be surrounded in quotes. - The example below shows the updated `metadata` section after making the changes. + The example below shows the updated `metadata` section after making the changes. -
+ ```yaml + apiVersion: apps/v1 + kind: Deployment + metadata: + name: webapp + namespace: {{ .Release.Namespace }} + annotations: + radapp.io/enabled: 'true' + spec: + ... + ``` - Adding the `radapp.io/enabled: 'true'` annotation enables Radius for the deployment. + Adding the `radapp.io/enabled: 'true'` annotation enables Radius for the deployment. 2. Save the file after you have made the edits and deploy the application again using Helm. Since the namespace and secret have already been created, we only need to run the `helm` command. - ```bash - helm upgrade demo ./Chart -n demo --install - ``` + ```bash + helm upgrade demo ./Chart -n demo --install + ``` - The output should look like: + The output should look like: - ``` - > helm upgrade demo ./Chart -n demo --install - Release "demo" has been upgraded. Happy Helming! - NAME: demo - LAST DEPLOYED: Wed Sep 13 01:31:58 2023 - NAMESPACE: demo - STATUS: deployed - REVISION: 2 - TEST SUITE: None - ``` + ``` + > helm upgrade demo ./Chart -n demo --install + Release "demo" has been upgraded. Happy Helming! + NAME: demo + LAST DEPLOYED: Wed Sep 13 01:31:58 2023 + NAMESPACE: demo + STATUS: deployed + REVISION: 2 + TEST SUITE: None + ``` - You should confirm that your output contains `REVISION: 2`, that means that the changes were applied. + You should confirm that your output contains `REVISION: 2`, that means that the changes were applied. 3. Run the following command to confirm that everything is running: - ```bash - kubectl get all -n demo - ``` + ```bash + kubectl get all -n demo + ``` - The output should look similar to the following: + The output should look similar to the following: - ``` - > kubectl get all -n demo - NAME READY STATUS RESTARTS AGE - pod/webapp-79d5dfb99-mv6q9 1/1 Running 0 10m + ``` + > kubectl get all -n demo + NAME READY STATUS RESTARTS AGE + pod/webapp-79d5dfb99-mv6q9 1/1 Running 0 10m - NAME READY UP-TO-DATE AVAILABLE AGE - deployment.apps/webapp 1/1 1 1 10m + NAME READY UP-TO-DATE AVAILABLE AGE + deployment.apps/webapp 1/1 1 1 10m - NAME DESIRED CURRENT READY AGE - replicaset.apps/webapp-79d5dfb99 1 1 1 10m - ``` + NAME DESIRED CURRENT READY AGE + replicaset.apps/webapp-79d5dfb99 1 1 1 10m + ``` - Notice that the `AGE` of `pod/webapp-...` reflects the time of your **first** deployment. Enabling Radius for an application does not change any of its behaviors, so Kubernetes did not need to restart the container. + Notice that the `AGE` of `pod/webapp-...` reflects the time of your **first** deployment. Enabling Radius for an application does not change any of its behaviors, so Kubernetes did not need to restart the container. 4. Now that Radius has been enabled, run this command to display the state of the Radius application: - ```bash - rad app graph -a demo -g default-demo - ``` + ```bash + rad app graph -a demo -g default-demo + ``` - The output should look like this: + The output should look like this: - ``` - > rad app graph -a demo -g default-demo - Displaying application: demo + ``` + > rad app graph -a demo -g default-demo + Displaying application: demo - Name: webapp (Applications.Core/containers) - Connections: (none) - Resources: - webapp (kubernetes: apps/Deployment) - ``` + Name: webapp (Applications.Core/containers) + Connections: (none) + Resources: + webapp (kubernetes: apps/Deployment) + ``` - This means that Radius has found the Kubernetes `Deployment` running your container and cataloged it as part of the application. + This means that Radius has found the Kubernetes `Deployment` running your container and cataloged it as part of the application. - {{< alert title="💡 Application Name" color="info" >}} - Radius will use the Kubernetes namespace as the application name by default. - {{< /alert >}} + {{< alert title="💡 Application Name" color="info" >}} + Radius will use the Kubernetes namespace as the application name by default. + {{< /alert >}} ## Step 5. Add Recipe @@ -280,175 +280,175 @@ In this step you will: 1. First, check recipes installed in your environment by running: - ```bash - rad recipe list - ``` + ```bash + rad recipe list + ``` - You will see output like this: + You will see output like this: - ``` - NAME TYPE TEMPLATE KIND TEMPLATE VERSION TEMPLATE - default Applications.Datastores/sqlDatabases bicep radius.ghcr.io/recipes/local-dev/sqldatabases:latest - default Applications.Messaging/rabbitMQQueues bicep radius.ghcr.io/recipes/local-dev/rabbitmqqueues:latest - default Applications.Dapr/pubSubBrokers bicep radius.ghcr.io/recipes/local-dev/pubsubbrokers:latest - default Applications.Dapr/secretStores bicep radius.ghcr.io/recipes/local-dev/secretstores:latest - default Applications.Dapr/stateStores bicep radius.ghcr.io/recipes/local-dev/statestores:latest - default Applications.Datastores/mongoDatabases bicep radius.ghcr.io/recipes/local-dev/mongodatabases:latest - default Applications.Datastores/redisCaches bicep radius.ghcr.io/recipes/local-dev/rediscaches:latest - ``` + ``` + NAME TYPE TEMPLATE KIND TEMPLATE VERSION TEMPLATE + default Applications.Datastores/sqlDatabases bicep radius.ghcr.io/recipes/local-dev/sqldatabases:latest + default Applications.Messaging/rabbitMQQueues bicep radius.ghcr.io/recipes/local-dev/rabbitmqqueues:latest + default Applications.Dapr/pubSubBrokers bicep radius.ghcr.io/recipes/local-dev/pubsubbrokers:latest + default Applications.Dapr/secretStores bicep radius.ghcr.io/recipes/local-dev/secretstores:latest + default Applications.Dapr/stateStores bicep radius.ghcr.io/recipes/local-dev/statestores:latest + default Applications.Datastores/mongoDatabases bicep radius.ghcr.io/recipes/local-dev/mongodatabases:latest + default Applications.Datastores/redisCaches bicep radius.ghcr.io/recipes/local-dev/rediscaches:latest + ``` - The recipe for `Applications.Datastores/redisCaches` is what you will use in this example. + The recipe for `Applications.Datastores/redisCaches` is what you will use in this example. - {{< alert title="💡 Recipes" color="info" >}} - Radius includes Recipes for local development when you use `rad init`. These [**local-dev**](https://github.com/radius-project/recipes/tree/main/local-dev) Recipes run popular OSS technologies as containerized infrastructure without requiring a cloud account. - - In a production environment you can substitute recipes that will create cloud or on-premises dependencies instead. - {{< /alert >}} + {{< alert title="💡 Recipes" color="info" >}} + Radius includes Recipes for local development when you use `rad init`. These [**local-dev**](https://github.com/radius-project/recipes/tree/main/local-dev) Recipes run popular OSS technologies as containerized infrastructure without requiring a cloud account. + + In a production environment you can substitute recipes that will create cloud or on-premises dependencies instead. + {{< /alert >}} 2. Make sure the `app.yaml` file from `./demo/Chart/templates/app.yaml` is open in your editor. At the bottom of the file add the following text, including the `---`: - ```yaml - --- - apiVersion: radapp.io/v1alpha3 - kind: Recipe - metadata: - name: db - namespace: {{ .Release.Namespace }} - spec: - type: Applications.Datastores/redisCaches - secretName: redis-secret - ``` + ```yaml + --- + apiVersion: radapp.io/v1alpha3 + kind: Recipe + metadata: + name: db + namespace: {{ .Release.Namespace }} + spec: + type: Applications.Datastores/redisCaches + secretName: redis-secret + ``` - Defining a `Recipe` object in Kubernetes will use a Radius Recipe to create dependencies for your application: + Defining a `Recipe` object in Kubernetes will use a Radius Recipe to create dependencies for your application: - - The `.spec.type` field defines the type of resource to create. `Applications.Datastores/redisCaches` is the type for a Redis Cache. - - The `.spec.secretName` field tells Radius where to store connection information. This is optional, and should be used to interoperate with other Kubernetes technologies that read from secrets. This tutorial example uses the secret to populate an environment variable. + - The `.spec.type` field defines the type of resource to create. `Applications.Datastores/redisCaches` is the type for a Redis Cache. + - The `.spec.secretName` field tells Radius where to store connection information. This is optional, and should be used to interoperate with other Kubernetes technologies that read from secrets. This tutorial example uses the secret to populate an environment variable. 3. Save the file after you have made the edits and deploy the application again using Helm. Since the namespace and secret have already been created, you only need to run the `helm` command. - ```bash - helm upgrade demo ./Chart -n demo --install - ``` + ```bash + helm upgrade demo ./Chart -n demo --install + ``` - The output should look like: + The output should look like: - ``` - > helm upgrade demo ./Chart -n demo --install - Release "demo" has been upgraded. Happy Helming! - NAME: demo - LAST DEPLOYED: Wed Sep 13 01:44:04 2023 - NAMESPACE: demo - STATUS: deployed - REVISION: 3 - TEST SUITE: None - ``` + ``` + > helm upgrade demo ./Chart -n demo --install + Release "demo" has been upgraded. Happy Helming! + NAME: demo + LAST DEPLOYED: Wed Sep 13 01:44:04 2023 + NAMESPACE: demo + STATUS: deployed + REVISION: 3 + TEST SUITE: None + ``` - This time you should see `REVISION: 3`. + This time you should see `REVISION: 3`. 4. Now that you are using a Recipe, you should see more resources running in Kubernetes. Run the following command: - ```bash - kubectl get all -n demo - ``` + ```bash + kubectl get all -n demo + ``` - The output should look similar to the following: + The output should look similar to the following: - ``` - > kubectl get all -n demo + ``` + > kubectl get all -n demo - pod/redis-r5tcrra3d7uh6-7bcd8b8d8d-jmgn4 2/2 Running 0 51s - pod/webapp-79d5dfb99-f6xgj 1/1 Running 0 52s + pod/redis-r5tcrra3d7uh6-7bcd8b8d8d-jmgn4 2/2 Running 0 51s + pod/webapp-79d5dfb99-f6xgj 1/1 Running 0 52s - NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE - service/redis-r5tcrra3d7uh6 ClusterIP 10.43.104.63- apiVersion: apps/v1 - kind: Deployment - metadata: - name: webapp - namespace: {{ .Release.Namespace }} - annotations: - radapp.io/enabled: 'true' - spec: - ... -