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 3 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
type: docs
title: "How-To: Incremental onboard from existing Kubernetes resources"
linkTitle: "Incremental onboard from existing Kubernetes resources"
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
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
categories: "How-To"
tags: ["Kubernetes"]
---

### 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/)
- [Radius initialized with `rad init`]({{< ref howto-environment >}})

### Step 1: Author a Radius Application
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved

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

{{< rad file="snippets/basemanifest.bicep" embed=true marker="//APPLICATION" >}}

### Step 2: Map your Kubernetes base YAML file to a Radius container resource
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved

You'll need to create a Radius container resource that will consume the information found in your Kubernetes base YAML file.

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

jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
#### Container configurations

Define your Radius container resource port with the port of your Kubernetes `Service` as well as the image container location that your service is dependent on.

#### Runtime configuration

jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
Load your Kubernetes YAML file into your Radius container resource through the `properties.runtimes.kubernetes.base` property which expects a string value containing all your Kubernetes data.
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved

{{< rad file="snippets/basemanifest.bicep" embed=true marker="//CONTAINER" >}}

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

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
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import radius as radius

@description('Specifies the location for resources.')
param location string = 'global'
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved

@description('Specifies the image of the container resource.')
param magpieimage string = 'ghcr.io/radius-project/dev/magpiego:pr-498da3203f'
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved

@description('Specifies the port of the container resource.')
param port int = 3000
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved

@description('Specifies the environment for resources.')
param environment string
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved

@description('Specifies the namespace for resources.')
param namespace string

//APPLICATION
resource app 'Applications.Core/applications@2022-03-15-privatepreview' = {
name: 'manifest-default'
location: location
properties: {
environment: environment
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
extensions: [
{
kind: 'kubernetesNamespace'
namespace: namespace
}
]
}
}
//APPLICATION

//CONTAINER
@description('Loads the Kubernetes base manifest file and turns content into a string.')
var manifest = loadTextContent('./basemanifest.yaml')
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved

resource container 'Applications.Core/containers@2022-03-15-privatepreview' = {
// Name must match with `ServiceAccount`, `Deployment`, and `Service` objects
name: 'your-manifest-default-name'
location: location
properties: {
application: app.id
container: {
// Points to your container image
image: magpieimage
ports: {
web: {
// Port must match with `Service` object port
containerPort: port
}
}
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
}
connections: {}
runtimes: {
kubernetes: {
base: manifest
}
}
}
}
//CONTAINER
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: manifest-default
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
labels:
app: manifest-default
annotations:
source: base-manifest-test
spec:
replicas: 3
selector:
matchLabels:
app: manifest-default
template:
metadata:
labels:
app: manifest-default
spec:
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
serviceAccountName: manifest-default
volumes:
- name: secret-vol
secret:
secretName: manifest-default-secret0
containers:
- name: manifest-default
ports:
- containerPort: 80
protocol: TCP
volumeMounts:
- name: secret-vol
readOnly: true
mountPath: /etc/secret-vol
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
env:
- name: TEST_SECRET_KEY
valueFrom:
secretKeyRef:
name: manifest-default-secret1
key: secret1
- name: TEST_CONFIGMAP_KEY
valueFrom:
configMapKeyRef:
name: manifest-default-config
key: TEST_CONFIGMAP
---
apiVersion: v1
kind: Service
metadata:
name: manifest-default
annotations:
source: base-manifest-test
spec:
selector:
app.kubernetes.io/name: manifest-default
ports:
- protocol: TCP
port: 3000
targetPort: 3000
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: manifest-default
annotations:
source: base-manifest-test
---
# Not supported in Radius yet
apiVersion: v1
kind: Secret
metadata:
name: manifest-default-secret0
annotations:
source: base-manifest-test
type: Opaque
stringData:
'secret0': test-secret-0
---
# Not supported in Radius yet
jasonviviano marked this conversation as resolved.
Show resolved Hide resolved
apiVersion: v1
kind: Secret
metadata:
name: manifest-default-secret1
annotations:
source: base-manifest-test
type: Opaque
stringData:
'secret1': test-secret-1
---
# Not supported in Radius yet
apiVersion: v1
kind: ConfigMap
metadata:
name: manifest-default-config
annotations:
source: base-manifest-test
data:
TEST_CONFIGMAP: test-configmap