From ed22144bc27537190edd4fe3a8198326b8e6e5e7 Mon Sep 17 00:00:00 2001 From: Will Tsai <28876888+willtsai@users.noreply.github.com> Date: Tue, 3 Oct 2023 21:07:28 -0700 Subject: [PATCH] incremental updates Signed-off-by: Will Tsai <28876888+willtsai@users.noreply.github.com> --- .../kubernetes/how-to-patch-pod/index.md | 55 ++++--------------- .../snippets/patch-container.bicep | 18 ++++++ .../snippets/patch-runtime.bicep | 33 +++++++++++ .../author-apps/kubernetes/overview/index.md | 2 +- 4 files changed, 63 insertions(+), 45 deletions(-) create mode 100644 docs/content/guides/author-apps/kubernetes/how-to-patch-pod/snippets/patch-container.bicep create mode 100644 docs/content/guides/author-apps/kubernetes/how-to-patch-pod/snippets/patch-runtime.bicep diff --git a/docs/content/guides/author-apps/kubernetes/how-to-patch-pod/index.md b/docs/content/guides/author-apps/kubernetes/how-to-patch-pod/index.md index d70c58704..8f78332ee 100644 --- a/docs/content/guides/author-apps/kubernetes/how-to-patch-pod/index.md +++ b/docs/content/guides/author-apps/kubernetes/how-to-patch-pod/index.md @@ -3,7 +3,7 @@ type: docs title: "How-To: Patch Kubernetes resources using PodSpec" linkTitle: "Patch with PodSpec" description: "Learn how to patch Kubernetes resources using PodSpec definitions" -weight: 400 +weight: 300 slug: 'patch-podspec' categories: "How-To" tags: ["containers","Kubernetes"] @@ -11,20 +11,19 @@ tags: ["containers","Kubernetes"] This how-to guide will provide an overview of how to: -- Mount an ephemeral (short-lived) volume to a container +- Patch Radius-created Kubernetes resources using [PodSpec](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#PodSpec) definitions ## Prerequisites - [rad CLI]({{< ref getting-started >}}) -- [Radius environment]({{< ref "/guides/deploy-apps/environments/overview" >}}) +- [Radius initialized with `rad init`]({{< ref howto-environment >}}) +- [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) ## Step 1: Define an app and a container Begin by creating a file named `app.bicep` with a Radius application and [container]({{< ref "guides/author-apps/containers" >}}): -{{< rad file="snippets/1-app.bicep" embed=true >}} - -The `quickstarts/volumes` container will display the status and contents of the `/tmpdir` directory within the container. +{{< rad file="snippets/kubernetes-container.bicep" embed=true >}} ## Step 2: Deploy the app and container @@ -33,47 +32,15 @@ The `quickstarts/volumes` container will display the status and contents of the ```bash rad deploy ./app.bicep ``` -1. Once complete, port forward to your container with [`rad resource expose`]({{< ref rad_resource_expose >}}): - - ```bash - rad resource expose containers mycontainer -a myapp --port 5000 - ``` -1. You should see a message warning that the directory `/tmpdir` does not exist: - - Screeshot of container showing that the tmp directory does not exist -## Step 3: Add an ephemeral volume +2. Confirm that a your app with a single container has been deployed: -Within the `container.volume` property, add a new volume named `temp` and configure it as a memory-backed ephemeral volume: + //TODO -{{< rad file="snippets/2-app.bicep" embed=true marker="//CONTAINER" >}} +## Step 3: Add a PodSpec to the container definition -## Redeploy your app and container - -1. Redeploy your application to apply the new definition of your container: - - ```bash - rad deploy ./app.bicep - ``` +//TODO -1. Once complete, port forward to your container with [`rad resource expose`]({{< ref rad_resource_expose >}}): +## Step 4: Redeploy the app with the PodSpec - ```bash - rad resource expose containers mycontainer -a myapp --port 5000 - ``` - -1. Visit [localhost:5000](http://localhost:5000) in your browser. You should see the contents of `/tmpdir`, showing an empty directory. - - Screeshot of container showing that the tmp directory has no items -1. Press the `Create file` button to generate a new file in the directory, such as `test.txt`: - - Screeshot of container showing files being created -1. Done! You've now learned how to mount an ephemeral volume - -## Cleanup - -1. Run the following command to delete your app and container: - - ```bash - rad app delete myapp - ``` +//TODO \ No newline at end of file diff --git a/docs/content/guides/author-apps/kubernetes/how-to-patch-pod/snippets/patch-container.bicep b/docs/content/guides/author-apps/kubernetes/how-to-patch-pod/snippets/patch-container.bicep new file mode 100644 index 000000000..5e17f4de5 --- /dev/null +++ b/docs/content/guides/author-apps/kubernetes/how-to-patch-pod/snippets/patch-container.bicep @@ -0,0 +1,18 @@ +import radius as radius + +param application string + +resource demo 'Applications.Core/containers@2023-10-01-preview' = { + name: 'demo' + properties: { + application: application + container: { + image: 'radius.azurecr.io/tutorial/webapp:edge' + ports: { + web: { + containerPort: 3000 + } + } + } + } +} diff --git a/docs/content/guides/author-apps/kubernetes/how-to-patch-pod/snippets/patch-runtime.bicep b/docs/content/guides/author-apps/kubernetes/how-to-patch-pod/snippets/patch-runtime.bicep new file mode 100644 index 000000000..78f56bc7d --- /dev/null +++ b/docs/content/guides/author-apps/kubernetes/how-to-patch-pod/snippets/patch-runtime.bicep @@ -0,0 +1,33 @@ +import radius as radius + +param application string + +resource demo 'Applications.Core/containers@2023-10-01-preview' = { + name: 'demo' + properties: { + application: application + container: { + image: 'radius.azurecr.io/tutorial/webapp:edge' + ports: { + web: { + containerPort: 3000 + } + } + } + // RUNTIMES + runtimes: { + kubernetes: { + pod: { + containers: [ + { + name: 'log-collector' + image: 'radiusdev.azurecr.io/fluent/fluent-bit:2.1.8' + } + ] + hostNetwork: true + } + } + } + // RUNTIMES + } +} diff --git a/docs/content/guides/author-apps/kubernetes/overview/index.md b/docs/content/guides/author-apps/kubernetes/overview/index.md index fb4274b93..4ee5ab757 100644 --- a/docs/content/guides/author-apps/kubernetes/overview/index.md +++ b/docs/content/guides/author-apps/kubernetes/overview/index.md @@ -3,7 +3,7 @@ type: docs title: "Kubernetes resources" linkTitle: "Overview" description: "Deploy and connect to Kubernetes resources in your application" -weight: 1000 +weight: 100 categories: "Overview" tags: ["Kubernetes"] ---