Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How-To: Kubernetes base YAML guide #748

Closed
wants to merge 48 commits into from
Closed
Show file tree
Hide file tree
Changes from 41 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
87aec43
YAML Kubernetes Base documentation
jasonviviano Sep 13, 2023
794aaa9
Merge branch 'edge' into jasonviviano/kubernetes-incremental-guide
jasonviviano Sep 13, 2023
9b84623
Merge branch 'edge' into jasonviviano/kubernetes-incremental-guide
jasonviviano Sep 15, 2023
488932b
Merge branch 'edge' into jasonviviano/kubernetes-incremental-guide
jasonviviano Oct 10, 2023
72a5099
Addressed feedback and added output for user verification
jasonviviano Oct 10, 2023
3c65d48
Apply suggestions from code review
jasonviviano Oct 11, 2023
cf76d5a
Addressing feedback on terminal output and page outline
jasonviviano Oct 11, 2023
6db1579
Merge branch 'jasonviviano/kubernetes-incremental-guide' of https://g…
jasonviviano Oct 11, 2023
59a295f
Removing unnecessary yaml config
jasonviviano Oct 11, 2023
654592a
Merge branch 'edge' into jasonviviano/kubernetes-incremental-guide
jasonviviano Oct 11, 2023
796f62a
Fixing spell check
jasonviviano Oct 11, 2023
0ca7d62
Apply suggestions from code review
jasonviviano Oct 12, 2023
7120924
Addressed page outline feedback and application string was added to b…
jasonviviano Oct 12, 2023
ee7a148
Namespace added to kubectl command
jasonviviano Oct 12, 2023
384ded0
Merge branch 'edge' into jasonviviano/kubernetes-incremental-guide
jasonviviano Oct 12, 2023
7a23481
Merge branch 'edge' into jasonviviano/kubernetes-incremental-guide
jasonviviano Oct 12, 2023
265c40f
Update docs/content/guides/author-apps/kubernetes/howto-yaml-base-sup…
jasonviviano Oct 12, 2023
b08b09f
Update docs/content/guides/author-apps/kubernetes/howto-yaml-base-sup…
jasonviviano Oct 12, 2023
2d2a8cd
Merge branch 'edge' into jasonviviano/kubernetes-incremental-guide
jasonviviano Oct 12, 2023
15732d1
Merge branch 'edge' into jasonviviano/kubernetes-incremental-guide
jasonviviano Oct 13, 2023
82f7397
Merge branch 'edge' into jasonviviano/kubernetes-incremental-guide
jasonviviano Oct 16, 2023
6dfb95a
Merge branch 'edge' into jasonviviano/kubernetes-incremental-guide
jasonviviano Oct 17, 2023
0cbfb8d
Addressed feedback
jasonviviano Oct 17, 2023
fcdabf1
Addressed feedback
jasonviviano Oct 17, 2023
082f285
Merge branch 'edge' into jasonviviano/kubernetes-incremental-guide
jasonviviano Oct 17, 2023
62e724f
Merge branch 'edge' into jasonviviano/kubernetes-incremental-guide
jasonviviano Oct 17, 2023
149e0f8
Merge branch 'edge' into jasonviviano/kubernetes-incremental-guide
jasonviviano Oct 18, 2023
889517e
Apply suggestions from code review
jasonviviano Oct 23, 2023
6d84511
Added sugested format changes
jasonviviano Oct 23, 2023
2e1ac34
Format changes
jasonviviano Oct 23, 2023
7883158
Merge branch 'edge' into jasonviviano/kubernetes-incremental-guide
jasonviviano Oct 24, 2023
f3306cb
Merge branch 'edge' into jasonviviano/kubernetes-incremental-guide
jasonviviano Oct 25, 2023
5c92d79
Apply suggestions from code review
jasonviviano Oct 26, 2023
a2d447b
Merge branch 'edge' into jasonviviano/kubernetes-incremental-guide
jasonviviano Oct 30, 2023
b74299e
Merge branch 'edge' into jasonviviano/kubernetes-incremental-guide
jasonviviano Nov 6, 2023
30aff34
Merge branch 'edge' into jasonviviano/kubernetes-incremental-guide
jasonviviano Nov 13, 2023
7a32bb1
Merge branch 'edge' into jasonviviano/kubernetes-incremental-guide
jasonviviano Nov 27, 2023
5fa516a
Fixed guide based on sync with YoungBu and feedback.
jasonviviano Nov 27, 2023
1d3fbc1
Fixed spellcheck
jasonviviano Nov 27, 2023
8e28441
Merge branch 'edge' into jasonviviano/kubernetes-incremental-guide
jasonviviano Nov 29, 2023
8eaba5a
fixed merge conflict
jasonviviano Nov 29, 2023
02c30cc
Apply suggestions from code review
jasonviviano Nov 30, 2023
fe81915
Fixed sentences that were not grammatically correct.
jasonviviano Nov 30, 2023
62bf76c
Fixing spellcheck
jasonviviano Nov 30, 2023
e7f4027
Merge branch 'edge' into jasonviviano/kubernetes-incremental-guide
willtsai Dec 1, 2023
766f343
Merge branch 'edge' into jasonviviano/kubernetes-incremental-guide
willtsai Dec 6, 2023
05a5580
Merge branch 'edge' into jasonviviano/kubernetes-incremental-guide
willtsai Jan 22, 2024
e046814
Merge branch 'edge' into jasonviviano/kubernetes-incremental-guide
willtsai Jan 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/config/en-custom.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Async
AWSSimpleQueueService
Azure
Blazor
basemanifest
renderer
CAs
clusterissuer
ClusterIssuer
Expand All @@ -39,6 +41,7 @@ Deployable
Dockerfiles
Docsy
DocumentDB
dcd
EKS
eksClusterName
ElastiCache
Expand Down Expand Up @@ -117,6 +120,8 @@ TBD
TCP
Terraform
TLS
tnvx
tq
ToCs
UCP
UDP
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
type: docs
title: "How-To: Migrate from existing Kubernetes resources"
linkTitle: "Migrate from YAML"
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
description: "Learn how to migrate to a Radius container from existing Kubernetes YAML"
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
weight: 500
categories: "How-To"
tags: ["containers","Kubernetes"]
---

This guide will provide an overview of how to migrate your existing Kubernetes resources from [Kubernetes YAML](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#writing-a-deployment-spec).

### 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: Define a base Kubernetes YAML file

In a file named `kubernetes.yaml` define all the Kubernetes resources that correspond to the new Radius container.

Note that the names of the Deployments, Services, and Config Maps all must match each other and the name of the new Radius container. Any other resources can be named differently.
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved

{{< rad file="snippets/basemanifest.yaml" embed=true lang="yaml">}}

### Step 2: Define a Radius container

[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 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:
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved

- 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" >}}
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved

> Radius will override any values found in your Kubernetes manifest file if it finds a value for the same parameter in your `app.bicep` file otherwise it will 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.
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved

### Step 3: Deploy your container

jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
Now that you've defined your Radius Container you can deploy it into your Application.

1. Run [`rad deploy`]({{< ref "rad_deploy" >}}) to deploy your application:

```bash
rad deploy -a demo
```

jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
2. Run `kubectl get all` to verify the Kubernetes resources were created:

```bash
kubectl get all -n default-demo
```

> 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:
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
```
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 <none> 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
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved

jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
1. Run the following command to delete all Pods, Deployments, and Services in the `my-microservice` namespace and the associated Radius Application:

jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
```
rad app delete -a demo
```

jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
## Further reading

- [Kubernetes authoring resources overview]({{< ref "/guides/author-apps/kubernetes/overview" >}})
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
- [Container resource overview]({{< ref "guides/author-apps/containers/overview#kubernetes" >}})
- [Container resource schema]({{< ref "container-schema#runtimes" >}})
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Loading