Skip to content

Commit

Permalink
refactoring helm chart (#5353)
Browse files Browse the repository at this point in the history
# Description
rad install --set command can now be used to set helm values.
This PR is to refactor helm values.yaml structure and provide final
documentation for different values that can be set using rad install
set.

## Issue reference

<!--
We strive to have all PR being opened based on an issue, where the
problem or feature have been discussed prior to implementation.
-->

Fixes: #5343 

## Checklist

Please make sure you've completed the relevant tasks for this PR, out of
the following list:

* [ ] Code compiles correctly
* [ ] Adds necessary unit tests for change
* [ ] Adds necessary E2E tests for change
* [ ] Unit tests passing
* [ ] Extended the documentation / Created issue for it
  • Loading branch information
nithyatsu authored Mar 29, 2023
1 parent 8368c99 commit 7617329
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 107 deletions.
4 changes: 2 additions & 2 deletions deploy/Chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ dependencies:
- name: ucp
version: '42.42.42-dev'
repository: "file://ucp"
- name: appcore-rp
- name: radius-rp
version: '42.42.42-dev'
repository: "file://appcore-rp"
repository: "file://radius-rp"
9 changes: 5 additions & 4 deletions deploy/Chart/charts/de/templates/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ spec:
value: https://ucp.radius-system:443/apis/api.ucp.dev/v1alpha3
- name: ASPNETCORE_Logging__LogLevel__Default
value: "Debug"
# TODO: Enable trace provider in 0.19
# - name: ASPNETCORE_Zipkin__Endpoint
# value: "http://jaeger-collector.radius-monitoring.svc.cluster.local:9411/api/v2/spans"
image: {{ .Values.global.engine.image }}:{{ .Values.global.engine.tag }}
{{ if and .Values.global.zipkin .Values.global.zipkin.url }}
- name: ASPNETCORE_Zipkin__Endpoint
value: {{ .Values.global.zipkin.url }}
{{ end }}
image: {{ .Values.image }}:{{ .Values.tag }}
name: de
ports:
- containerPort: 6443
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: appcore-rp
description: Applications.Core Radius service
name: radius-rp
description: Radius service
type: application
# We automate versioning of the chart during publishing.
# The value here is only used for a dev build.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ ucp:
logging:
level: "info"
json: true
{{ if and .Values.global.tracerProvider .Values.global.tracerProvider.zipkin .Values.global.tracerProvider.zipkin.url }}
# Distributed Trace configuration
{{ if and .Values.global.zipkin .Values.global.zipkin.url }}
tracerProvider:
serviceName: "applications.link"
zipkin:
url: {{ .Values.global.tracerProvider.zipkin.url }}
url: {{ .Values.global.zipkin.url }}
{{ end }}

{{ end }}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ spec:
- --config-file=/etc/config/radius-self-host.yaml
- --run-link
- --link-config=/etc/config/link-self-host.yaml
image: {{ .Values.global.appcorerp.image }}:{{ .Values.global.appcorerp.tag }}
image: {{ .Values.image }}:{{ .Values.tag }}
env:
- name: SKIP_ARM
value: 'false'
Expand All @@ -41,9 +41,9 @@ spec:
value: 'true'
- name: SKIP_AUTH
value: 'true'
{{ if .Values.global.rp.publicEndpointOverride}}
{{ if .Values.publicEndpointOverride}}
- name: RADIUS_PUBLIC_ENDPOINT_OVERRIDE
value: {{ .Values.global.rp.publicEndpointOverride }}
value: {{ .Values.publicEndpointOverride }}
{{ end }}
name: appcore-rp
ports:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ ucp:
logging:
level: "info"
json: true
{{ if and .Values.global.tracerProvider .Values.global.tracerProvider.zipkin .Values.global.tracerProvider.zipkin.url }}
# Distributed Trace configuration
{{ if and .Values.global.zipkin .Values.global.zipkin.url }}
tracerProvider:
serviceName: "applications.core"
zipkin:
url: {{ .Values.global.tracerProvider.zipkin.url }}
url: {{ .Values.global.zipkin.url }}
{{ end }}
{{ end }}
7 changes: 4 additions & 3 deletions deploy/Chart/charts/ucp/templates/ucp-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,16 @@ metricsProvider:
path: "/metrics"
port: 9090

# Logging configuration
# Logging configuration
logging:
level: "info"
json: true

{{ if and .Values.global.tracerProvider .Values.global.tracerProvider.zipkin .Values.global.tracerProvider.zipkin.url }}
# Distributed Trace configuration
{{ if and .Values.global.zipkin .Values.global.zipkin.url }}
tracerProvider:
serviceName: "ucp"
zipkin:
url: {{ .Values.global.tracerProvider.zipkin.url }}
url: {{ .Values.global.zipkin.url }}
{{ end }}
{{ end }}
6 changes: 3 additions & 3 deletions deploy/Chart/charts/ucp/templates/ucp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
spec:
serviceAccountName: ucp
containers:
- image: "{{ .Values.global.ucp.image }}:{{ .Values.global.ucp.tag }}"
- image: "{{ .Values.image }}:{{ .Values.tag }}"
env:
- name: UCP_CONFIG
value: /etc/config/ucp-config.yaml
Expand All @@ -35,9 +35,9 @@ spec:
value: '/var/tls/cert'
- name: PORT
value: '9443'
{{ if .Values.global.rp.provider.aws }}
{{ if and .Values.provider .Values.provider.aws }}
- name: AWS_REGION
value: {{ .Values.global.rp.provider.aws.region }}
value: {{ .Values.provider.aws.region }}
{{ end }}
name: ucp
ports:
Expand Down
38 changes: 20 additions & 18 deletions deploy/Chart/values.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
de:
image: radius.azurecr.io/deployment-engine
tag: latest
ucp:
image: radius.azurecr.io/ucpd
tag: latest
# provider can be also set using rad env init --provider-aws
# provider:
# aws:
# region:"us-east"
radius-rp:
image: radius.azurecr.io/appcore-rp
tag: latest
publicEndpointOverride: ""
global:
engine:
image: radius.azurecr.io/deployment-engine
tag: latest
appcorerp:
image: radius.azurecr.io/appcore-rp
tag: latest # Tag for appcore-rp image.
provider:
azure: {}
ucp:
image: radius.azurecr.io/ucpd
tag: latest # Tag for ucp image.
radius:
container: radius.azurecr.io/radius-controller
tag: latest # Tag for radius-controller image.
rp:
provider:
azure: {}
publicEndpointOverride: ""
prometheus:
enabled: true
path: "/metrics"
port: 9090
#
# Configure global.zipkin.url to enable distributed trace. Replace the example url
# below with the environment specific url
# zipkin:
# url: "http://jaeger-collector.radius-monitoring.svc.cluster.local:9411/api/v2/spans"
#
78 changes: 10 additions & 68 deletions pkg/cli/helm/radiusclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,6 @@ func ApplyRadiusHelmChart(options RadiusOptions, kubeContext string) (bool, erro
return false, fmt.Errorf("failed to add radius values, err: %w, helm output: %s", err, helmOutput.String())
}

if options.AzureProvider != nil {
err = addAzureProviderValues(helmChart, options.AzureProvider)
if err != nil {
return false, fmt.Errorf("failed to add azure provider values, err: %w, helm output: %s", err, helmOutput.String())
}
}

if options.AWSProvider != nil {
err = addAWSProviderValues(helmChart, options.AWSProvider)
if err != nil {
Expand Down Expand Up @@ -301,76 +294,25 @@ func addAWSProviderValues(helmChart *chart.Chart, awsProvider *aws.Provider) err
}
values := helmChart.Values

_, ok := values["global"]
_, ok := values["ucp"]
if !ok {
values["global"] = make(map[string]any)
values["ucp"] = make(map[string]any)
}
global := values["global"].(map[string]any)
ucp := values["ucp"].(map[string]any)

_, ok = global["rp"]
_, ok = ucp["provider"]
if !ok {
global["rp"] = make(map[string]any)
ucp["provider"] = make(map[string]any)
}
rp := global["rp"].(map[string]any)
provider := ucp["provider"].(map[string]any)

_, ok = rp["provider"]
_, ok = provider["aws"]
if !ok {
rp["provider"] = make(map[string]any)
}
provider := rp["provider"].(map[string]any)

provider["aws"] = map[string]any{
"accessKeyId": awsProvider.AccessKeyId,
"secretAccessKey": awsProvider.SecretAccessKey,
"region": awsProvider.TargetRegion,
}

return nil
}

func addAzureProviderValues(helmChart *chart.Chart, azureProvider *azure.Provider) error {
if azureProvider == nil {
return nil
}
values := helmChart.Values

_, ok := values["global"]
if !ok {
values["global"] = make(map[string]any)
}
global := values["global"].(map[string]any)

_, ok = global["rp"]
if !ok {
global["rp"] = make(map[string]any)
}
rp := global["rp"].(map[string]any)

_, ok = rp["provider"]
if !ok {
rp["provider"] = make(map[string]any)
}
provider := rp["provider"].(map[string]any)

_, ok = provider["azure"]
if !ok {
provider["azure"] = make(map[string]any)
}

azure := provider["azure"].(map[string]any)

if azureProvider.ServicePrincipal != nil {
_, ok = azure["servicePrincipal"]
if !ok {
azure["servicePrincipal"] = make(map[string]any)
}
azure["servicePrincipal"] = map[string]any{
"clientId": azureProvider.ServicePrincipal.ClientID,
"clientSecret": azureProvider.ServicePrincipal.ClientSecret,
"tenantId": azureProvider.ServicePrincipal.TenantID,
}
provider["aws"] = make(map[string]any)
}
aws := provider["aws"].(map[string]any)

aws["region"] = awsProvider.TargetRegion
return nil
}

Expand Down

0 comments on commit 7617329

Please sign in to comment.