diff --git a/.github/config/en-custom.txt b/.github/config/en-custom.txt index 9c387f88b..03e3bd661 100644 --- a/.github/config/en-custom.txt +++ b/.github/config/en-custom.txt @@ -13,6 +13,7 @@ Async AWSSimpleQueueService Azure Blazor +basemanifest clusterissuer ClusterIssuer CLI diff --git a/docs/content/guides/author-apps/kubernetes/howto-yaml-base-support/index.md b/docs/content/guides/author-apps/kubernetes/howto-yaml-base-support/index.md index 435a660a8..f28eeac76 100644 --- a/docs/content/guides/author-apps/kubernetes/howto-yaml-base-support/index.md +++ b/docs/content/guides/author-apps/kubernetes/howto-yaml-base-support/index.md @@ -1,25 +1,30 @@ --- type: docs title: "How-To: Incremental onboard from existing Kubernetes resources" -linkTitle: "Incremental onboard from existing Kubernetes resources" -description: "Learn how to load a Kubernetes YAML base manifest into Radius and have Radius override properties on top of the user-given base resources" -weight: 500 +linkTitle: "Incremental onboard with YAML" +description: "Learn how to load a Kubernetes YAML deployment manifest into Radius and have Radius override properties on top of the user-given base resources" +weight: 200 categories: "How-To" -tags: ["Kubernetes"] +tags: ["containers","Kubernetes"] --- +This how-to guide will provide an overview of how to: + +- Incrementally onboard your Kubernetes resources using your Kubernetes [Deployment YAML](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#writing-a-deployment-spec) definitions + ### Prerequisites Before you get started, you'll need to make sure you have the following tools and resources: - [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) +- [rad CLI]({{< ref getting-started >}}) - [Radius initialized with `rad init`]({{< ref howto-environment >}}) ### Step 1: Author a Radius Application Define a Radius Application resource that will contain your Kubernetes resource container. -> Application-scoped resources are by default generated in a new Kubernetes namespace with the name format `-`. This prevents multiple applications with resources of the same name from conflicting with each other, however users can define their own Kubernetes namespace if they desire. +> Radius resources, when deployed to a Kubernetes environment, are mapped to one or more Kubernetes objects. For more information visit [Radius on Kubernetes platform]({{< ref "guides/operations/kubernetes#resource-mapping" >}}) {{< rad file="snippets/basemanifest.bicep" embed=true marker="//APPLICATION" >}} @@ -27,6 +32,10 @@ Define a Radius Application resource that will contain your Kubernetes resource You'll need to create a Radius container resource that will consume the information found in your Kubernetes base YAML file. +#### YAML Deployment template + +{{< rad file="snippets/basemanifest.yaml" embed=true lang="yaml">}} + #### Standardize object names Begin by assuring that your `ServiceAccount`, `Deployment`, and `Service` objects found in your Kubernetes base YAML file have the same name as the Radius container resource that lives inside your application-scoped namespace. @@ -43,7 +52,38 @@ Load your Kubernetes YAML file into your Radius container resource through the ` ### Done -You can now deploy your Radius Application and verify that your Kubernetes objects are created in the desired namespace. Visit the Radius [Kubernetes resources authoring overview]({{< ref "/guides/author-apps/kubernetes/overview" >}}) page for more information. +You can now deploy your Radius Application and verify that your Kubernetes objects are created in the desired namespace. + +#### Deployment + +Run `rad deploy app.bicep` and your expected outcome should be: + +```bash +Building app.bicep... +Deploying template 'app.bicep' into environment 'default' from workspace 'default'... + +Deployment In Progress... + +Completed my-microservice Applications.Core/applications +.. my-microservice Applications.Core/containers + +Deployment Complete + +Resources: + my-microservice Applications.Core/applications + my-microservice Applications.Core/containers +``` + +To verify and follow the Kubernetes pod creations run `kubectl get pods -A -w` during your deployment and the following output should be seen: + +```bash +radius-system controller-585dcd4c9b-5g2c9 1/1 Running 5 (91s ago) 13m +my-microservice my-microservice-5c464f66d4-s7n7w 0/1 Pending 0 0s +my-microservice my-microservice-5c464f66d4-s4tq8 0/1 Pending 0 0s +my-microservice my-microservice-5c464f66d4-tnvx4 0/1 Pending 0 0s +my-microservice my-microservice-5c464f66d4-s7n7w 0/1 Pending 0 0s +my-microservice my-microservice-5c464f66d4-tnvx4 0/1 Pending 0 0s +``` ## Further reading diff --git a/docs/content/guides/author-apps/kubernetes/howto-yaml-base-support/snippets/basemanifest.bicep b/docs/content/guides/author-apps/kubernetes/howto-yaml-base-support/snippets/basemanifest.bicep index f2b168f0f..6a10425cd 100644 --- a/docs/content/guides/author-apps/kubernetes/howto-yaml-base-support/snippets/basemanifest.bicep +++ b/docs/content/guides/author-apps/kubernetes/howto-yaml-base-support/snippets/basemanifest.bicep @@ -13,11 +13,11 @@ param port int = 3000 param environment string @description('Specifies the namespace for resources.') -param namespace string +param namespace string = 'my-microservice' //APPLICATION -resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { - name: 'manifest-default' +resource app 'Applications.Core/applications@2023-10-01-preview' = { + name: 'my-microservice' location: location properties: { environment: environment @@ -35,9 +35,9 @@ resource app 'Applications.Core/applications@2022-03-15-privatepreview' = { @description('Loads the Kubernetes base manifest file and turns content into a string.') var manifest = loadTextContent('./basemanifest.yaml') -resource container 'Applications.Core/containers@2022-03-15-privatepreview' = { +resource container 'Applications.Core/containers@2023-10-01-preview' = { // Name must match with `ServiceAccount`, `Deployment`, and `Service` objects - name: 'your-manifest-default-name' + name: 'my-microservice' location: location properties: { application: app.id diff --git a/docs/content/guides/author-apps/kubernetes/howto-yaml-base-support/snippets/basemanifest.yaml b/docs/content/guides/author-apps/kubernetes/howto-yaml-base-support/snippets/basemanifest.yaml index c0bd4f72d..cbdef7d7b 100644 --- a/docs/content/guides/author-apps/kubernetes/howto-yaml-base-support/snippets/basemanifest.yaml +++ b/docs/content/guides/author-apps/kubernetes/howto-yaml-base-support/snippets/basemanifest.yaml @@ -1,28 +1,28 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: manifest-default + name: my-microservice labels: - app: manifest-default + app: my-microservice annotations: source: base-manifest-test spec: replicas: 3 selector: matchLabels: - app: manifest-default + app: my-microservice template: metadata: labels: - app: manifest-default + app: my-microservice spec: - serviceAccountName: manifest-default + serviceAccountName: my-microservice volumes: - name: secret-vol secret: - secretName: manifest-default-secret0 + secretName: my-microservice-secret0 containers: - - name: manifest-default + - name: my-microservice ports: - containerPort: 80 protocol: TCP @@ -34,23 +34,23 @@ spec: - name: TEST_SECRET_KEY valueFrom: secretKeyRef: - name: manifest-default-secret1 + name: my-microservice-secret1 key: secret1 - name: TEST_CONFIGMAP_KEY valueFrom: configMapKeyRef: - name: manifest-default-config + name: my-microservice-config key: TEST_CONFIGMAP --- apiVersion: v1 kind: Service metadata: - name: manifest-default + name: my-microservice annotations: source: base-manifest-test spec: selector: - app.kubernetes.io/name: manifest-default + app.kubernetes.io/name: my-microservice ports: - protocol: TCP port: 3000 @@ -59,7 +59,7 @@ spec: apiVersion: v1 kind: ServiceAccount metadata: - name: manifest-default + name: my-microservice annotations: source: base-manifest-test --- @@ -67,7 +67,7 @@ metadata: apiVersion: v1 kind: Secret metadata: - name: manifest-default-secret0 + name: my-microservice-secret0 annotations: source: base-manifest-test type: Opaque @@ -78,7 +78,7 @@ stringData: apiVersion: v1 kind: Secret metadata: - name: manifest-default-secret1 + name: my-microservice-secret1 annotations: source: base-manifest-test type: Opaque @@ -89,7 +89,7 @@ stringData: apiVersion: v1 kind: ConfigMap metadata: - name: manifest-default-config + name: my-microservice-config annotations: source: base-manifest-test data: diff --git a/docs/content/guides/author-apps/kubernetes/overview/index.md b/docs/content/guides/author-apps/kubernetes/overview/index.md index 31e43d7ab..254103b64 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: "Overview: Kubernetes resources" linkTitle: "Overview" description: "Deploy and connect to Kubernetes resources in your application" -weight: 1000 +weight: 100 categories: "Overview" tags: ["Kubernetes"] ---