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-18942 - Add operator configuration in fleetshard-sync #1157

Merged
merged 8 commits into from
Aug 11, 2023

Conversation

SimonBaeumer
Copy link
Member

@SimonBaeumer SimonBaeumer commented Jul 17, 2023

Description

This PR adds a declarative structure to configure RHACS operators to deploy to a data-plane cluster.
OperatorConfigs represents all Operators including a CRD which should be installed.
The Operators are a slice of OperatorConfig which is applied to the Helm chart.
The Validate function executes extended validation when the configuration is read to provide early failures and being used from a CLI context.
It also validates the Helm chart rendering including CRD download.

The API call to the private Central list call, polled by fleetshard, is extended with a property for the operator configurations.

Data Structure

Example structure:

crd:
  baseURL: https://raw.githubusercontent.com/stackrox/stackrox/%s/operator/bundle/manifests/
  gitRef: 4.1.1
operators:
- gitRef: 4.1.1
  image: "quay.io/rhacs-eng/stackrox-operator:4.1.1"
  helmValues: |
    operator:
      resources:
        requests:
          memory: 500Mi
          cpu: 50m

Checklist (Definition of Done)

  • Unit and integration tests added
  • Added test description under Test manual
  • Documentation added if necessary (i.e. changes to dev setup, test execution, ...)
  • CI and all relevant tests are passing
  • Add the ticket number to the PR title if available, i.e. ROX-12345: ...
  • Discussed security and business related topics privately. Will move any security and business related topics that arise to private communication channel.
  • Add secret to app-interface Vault or Secrets Manager if necessary
  • RDS changes were e2e tested manually
  • Check AWS limits are reasonable for changes provisioning new resources

TODO

  • Test provisioning to a data-plane cluster
  • Add more test cases and validations
    • Test helm chart values are passed to Helm chart
    • More validation tests

Test manual

  • Added unit tests

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jul 17, 2023

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@SimonBaeumer SimonBaeumer temporarily deployed to development July 17, 2023 09:25 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer temporarily deployed to development July 17, 2023 09:25 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer temporarily deployed to development July 17, 2023 09:25 — with GitHub Actions Inactive
Comment on lines 8 to 15
rhacs_operator:
resources:
limits:
cpu: 0.5
memory: "1GiB"
requests:
cpu: 50m
memory: "250MiB"
Copy link
Member Author

Choose a reason for hiding this comment

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

Suggested change
rhacs_operator:
resources:
limits:
cpu: 0.5
memory: "1GiB"
requests:
cpu: 50m
memory: "250MiB"
rhacs_operator:
default:
resources:
limits:
cpu: 0.5
memory: "1GiB"
requests:
cpu: 50m
memory: "250MiB"
quay.io/rhacs-eng/stackrox@sha256:asdfasdfsadfasdfasf:
resources:
limits:
cpu: 0.5
memory: "1GiB"
requests:
cpu: 50m
memory: "250MiB"

@SimonBaeumer SimonBaeumer temporarily deployed to development July 20, 2023 08:19 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer temporarily deployed to development July 20, 2023 08:19 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer temporarily deployed to development July 20, 2023 08:19 — with GitHub Actions Inactive
@@ -115,11 +115,11 @@ spec:
timeoutSeconds: 1
resources:
limits:
cpu: 2
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you put those under operator.resources...? Because we might want to also configure the rbac-proxy (e.g. rbac-proxy.resources...)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, good point

@@ -0,0 +1,15 @@
---
Copy link
Collaborator

Choose a reason for hiding this comment

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

Will this be the git-ops config map as well ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, this will be removed

name: fleetshard-sync-config
data:
config.yaml: |
rhacs_operator:
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this be rather

operators:
- image: ...
   operator:
     resources: ...
     rbacProxy: ...

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes

@SimonBaeumer
Copy link
Member Author

SimonBaeumer commented Jul 21, 2023

@ludydoo fyi The PR is out of date with the recent design changes we discussed.

@SimonBaeumer SimonBaeumer temporarily deployed to development July 21, 2023 09:01 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer temporarily deployed to development July 21, 2023 09:01 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer temporarily deployed to development July 21, 2023 09:01 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer temporarily deployed to development July 21, 2023 09:01 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer temporarily deployed to development July 21, 2023 09:01 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer temporarily deployed to development July 21, 2023 09:01 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer temporarily deployed to development July 21, 2023 13:45 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer temporarily deployed to development July 21, 2023 13:45 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer temporarily deployed to development July 21, 2023 13:45 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer temporarily deployed to development July 24, 2023 09:09 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer temporarily deployed to development July 24, 2023 09:09 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer temporarily deployed to development July 24, 2023 09:09 — with GitHub Actions Inactive
Comment on lines 38 to 40
Image string `yaml:"image"`
GitRef string `yaml:"gitRef"`
HelmValues string `yaml:"helmValues,omitempty"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

using json should work too

return []byte(`
- gitRef: 4.1.1
image: "quay.io/rhacs-eng/stackrox-operator:4.0.0"
helmValues: |
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the reason to use a string here and not an object & unmarshaling it into a map[string]interface{} ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've not found a way to define an unstructured object to the OpenAPI spec.

@SimonBaeumer SimonBaeumer temporarily deployed to development July 24, 2023 09:38 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer temporarily deployed to development July 24, 2023 09:38 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer marked this pull request as ready for review August 8, 2023 14:18
@SimonBaeumer SimonBaeumer temporarily deployed to development August 8, 2023 14:18 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer temporarily deployed to development August 8, 2023 14:18 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer temporarily deployed to development August 8, 2023 14:18 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer requested a review from kurlov August 8, 2023 14:25
@SimonBaeumer SimonBaeumer temporarily deployed to development August 9, 2023 08:04 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer temporarily deployed to development August 9, 2023 08:04 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer temporarily deployed to development August 9, 2023 08:05 — with GitHub Actions Inactive
Copy link
Member

@kurlov kurlov left a comment

Choose a reason for hiding this comment

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

Looking great!

@openshift-ci openshift-ci bot added the lgtm label Aug 9, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 9, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: kurlov, SimonBaeumer

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [SimonBaeumer,kurlov]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot removed the lgtm label Aug 9, 2023
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 9, 2023

New changes are detected. LGTM label has been removed.

@SimonBaeumer SimonBaeumer temporarily deployed to development August 9, 2023 08:27 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer temporarily deployed to development August 9, 2023 08:27 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer temporarily deployed to development August 9, 2023 08:27 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer changed the title Add operator configuration in fleetshard-sync ROX-18942 - Add operator configuration in fleetshard-sync Aug 9, 2023
@SimonBaeumer
Copy link
Member Author

/retest

@@ -28,7 +28,7 @@ type Config struct {
CreateAuthProvider bool `env:"CREATE_AUTH_PROVIDER" envDefault:"false"`
MetricsAddress string `env:"FLEETSHARD_METRICS_ADDRESS" envDefault:":8080"`
EgressProxyImage string `env:"EGRESS_PROXY_IMAGE"`
BaseCrdURL string `env:"BASE_CRD_URL" envDefault:"https://raw.githubusercontent.com/stackrox/stackrox/%s/operator/bundle/manifests/"`
DefaultBaseCRDURL string `env:"DEFAULT_BASE_CRD_URL" envDefault:"https://raw.githubusercontent.com/stackrox/stackrox/%s/operator/bundle/manifests/"`
Copy link
Collaborator

@ludydoo ludydoo Aug 9, 2023

Choose a reason for hiding this comment

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

Consider something like:

Suggested change
DefaultBaseCRDURL string `env:"DEFAULT_BASE_CRD_URL" envDefault:"https://raw.githubusercontent.com/stackrox/stackrox/%s/operator/bundle/manifests/"`
CentralCRDURLTemplate string `env:"CENTRAL_CRD_URL_TEMPLATE" envDefault:"https://raw.githubusercontent.com/stackrox/stackrox/{{ .GitRef }} /operator/bundle/manifests/platform.stackrox.io_centrals.yaml"`

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed the variable and replaced it with a constant. We can overwrite the default via GitOps, there is no need for a config as an env variable, it would be duplicated.

var errors []error
manager := ACSOperatorManager{
// TODO: align config URL with fleetshard-sync default
DefaultBaseCRDURL: "https://raw.githubusercontent.com/stackrox/stackrox/%s/operator/bundle/manifests/",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this duplicated there ?

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed it and replaced with a constant

@SimonBaeumer SimonBaeumer temporarily deployed to development August 10, 2023 13:53 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer temporarily deployed to development August 10, 2023 13:53 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer temporarily deployed to development August 10, 2023 13:53 — with GitHub Actions Inactive
@SimonBaeumer SimonBaeumer merged commit 63d5d0e into main Aug 11, 2023
@SimonBaeumer SimonBaeumer deleted the sb/operator-configuration branch August 11, 2023 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants