-
Notifications
You must be signed in to change notification settings - Fork 101
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
support rad install kubernetes --set values #5243
Conversation
cmd/applink-rp/radius-cloud.yaml
Outdated
logging: | ||
log: "info" | ||
json: true | ||
tracerProvider: | ||
serviceName: "applications.core" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be link
?
cmd/rad/cmd/envInit.go
Outdated
@@ -399,6 +399,6 @@ func createEnvironmentResource(ctx context.Context, kubeCtxName, resourceGroupNa | |||
} | |||
|
|||
func isEmpty(chartArgs *setup.ChartArgs) bool { | |||
var emptyChartArgs setup.ChartArgs | |||
return (chartArgs == nil || *chartArgs == emptyChartArgs) | |||
//var emptyChartArgs setup.ChartArgs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since I introduced a slice of string it does not allow it any more. I might have to add some more code to test fr isEmpty once I get the main functionality working.
@@ -40,7 +40,8 @@ logging: | |||
json: true | |||
tracerProvider: | |||
serviceName: "applications.link" | |||
|
|||
zipkin: | |||
url: "http://jaeger-collector.radius-monitoring.svc.cluster.local:9411/api/v2/spans" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented out code can be deleted
# url: "http://jaeger-collector.radius-monitoring.svc.cluster.local:9411/api/v2/spans" No newline at end of file | ||
#url: "http://jaeger-collector.radius-monitoring.svc.cluster.local:9411/api/v2/spans" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here (commented out code can be deleted)
@@ -57,7 +57,7 @@ spec: | |||
- containerPort: {{ .Values.global.prometheus.port }} | |||
name: metrics | |||
protocol: TCP | |||
{{ end }} | |||
{{ end }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might create an issue while deploying the chart (extra spaces need to be deleted)
@@ -64,7 +64,9 @@ logging: | |||
json: true | |||
|
|||
tracerProvider: | |||
serviceName: "ucp" | |||
serviceName: "applications.core" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be ucp?
serviceName: "ucp" | ||
serviceName: "applications.core" | ||
zipkin: | ||
url: "http://jaeger-collector.radius-monitoring.svc.cluster.local:9411/api/v2/spans" | ||
|
||
# TODO: Enable trace provider in 0.19 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove
@@ -105,7 +105,9 @@ func PopulateDefaultClusterOptions(cliOptions CLIClusterOptions) ClusterOptions | |||
if cliOptions.Radius.AWSProvider != nil { | |||
options.Radius.AWSProvider = cliOptions.Radius.AWSProvider | |||
} | |||
|
|||
if len(cliOptions.Radius.Values) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not quite sure why we need the values?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are trying to implement https://github.com/project-radius/radius/issues/5173#issuecomment-1452655212
it would be somewhat like a wrapper around helm install ( or upgrade)'s set command
pkg/cli/helm/radiusclient.go
Outdated
@@ -194,6 +207,35 @@ func GetAzProvider(options RadiusOptions, kubeContext string) (*azure.Provider, | |||
|
|||
} | |||
|
|||
func GetHelmValues(kubeContext string) (map[string]interface{}, error) { | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove extra line
pkg/cli/setup/chart.go
Outdated
@@ -24,8 +24,13 @@ type ChartArgs struct { | |||
// for display purposes. This is useful when the the actual public IP address of a cluster's ingress | |||
// is not a routable IP. This comes up all of the time for a local cluster. | |||
PublicEndpointOverride string | |||
Values []string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, thats the support for rad install kubernetes --set command. (https://github.com/project-radius/radius/issues/5173#issuecomment-1452655212
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use the existing pkgs from helm repo as possible instead of creating new wheel.
pkg/cli/setup/chart.go
Outdated
@@ -24,8 +24,13 @@ type ChartArgs struct { | |||
// for display purposes. This is useful when the the actual public IP address of a cluster's ingress | |||
// is not a routable IP. This comes up all of the time for a local cluster. | |||
PublicEndpointOverride string | |||
Values []string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add comments here.
Values []string | |
Values []string |
pkg/cli/helm/radiusclient.go
Outdated
@@ -213,6 +221,38 @@ func runRadiusHelmUpgrade(helmConf *helm.Configuration, releaseName string, helm | |||
return runUpgrade(installClient, releaseName, helmChart) | |||
} | |||
|
|||
func addChartValues(helmChart *chart.Chart, values []string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not need to implement key and value parser.
Please refer the following helm chart pkgs:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reimplemented.
cmd/rad/cmd/envInit.go
Outdated
@@ -400,5 +401,6 @@ func createEnvironmentResource(ctx context.Context, kubeCtxName, resourceGroupNa | |||
|
|||
func isEmpty(chartArgs *setup.ChartArgs) bool { | |||
var emptyChartArgs setup.ChartArgs | |||
return (chartArgs == nil || *chartArgs == emptyChartArgs) | |||
emptyChartArgs.Values = []string{} | |||
return (chartArgs == nil || reflect.DeepEqual(*chartArgs, emptyChartArgs)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't it sufficient to check len?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
chartArgs now has a slice Values, therefore deepcopy was needed..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see my comment. I recommend to use string for values arg because helm's parser parse strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reimplemented using string. Please see if that looks better.
pkg/cli/setup/chart.go
Outdated
@@ -37,6 +42,7 @@ func RegisterPersistentChartArgs(cmd *cobra.Command) { | |||
cmd.PersistentFlags().String("ucp-image", "", "Specify the UCP image to use") | |||
cmd.PersistentFlags().String("ucp-tag", "", "Specify the UCP tag to use") | |||
cmd.PersistentFlags().String("public-endpoint-override", "", "Specify the public IP address or hostname of the Kubernetes cluster. It must be in the format: <hostname>[:<port>]. Ex: 'localhost:9000'") | |||
cmd.PersistentFlags().StringArrayVar(&values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name "values" isn't very intuitive. Have you checked this with PM?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AaronCrawfis approved rad install kuberenetes --set.
I got the idea of values from dapr and it seemed to make sense since we are somewhat implementing a wrapper around helm's install/ upgrade, which will overwrite the values.yaml values (https://github.com/project-radius/radius/issues/5173#issuecomment-1452655212 ). Should I rename it to something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest run it by him once....whether we want to call it helmValues or something
pkg/cli/setup/chart.go
Outdated
@@ -24,8 +24,13 @@ type ChartArgs struct { | |||
// for display purposes. This is useful when the the actual public IP address of a cluster's ingress | |||
// is not a routable IP. This comes up all of the time for a local cluster. | |||
PublicEndpointOverride string | |||
Values []string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add some comments here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
pkg/cli/setup/chart.go
Outdated
@@ -37,6 +44,7 @@ func RegisterPersistentChartArgs(cmd *cobra.Command) { | |||
cmd.PersistentFlags().String("ucp-image", "", "Specify the UCP image to use") | |||
cmd.PersistentFlags().String("ucp-tag", "", "Specify the UCP tag to use") | |||
cmd.PersistentFlags().String("public-endpoint-override", "", "Specify the public IP address or hostname of the Kubernetes cluster. It must be in the format: <hostname>[:<port>]. Ex: 'localhost:9000'") | |||
cmd.PersistentFlags().StringArrayVar(&values, "set", []string{}, "set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use String() instead of StringArrayVar(). helm's strvals.ParseInto(val, helmChart.Values) has its own parser to parse comma and KV. So we do not need to get this as value array. Then you do not need addChartValues
because you can just call strvals.ParseInto directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
pkg/cli/helm/radiusclient.go
Outdated
err = addRadiusValues(helmChart, &options) | ||
if err != nil { | ||
return false, fmt.Errorf("failed to add radius values, err: %w, helm output: %s", err, helmOutput.String()) | ||
} | ||
|
||
if options.Values != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think empty string should be handled by ParseInto. so we do not need this if else.
pkg/cli/helm/radiusclient.go
Outdated
err = addRadiusValues(helmChart, &options) | ||
if err != nil { | ||
return false, fmt.Errorf("failed to add radius values, err: %w, helm output: %s", err, helmOutput.String()) | ||
} | ||
|
||
if options.Values != "" { | ||
err := strvals.ParseInto(options.Values, helmChart.Values) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't it overriding the values from L78 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would overwrite if the keys match, for example if someone specified a set with globar.rp.container. I thought eventually when we refactor helm in next sprint, we would remove addRadiusValues and just document --set usage to set different values.
So I had added a TODO comment at L77. Should I add checks to make sure we arent using set for thos eparameters alone?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#5284 created to use this function for functionalities of --tag, --image etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. then I would move this strvals.ParseInto
to the end of the existing addRadiusValues
function and have the unit-test for addRadiusValues.
0af3ea8
to
d3747eb
Compare
@nithyatsu Thanks! You increased 0.3 % of our test coverage! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It increased 0.3% coverage!!!
Thanks for this! I left two comments. Please resolve them before merge :)
pkg/cli/helm/radiusclient.go
Outdated
@@ -284,6 +287,13 @@ func addRadiusValues(helmChart *chart.Chart, options *RadiusOptions) error { | |||
de["tag"] = options.DETag | |||
} | |||
|
|||
if options.Values != "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ParseInfo takes care of empty string. So we do not need this check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed it
pkg/cli/helm/radiusclient_test.go
Outdated
|
||
func Test_AddRadiusValues(t *testing.T) { | ||
var helmChart chart.Chart | ||
helmChart.Values = map[string]interface{}{} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
helmChart.Values = map[string]interface{}{} | |
helmChart.Values = map[string]any{} |
😍 really glad to see this getting worked on |
|
I'm confused about something.... the title says introduce |
Missed updating description... Should be OK now. Also added the github user stopry that gets partially fixed by this command. |
Thanks 👍 - we need to get in the habit of including this info for when we're open source. |
73d22d3
to
ccdf87f
Compare
@@ -37,6 +40,7 @@ func RegisterPersistentChartArgs(cmd *cobra.Command) { | |||
cmd.PersistentFlags().String("ucp-image", "", "Specify the UCP image to use") | |||
cmd.PersistentFlags().String("ucp-tag", "", "Specify the UCP tag to use") | |||
cmd.PersistentFlags().String("public-endpoint-override", "", "Specify the public IP address or hostname of the Kubernetes cluster. It must be in the format: <hostname>[:<port>]. Ex: 'localhost:9000'") | |||
cmd.PersistentFlags().String("set", "", "Set values on the command line (can specify multiple or separate values with commas: key1=val1,key2=val2)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add an example of this to rad install kubernetes
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're also doing #3937 |
For tracer feature mvp, I am templatizing config map and exposing tracer url as a templatized value. This is what I am doing as part of https://dev.azure.com/azure-octo/Incubations/_workitems/edit/6520 . Perhaps I should have a discussion around what else should be available as template? |
But you did implement #3937 - this is a new CLI feature to pass values to the helm chart during installation. |
Description
Introduce rad install kubernetes --set
which can set single or multiple comma separated values for helm chart.
ex:
rad install kubernetes --set global.ucp.image=radius.azurecr.io/ucpd,global.ucp.tag=latest
rad install kubernetes --set global.tracerProvider.zipkin.url=http://jaeger-collector.radius-monitoring.svc.cluster.local:9411/api/v2/spans
Issue reference
Partially Fixes: radius-project/core-team#1117 based on discussion here : https://github.com/project-radius/radius/issues/5173#issuecomment-1452655212
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: