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

ROX-20450: Configure operator resources in chart #1417

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Expand Up @@ -50,11 +50,11 @@ spec:
protocol: TCP
resources:
limits:
cpu: 2
memory: 1Gi
cpu: {{ ((((.rbac).resources).limits).cpu) | default $.Values.operator.default.rbac.resources.limits.cpu }}
memory: {{ ((((.rbac).resources).limits).memory) | default $.Values.operator.default.rbac.resources.limits.memory }}
requests:
cpu: 1
memory: 200Mi
cpu: {{ ((((.rbac).resources).requests).cpu) | default $.Values.operator.default.rbac.resources.requests.cpu }}
memory: {{ ((((.rbac).resources).requests).memory) | default $.Values.operator.default.rbac.resources.requests.memory }}
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
- args:
Expand Down Expand Up @@ -127,11 +127,11 @@ spec:
timeoutSeconds: 1
resources:
limits:
cpu: 2
memory: 1Gi
cpu: {{ (((.resources).limits).cpu) | default $.Values.operator.default.resources.limits.cpu }}
memory: {{ (((.resources).limits).memory) | default $.Values.operator.default.resources.limits.memory }}
requests:
cpu: 1
memory: 200Mi
cpu: {{ (((.resources).requests).cpu) | default $.Values.operator.default.resources.requests.cpu }}
memory: {{ (((.resources).requests).memory) | default $.Values.operator.default.resources.requests.memory }}
securityContext:
allowPrivilegeEscalation: false
terminationMessagePath: /dev/termination-log
Expand Down
19 changes: 18 additions & 1 deletion fleetshard/pkg/central/charts/data/rhacs-operator/values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,22 @@
operator:
# default values for resources. These values will be used if there is no gitops overrides
default:
resources:
limits:
cpu: "2"
memory: "2Gi"
requests:
cpu: "1"
memory: "1Gi"
rbac:
resources:
limits:
cpu: "2"
memory: "1Gi"
requests:
cpu: "1"
memory: "200Mi"

# Each item in this list will install an operator deployment.
# images:
#
Expand Down Expand Up @@ -37,5 +55,4 @@ operator:
# securedClusterReconcilerEnabled: true
#
images: []
# TODO: add values + modify template for overriding resource limits and requests for both proxy and manager container
# TODO: add value for kube-rbac-proxy image
9 changes: 7 additions & 2 deletions fleetshard/pkg/central/operator/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,18 @@ func RenderChart(operators OperatorConfigs) ([]*unstructured.Unstructured, error
for _, operator := range operators.Configs {
valuesArr = append(valuesArr, chartutil.Values(operator))
}

resourcesChart, err := charts.GetChart("rhacs-operator", operators.CRDURLs)
operatorValues := resourcesChart.Values["operator"].(map[string]interface{})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to safe-cast here,
e.g

operatorValues, ok := resourcesChart.Values["operator"].(map[string]interface{})
if !ok { return fmt.Errorf("...") }
defaultValues, ok  := ...

defaultValues := operatorValues["default"].(map[string]interface{})

chartVals := chartutil.Values{
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is an obvious room for improvement in how to chart values constructed but I would prefer a separate PR for this

"operator": chartutil.Values{
"images": valuesArr,
"images": valuesArr,
"default": chartutil.Values(defaultValues),
},
}

resourcesChart, err := charts.GetChart("rhacs-operator", operators.CRDURLs)
if err != nil {
return nil, fmt.Errorf("failed getting chart: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion fleetshard/pkg/central/operator/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func validateCRDUrls(path *field.Path, urls []string) field.ErrorList {

func validateCRDURL(path *field.Path, urlStr string) field.ErrorList {
var errs field.ErrorList
if _, err := url.Parse(urlStr); err != nil {
if _, err := url.ParseRequestURI(urlStr); err != nil {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parse doesn't complain about broken url string

errs = append(errs, field.Invalid(path, urlStr, fmt.Sprintf("invalid url: %s", err.Error())))
}
return errs
Expand Down
4 changes: 2 additions & 2 deletions fleetshard/pkg/central/operator/validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ func TestGetOperatorConfigFailsValidation(t *testing.T) {
"should fail with invalid crd url": {
getConfig: func(t *testing.T, config OperatorConfigs) OperatorConfigs {
config.CRDURLs = []string{
"invalid url",
"broken url",
}
return config
},
contains: "failed downloading chart files",
contains: "invalid url",
},
"should fail with empty deployment name": {
getConfig: func(t *testing.T, config OperatorConfigs) OperatorConfigs {
Expand Down
Loading