Skip to content

Commit

Permalink
Add dynamic-rp boilerplate (#8029)
Browse files Browse the repository at this point in the history
# Description

This change adds a new control-plane microservice - the "Dynamic RP".
The dynamic-rp will be responsible for implementing the bulk of UDT
functionality. The naming reflects that fact that dynamic-rp behaves
*dynamically* based on the schema definitions provided by users.

This change only contains the *base layer* for dynamic-rp and no
user-visible functionality. Here's a brief list of what's included.

- dynamic-rp binary
- dynamic-rp Dockerfiles
- dynamic-rp Kubernetes yaml
- dynamic-rp configuration file
- initialization and stubs for frontend and backend services
- vscode debugging support
- functional test integration

The actual functionality for dynamic-rp will be added in a series of
follow-up pull-requests.



_Please explain the changes you've made._

## Type of change

- This pull request adds or changes features of Radius and has an
approved issue (issue link required).

Part of: #6688 

## Contributor checklist

Please verify that the PR meets the following requirements, where
applicable:

- [ ] An overview of proposed schema changes is included in a linked
GitHub issue.
- [ ] A design document PR is created in the [design-notes
repository](https://github.com/radius-project/design-notes/), if new
APIs are being introduced.
- [ ] If applicable, design document has been reviewed and approved by
Radius maintainers/approvers.
- [ ] A PR for the [samples
repository](https://github.com/radius-project/samples) is created, if
existing samples are affected by the changes in this PR.
- [ ] A PR for the [documentation
repository](https://github.com/radius-project/docs) is created, if the
changes in this PR affect the documentation or any user facing updates
are made.
- [ ] A PR for the [recipes
repository](https://github.com/radius-project/recipes) is created, if
existing recipes are affected by the changes in this PR.

Signed-off-by: Ryan Nowak <[email protected]>
  • Loading branch information
rynowak authored Nov 6, 2024
1 parent e6c8911 commit 7ac2c22
Show file tree
Hide file tree
Showing 29 changed files with 1,007 additions and 5 deletions.
7 changes: 7 additions & 0 deletions .github/scripts/release-verification.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ kind create cluster
./rad install kubernetes

EXPECTED_APPCORE_RP_IMAGE="ghcr.io/radius-project/applications-rp:${EXPECTED_TAG_VERSION}"
EXPECTED_DYNAMIC_RP_IMAGE="ghcr.io/radius-project/dynamic-rp:${EXPECTED_TAG_VERSION}"
EXPECTED_UCP_IMAGE="ghcr.io/radius-project/ucpd:${EXPECTED_TAG_VERSION}"
EXPECTED_DE_IMAGE="ghcr.io/radius-project/deployment-engine:${EXPECTED_TAG_VERSION}"

APPCORE_RP_IMAGE=$(kubectl describe pods -n radius-system -l control-plane=applications-rp | awk '/^.*Image:/ {print $2}')
DYNAMIC_RP_IMAGE=$(kubectl describe pods -n radius-system -l control-plane=dynamic-rp | awk '/^.*Image:/ {print $2}')
UCP_IMAGE=$(kubectl describe pods -n radius-system -l control-plane=ucp | awk '/^.*Image:/ {print $2}')
DE_IMAGE=$(kubectl describe pods -n radius-system -l control-plane=bicep-de | awk '/^.*Image:/ {print $2}')

Expand All @@ -81,6 +83,11 @@ if [[ "${APPCORE_RP_IMAGE}" != "${EXPECTED_APPCORE_RP_IMAGE}" ]]; then
exit 1
fi

if [[ "${DYNAMIC_RP_IMAGE}" != "${EXPECTED_DYNAMIC_RP_IMAGE}" ]]; then
echo "Error: Dynamic RP image: ${DYNAMIC_RP_IMAGE} does not match the desired image: ${EXPECTED_DYNAMIC_RP_IMAGE}."
exit 1
fi

if [[ "${UCP_IMAGE}" != "${EXPECTED_UCP_IMAGE}" ]]; then
echo "Error: UCP image: ${UCP_IMAGE} does not match the desired image: ${EXPECTED_UCP_IMAGE}."
exit 1
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/functional-test-cloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ jobs:
* Bicep recipe location `${{ env.BICEP_RECIPE_REGISTRY }}/test/testrecipes/test-bicep-recipes/<name>:${{ env.REL_VERSION }}`
* Terraform recipe location `${{ env.TF_RECIPE_MODULE_SERVER_URL }}/<name>.zip` (in cluster)
* applications-rp test image location: `${{ env.CONTAINER_REGISTRY }}/applications-rp:${{ env.REL_VERSION }}`
* dynamic-rp test image location: `${{ env.CONTAINER_REGISTRY }}/dynamic-rp:${{ env.REL_VERSION }}`
* controller test image location: `${{ env.CONTAINER_REGISTRY }}/controller:${{ env.REL_VERSION }}`
* ucp test image location: `${{ env.CONTAINER_REGISTRY }}/ucpd:${{ env.REL_VERSION }}`
* deployment-engine test image location: `${{ env.DE_IMAGE }}:${{ env.DE_TAG }}`
Expand Down Expand Up @@ -647,7 +648,7 @@ jobs:
echo "*** Installing Radius to Kubernetes ***"
rad install kubernetes \
--chart ${{ env.RADIUS_CHART_LOCATION }} \
--set rp.image=${{ env.CONTAINER_REGISTRY }}/applications-rp,rp.tag=${{ env.REL_VERSION }},controller.image=${{ env.CONTAINER_REGISTRY }}/controller,controller.tag=${{ env.REL_VERSION }},ucp.image=${{ env.CONTAINER_REGISTRY }}/ucpd,ucp.tag=${{ env.REL_VERSION }},de.image=${{ env.DE_IMAGE }},de.tag=${{ env.DE_TAG }},global.azureWorkloadIdentity.enabled=true
--set rp.image=${{ env.CONTAINER_REGISTRY }}/applications-rp,rp.tag=${{ env.REL_VERSION }},dynamicrp.image=${{ env.CONTAINER_REGISTRY }}/dynamic-rp,dynamicrp.tag=${{ env.REL_VERSION }}controller.image=${{ env.CONTAINER_REGISTRY }}/controller,controller.tag=${{ env.REL_VERSION }},ucp.image=${{ env.CONTAINER_REGISTRY }}/ucpd,ucp.tag=${{ env.REL_VERSION }},de.image=${{ env.DE_IMAGE }},de.tag=${{ env.DE_TAG }},global.azureWorkloadIdentity.enabled=true
echo "*** Create workspace, group and environment for test ***"
rad workspace create kubernetes
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/functional-test-noncloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ jobs:
RAD_COMMAND="rad install kubernetes \
--chart ${{ env.RADIUS_CHART_LOCATION }} \
--set rp.image=${{ env.LOCAL_REGISTRY_NAME }}:${{ env.LOCAL_REGISTRY_PORT }}/applications-rp,rp.tag=${{ env.REL_VERSION }} \
--set dynamicrp.image=${{ env.LOCAL_REGISTRY_NAME }}:${{ env.LOCAL_REGISTRY_PORT }}/dynamic-rp,dynamicrp.tag=${{ env.REL_VERSION }} \
--set controller.image=${{ env.LOCAL_REGISTRY_NAME }}:${{ env.LOCAL_REGISTRY_PORT }}/controller,controller.tag=${{ env.REL_VERSION }} \
--set ucp.image=${{ env.LOCAL_REGISTRY_NAME }}:${{ env.LOCAL_REGISTRY_PORT }}/ucpd,ucp.tag=${{ env.REL_VERSION }} \
--set de.image=${{ env.DE_IMAGE }},de.tag=${{ env.DE_TAG }}"
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/long-running-azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ jobs:
* Bicep recipe location `${{ env.BICEP_RECIPE_REGISTRY }}/test/testrecipes/test-bicep-recipes/<name>:${{ steps.gen-id.outputs.REL_VERSION }}`
* Terraform recipe location `${{ env.TF_RECIPE_MODULE_SERVER_URL }}/<name>.zip` (in cluster)
* applications-rp test image location: `${{ env.CONTAINER_REGISTRY }}/applications-rp:${{ steps.gen-id.outputs.REL_VERSION }}`
* dynamic-rp test image location: `${{ env.CONTAINER_REGISTRY }}/dynamic-rp:${{ steps.gen-id.outputs.REL_VERSION }}`
* controller test image location: `${{ env.CONTAINER_REGISTRY }}/controller:${{ steps.gen-id.outputs.REL_VERSION }}`
* ucp test image location: `${{ env.CONTAINER_REGISTRY }}/ucpd:${{ steps.gen-id.outputs.REL_VERSION }}`
Expand Down Expand Up @@ -405,7 +406,7 @@ jobs:
echo "*** Installing Radius to Kubernetes ***"
rad install kubernetes --reinstall \
--chart ${{ env.RADIUS_CHART_LOCATION }} \
--set rp.image=${{ env.CONTAINER_REGISTRY }}/applications-rp,rp.tag=${{ env.REL_VERSION }},controller.image=${{ env.CONTAINER_REGISTRY }}/controller,controller.tag=${{ env.REL_VERSION }},ucp.image=${{ env.CONTAINER_REGISTRY }}/ucpd,ucp.tag=${{ env.REL_VERSION }}
--set rp.image=${{ env.CONTAINER_REGISTRY }}/applications-rp,rp.tag=${{ env.REL_VERSION }},dynamicrp.image=${{ env.CONTAINER_REGISTRY }}/dynamic-rp,dynamicrp.tag=${{ env.REL_VERSION }},controller.image=${{ env.CONTAINER_REGISTRY }}/controller,controller.tag=${{ env.REL_VERSION }},ucp.image=${{ env.CONTAINER_REGISTRY }}/ucpd,ucp.tag=${{ env.REL_VERSION }}
- name: Configure Radius test workspace
run: |
set -x
Expand Down
8 changes: 8 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@
"env": {
"RADIUS_ENV": "self-hosted"
}
},{
"name": "Launch Dynamic RP",
"type": "go",
"request": "launch",
"mode": "auto",
"preLaunchTask": "Build Radius (all)",
"program": "${workspaceFolder}/cmd/dynamic-rp/main.go",
},
{
"name": "Launch UCP",
Expand Down Expand Up @@ -108,6 +115,7 @@
"name": "Launch Control Plane (all)",
"configurations": [
"Launch UCP",
"Launch Dynamic RP",
"Launch Applications RP",
"Launch Controller",
"Launch Deployment Engine",
Expand Down
1 change: 1 addition & 0 deletions build/build.mk
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ GOARCHES := amd64 arm arm64
BINARIES := docgen:./cmd/docgen \
rad:./cmd/rad \
applications-rp:./cmd/applications-rp \
dynamic-rp:./cmd/dynamic-rp \
ucpd:./cmd/ucpd \
controller:./cmd/controller \
testrp:./test/testrp \
Expand Down
1 change: 1 addition & 0 deletions build/docker.mk
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ configure-buildx:
# Define a target for each image with name and Dockerfile location
APPS_MAP := ucpd:./deploy/images/ucpd \
applications-rp:./deploy/images/applications-rp \
dynamic-rp:./deploy/images/dynamic-rp \
controller:./deploy/images/controller \
testrp:./test/testrp \
magpiego:./test/magpiego
Expand Down
2 changes: 1 addition & 1 deletion cmd/controller/controller-self-hosted.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ server:

# workerServer port specifies port set for Health Checks
workerServer:
port: 3000
port: 7073
ucp:
kind: direct
direct:
Expand Down
81 changes: 81 additions & 0 deletions cmd/dynamic-rp/cmd/root.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
Copyright 2023 The Radius Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package cmd

import (
"context"
"fmt"
"os"

"github.com/go-logr/logr"
"github.com/spf13/cobra"
runtimelog "sigs.k8s.io/controller-runtime/pkg/log"

"github.com/radius-project/radius/pkg/armrpc/hostoptions"
"github.com/radius-project/radius/pkg/dynamicrp"
"github.com/radius-project/radius/pkg/dynamicrp/server"
"github.com/radius-project/radius/pkg/ucp/hosting"
"github.com/radius-project/radius/pkg/ucp/ucplog"
)

var rootCmd = &cobra.Command{
Use: "dynamic-rp",
Short: "Dyanamic Resource Provider server",
Long: `Server process for the Dynamic Resource Provider (dynamic-rp).`,
RunE: func(cmd *cobra.Command, args []string) error {
configFilePath := cmd.Flag("config-file").Value.String()
bs, err := os.ReadFile(configFilePath)
if err != nil {
return fmt.Errorf("failed to read config file %s: %w", configFilePath, err)
}

config, err := dynamicrp.LoadConfig(bs)
if err != nil {
return fmt.Errorf("failed to parse config file %s: %w", configFilePath, err)
}

options, err := dynamicrp.NewOptions(cmd.Context(), config)
if err != nil {
return err
}

logger, flush, err := ucplog.NewLogger(ucplog.LoggerName, &options.Config.Logging)
if err != nil {
return err
}
defer flush()

// Must set the logger before using controller-runtime.
runtimelog.SetLogger(logger)

host, err := server.NewServer(options)
if err != nil {
return err
}

ctx := logr.NewContext(cmd.Context(), logger)

return hosting.RunWithInterrupts(ctx, host)
},
}

func Execute() {
// Let users override the configuration via `--config-file`.
rootCmd.Flags().String("config-file", fmt.Sprintf("dynamicrp-%s.yaml", hostoptions.Environment()), "The service configuration file.")

cobra.CheckErr(rootCmd.ExecuteContext(context.Background()))
}
43 changes: 43 additions & 0 deletions cmd/dynamic-rp/dynamicrp-dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# This is an example of configuration file.
environment:
name: Dev
roleLocation: "global"
storageProvider:
provider: "apiserver"
apiserver:
context: ''
namespace: 'radius-testing'
queueProvider:
provider: "apiserver"
name: dynamic-rp
apiserver:
context: ''
namespace: 'radius-testing'
secretProvider:
provider: "kubernetes"
profilerProvider:
enabled: false
port: 6062
metricsProvider:
prometheus:
enabled: false
path: "/metrics"
port: 9092
server:
host: "0.0.0.0"
port: 8082
workerServer:
maxOperationConcurrency: 10
maxOperationRetryCount: 2
ucp:
kind: direct
direct:
endpoint: "http://localhost:9000/apis/api.ucp.dev/v1alpha3"
logging:
level: "info"
json: false
bicep:
deleteRetryCount: 20
deleteRetryDelaySeconds: 60
terraform:
path: "/terraform"
23 changes: 23 additions & 0 deletions cmd/dynamic-rp/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Copyright 2023 The Radius Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import "github.com/radius-project/radius/cmd/dynamic-rp/cmd"

func main() {
cmd.Execute()
}
2 changes: 1 addition & 1 deletion cmd/ucpd/ucp-self-hosted-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ metricsProvider:
prometheus:
enabled: false
path: "/metrics"
port: 9090
port: 9091

# Logging configuration
logging:
Expand Down
2 changes: 1 addition & 1 deletion deploy/Chart/templates/controller/configmaps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ data:
queueProvider:
provider: "apiserver"
name: "ucp"
name: "controller"
apiserver:
context: ""
namespace: "radius-system"
Expand Down
58 changes: 58 additions & 0 deletions deploy/Chart/templates/dynamic-rp/configmaps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: dynamic-rp-config
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: dynamic-rp
app.kubernetes.io/part-of: radius
data:
radius-self-host.yaml: |-
# Radius configuration file.
# See https://github.com/radius-project/radius/blob/main/docs/contributing/contributing-code/contributing-code-control-plane/configSettings.md for more information.
environment:
name: self-hosted
roleLocation: "global"
storageProvider:
provider: "apiserver"
apiserver:
context: ""
namespace: "radius-system"
queueProvider:
provider: "apiserver"
name: "dynamic-rp"
apiserver:
context: ""
namespace: "radius-system"
metricsProvider:
prometheus:
enabled: true
path: "/metrics"
port: 9092
profilerProvider:
enabled: true
port: 6062
secretProvider:
provider: kubernetes
server:
host: "0.0.0.0"
port: 8082
workerServer:
maxOperationConcurrency: 10
maxOperationRetryCount: 2
ucp:
kind: kubernetes
logging:
level: "info"
json: true
{{- if and .Values.global.zipkin .Values.global.zipkin.url }}
tracerProvider:
serviceName: "dynamic-rp"
zipkin:
url: {{ .Values.global.zipkin.url }}
{{- end }}
bicep:
deleteRetryCount: 20
deleteRetryDelaySeconds: 60
terraform:
path: "/terraform"
Loading

0 comments on commit 7ac2c22

Please sign in to comment.