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 7e760a1a9..0f7421e71 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 @@ -30,15 +30,17 @@ Note that the names of the Deployments, Services, and Config Maps all must match [Radius containers]({{< ref "/guides/author-apps/containers/overview" >}}) represent a containerized workload within your Radius Application. You can define a Radius container and reference your Kubernetes YAML in order to deploy and manage it within Radius. -In a file named "app.bicep" add a new Container resource, specifying: +In a file named "app.bicep" add any missing parameter that isn't found in your manifest file in your new Container resource. This could range from anything like a new such as: -- The container image +- The container image path - The port(s) your container exposes - The contents of your Kubernetes YAML file {{< rad file="snippets/basemanifest.bicep" embed=true marker="//CONTAINER" >}} +> Radius will override any values found in your Kubernetes manifest file if it finds a value for the same paramater in your `app.bicep` file otherwise it wil use the value and only fill in the gaps in your manifest. However if you define a parameter such as image name in the different container like sidecar, container renderer will not override the image location. + ### Step 3: Deploy your container Now that you've defined your Radius Container you can deploy it into your Application. @@ -58,22 +60,25 @@ Now that you've defined your Radius Container you can deploy it into your Applic > Radius deploys app resources into a unique namespace for every app. For more information refer to the [Kubernetes docs]({{< ref "/guides/operations/kubernetes/overview#namespace-mapping" >}}). 3. Your console output should look similar to: ``` -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 +NAME READY STATUS RESTARTS AGE +pod/my-microservice-795545bf79-glbhw 1/1 Running 0 21s + +NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE +service/my-microservice ClusterIP 10.43.177.210 3000/TCP 18s + +NAME READY UP-TO-DATE AVAILABLE AGE +deployment.apps/my-microservice 1/1 1 1 2m41s + +NAME DESIRED CURRENT READY AGE +replicaset.apps/my-microservice-795545bf79 1 1 1 21s +replicaset.apps/my-microservice-96dc8569d 0 0 0 2m41s ``` ### Step 4: Clean up -1. Run the following command to delete all Pods, Deployments, and Services in the `my-microservice` namespace: +1. Run the following command to delete all Pods, Deployments, and Services in the `my-microservice` namespace and the associated Radius Application: - ```bash - kubectl delete -n my-microservice -f ./deploy ``` -2. Run the following command to delete the `my-microservice` namespace: - - ```bash - kubectl delete namespace my-microservice + rad app delete -a demo ``` ## Further reading diff --git a/docs/content/guides/author-apps/kubernetes/howto-yaml-base-support/snippets/app.bicep b/docs/content/guides/author-apps/kubernetes/howto-yaml-base-support/snippets/app.bicep new file mode 100644 index 000000000..5666ea45c --- /dev/null +++ b/docs/content/guides/author-apps/kubernetes/howto-yaml-base-support/snippets/app.bicep @@ -0,0 +1,27 @@ +import radius as radius + +@description('The app ID of your Radius Application. Set automatically by the rad CLI.') +param application string + +//CONTAINER +@description('Loads the Kubernetes base manifest file and turns content into a string.') +var manifest = loadTextContent('./manifest.yaml') + +resource container 'Applications.Core/containers@2023-10-01-preview' = { + // Name must match with `ServiceAccount`, `Deployment`, and `Service` objects + name: 'my-microservice' + properties: { + application: application + container: { + // Points to your container image + image: 'ghcr.io/radius-project/samples/demo:latest' + } + connections: {} + runtimes: { + kubernetes: { + base: manifest + } + } + } +} +//CONTAINER 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 deleted file mode 100644 index cd3e66316..000000000 --- a/docs/content/guides/author-apps/kubernetes/howto-yaml-base-support/snippets/basemanifest.bicep +++ /dev/null @@ -1,43 +0,0 @@ -import radius as radius - - -@description('Specifies the image of the container resource.') -param magpieimage string = 'ghcr.io/radius-project/dev/magpiego:pr-498da3203f' - -@description('Specifies the port of the container resource.') -param port int = 3000 - -@description('Specifies the environment for resources.') -param environment string - -@description('Specifies the application for resources.') -param application string - -//CONTAINER -@description('Loads the Kubernetes base manifest file and turns content into a string.') -var manifest = loadTextContent('./basemanifest.yaml') - -resource container 'Applications.Core/containers@2023-10-01-preview' = { - // Name must match with `ServiceAccount`, `Deployment`, and `Service` objects - name: 'my-microservice' - properties: { - application: application - container: { - // Points to your container image - image: magpieimage - ports: { - web: { - // Port must match with `Service` object port - containerPort: port - } - } - } - connections: {} - runtimes: { - kubernetes: { - base: manifest - } - } - } -} -//CONTAINER 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 deleted file mode 100644 index 7a17f81eb..000000000 --- a/docs/content/guides/author-apps/kubernetes/howto-yaml-base-support/snippets/basemanifest.yaml +++ /dev/null @@ -1,54 +0,0 @@ -apiVersion: apps/v1 -kind: Deployment -metadata: - name: my-microservice - labels: - app: my-microservice - annotations: - source: base-manifest-test -spec: - replicas: 3 - selector: - matchLabels: - app: my-microservice - template: - metadata: - labels: - app: my-microservice - spec: - serviceAccountName: my-microservice - volumes: - - name: secret-vol - secret: - secretName: my-microservice-secret0 - containers: - - name: my-microservice - ports: - - containerPort: 80 - protocol: TCP - volumeMounts: - - name: secret-vol - readOnly: true - mountPath: /etc/secret-vol ---- -apiVersion: v1 -kind: Service -metadata: - name: my-microservice - annotations: - source: base-manifest-test -spec: - selector: - app.kubernetes.io/name: my-microservice - ports: - - protocol: TCP - port: 3000 - targetPort: 3000 ---- -apiVersion: v1 -kind: ServiceAccount -metadata: - name: my-microservice - annotations: - source: base-manifest-test ---- \ No newline at end of file diff --git a/docs/content/guides/author-apps/kubernetes/howto-yaml-base-support/snippets/manifest.yaml b/docs/content/guides/author-apps/kubernetes/howto-yaml-base-support/snippets/manifest.yaml new file mode 100644 index 000000000..d95c82447 --- /dev/null +++ b/docs/content/guides/author-apps/kubernetes/howto-yaml-base-support/snippets/manifest.yaml @@ -0,0 +1,12 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: my-microservice # Required for Radius validation + labels: + app: my-microservice # Radius will perform a synthetic validation but a hard requirement +spec: + selector: + template: + spec: + containers: + - name: my-microservice