Skip to content

Commit

Permalink
Addressed feedback and added output for user verification
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonviviano committed Oct 10, 2023
1 parent 488932b commit 72a5099
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 27 deletions.
1 change: 1 addition & 0 deletions .github/config/en-custom.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Async
AWSSimpleQueueService
Azure
Blazor
basemanifest
clusterissuer
ClusterIssuer
CLI
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,41 @@
---
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 `<envNamespace>-<appname>`. 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" >}}

### Step 2: Map your Kubernetes base YAML file to a Radius container 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.
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -59,15 +59,15 @@ spec:
apiVersion: v1
kind: ServiceAccount
metadata:
name: manifest-default
name: my-microservice
annotations:
source: base-manifest-test
---
# Not supported in Radius yet
apiVersion: v1
kind: Secret
metadata:
name: manifest-default-secret0
name: my-microservice-secret0
annotations:
source: base-manifest-test
type: Opaque
Expand All @@ -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
Expand All @@ -89,7 +89,7 @@ stringData:
apiVersion: v1
kind: ConfigMap
metadata:
name: manifest-default-config
name: my-microservice-config
annotations:
source: base-manifest-test
data:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
---
Expand Down

0 comments on commit 72a5099

Please sign in to comment.