diff --git a/.github/config/en-custom.txt b/.github/config/en-custom.txt index 643790033..53eff00f9 100644 --- a/.github/config/en-custom.txt +++ b/.github/config/en-custom.txt @@ -943,3 +943,7 @@ WirelessGateway WorkGroup Workgroup XRay +PodSpec +ConfigMap +CRD +composable \ No newline at end of file diff --git a/docs/content/guides/author-apps/containers/overview/index.md b/docs/content/guides/author-apps/containers/overview/index.md index d53bfb505..60821eb35 100644 --- a/docs/content/guides/author-apps/containers/overview/index.md +++ b/docs/content/guides/author-apps/containers/overview/index.md @@ -22,6 +22,28 @@ Radius containers are portable across container runtimes, allowing you to define Containers are deployed to the same Kubernetes cluster as your Radius installation, into the namespace that is defined in your application. For more information on how Radius resources map to Kubernetes objects, refer to the [Kubernetes mapping guide]({{< ref "/guides/operations/kubernetes/overview#resource-mapping" >}}). +#### Customize Kubernetes configurations + +Radius provides a way to apply custom Kubernetes configurations to container resources that are created by Radius. This allows you to make use of Kubernetes configurations or features that are not supported by Radius, yet remain composable with other Radius features like [Connections]({{< ref "guides/author-apps/containers/overview#connections" >}}). Additionally, it provides a way to migrate your existing Kubernetes applications into Radius without having to rewrite your Kubernetes configurations, while giving you the option to incrementally adopt Radius features over time. The customizations are applied to the container resource via the [`runtimes`]({{< ref "reference/resource-schema/core-schema/container-schema/_index.md#runtimes" >}}) property within the container resource definition. + +##### Base Kubernetes YAML + +You can provide a Kubernetes YAML definition as a base or foundation upon which Radius will build your containers, enabling you to incrementally adopting Radius by starting with your existing YAML definition and use applying Radius customizations on top. The provided YAML is fully passed through to Kubernetes when Radius creates the container resource, which means that you may even provide a definition for a CRD that Radius has no visibility into. + +Radius currently supports the following Kubernetes resource types for the `base` property: + +| Kubernetes Resource Types | Number of resources | Limitation | +|---------------------------|---------------------|------------| +| Deployment | 1 | Deployment name must match the name of the Radius container | +| ServiceAccount | 1 | ServiceAccount name must match the name of the Radius container using the correct namespace | +| Service | 1 | ServiceAccount name must match the name of the Radius container using the correct namespace | +| Secrets | Multiple | No limitation except within the respective namespace | +| ConfigMap | Multiple config maps | No limitation except within the respective namespace | + +##### Pod patching + +You can also "patch" the Kubernetes containers created and deployed by Radius using [PodSpec](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#PodSpec) definitions. This allows for setting Kubernetes-specific configurations, as well as overriding Radius behaviors, which means that you may access all Kubernetes Pod features, even if they are not supported by Radius. + ## Container definition Radius containers allow you to specify your image, ports, environment variables, volumes, and more. Refer to the [container resource schema]({{< ref "container-schema" >}}) for more information. diff --git a/docs/content/reference/resource-schema/core-schema/container-schema/_index.md b/docs/content/reference/resource-schema/core-schema/container-schema/_index.md index cbba38e4f..2d99baf88 100644 --- a/docs/content/reference/resource-schema/core-schema/container-schema/_index.md +++ b/docs/content/reference/resource-schema/core-schema/container-schema/_index.md @@ -28,6 +28,7 @@ weight: 300 | [container](#container) | y | Container configuration. | [See below](#container) | [connections](#connections) | n | List of connections to other resources. | [See below](#connections) | [extensions](#extensions) | n | List of extensions on the container. | [See below](#extensions) +| [runtimes](#runtimes) | n | Runtime specific configurations for the container. | [See below](#runtimes) ### Container @@ -165,3 +166,15 @@ The `manualScaling` extension configures the number of replicas of a compute ins | kind | y | The kind of extension. | `manualScaling` | replicas | Y | The number of replicas to run | `5` | +### Runtimes + +| Key | Required | Description | Example | +|------|:--------:|-------------|---------| +| kubernetes | n | Kubernetes specific configuration for the container. | [See below](#kubernetes) + +#### Kubernetes + +| Key | Required | Description | Example | +|------|:--------:|-------------|---------| +| base | n | The base Kubernetes resource manifest on top of which Radius specified properties will be applied. Supported resource types are documented [here]({{}}). | `loadTextContent('manifest/base-container.yaml')` +| pod | n | The pod specifications to apply to the Kubernetes resource created by Radius. Any field defined on [PodSpec](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#PodSpec) can be set here. | [`topologySpreadConstraints`](https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/#scheduling) diff --git a/docs/content/reference/resource-schema/core-schema/container-schema/snippets/base-container.yaml b/docs/content/reference/resource-schema/core-schema/container-schema/snippets/base-container.yaml new file mode 100644 index 000000000..ce9084c94 --- /dev/null +++ b/docs/content/reference/resource-schema/core-schema/container-schema/snippets/base-container.yaml @@ -0,0 +1,19 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: frontend + labels: + app: frontend +spec: + replicas: 1 + selector: + matchLabels: + app: frontend + template: + metadata: + labels: + app: frontend + spec: + containers: + - name: frontend + image: radiusdev.azurecr.io/magpie:latest \ No newline at end of file diff --git a/docs/content/reference/resource-schema/core-schema/container-schema/snippets/container.bicep b/docs/content/reference/resource-schema/core-schema/container-schema/snippets/container.bicep index e3b2ca0c2..d1a101667 100644 --- a/docs/content/reference/resource-schema/core-schema/container-schema/snippets/container.bicep +++ b/docs/content/reference/resource-schema/core-schema/container-schema/snippets/container.bicep @@ -95,6 +95,20 @@ resource frontend 'Applications.Core/containers@2023-10-01-preview' = { } } ] + runtimes: { + kubernetes: { + base: loadTextContent('base-container.yaml') + pod: { + containers: [ + { + name: 'log-collector' + image: 'radiusdev.azurecr.io/fluent/fluent-bit:2.1.8' + } + ] + hostNetwork: true + } + } + } } } //CONTAINER