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

Remote Cluster Configuration for Trivy-Dojo-Report-Operator #84

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

tidusete
Copy link
Contributor

Description

This MR introduces the following changes to the trivy-dojo-report-operator application:

  1. Added support for remote cluster configuration using a Kubernetes configuration (kubeconfig) file.
  2. Implemented conditional RBAC creation based on the presence of a flag.
  3. Updated the login function in the handlers.py file to handle the kubeconfig scenario.

Changes

  1. charts/templates/deployment.yaml:

    • Added a new environment variable KUBECONFIG with the value of the path of the mounted kubeconfig file.
    • Added a new volume mount and volume to handle the kubeconfig file, if provided.
    • Added a conditional check for the createRBAC flag to set the service account name.
  2. charts/templates/rbac.yaml:

    • Added a conditional check for the createRBAC flag to create the service account, cluster role, and cluster role binding.
  3. charts/templates/secret.yaml:

    • Added a new key-value pair to store the remote cluster kubeconfig, if provided.
  4. charts/values.yaml:

    • Added a new field remoteClusterKubeconfig to store the base64-encoded remote cluster kubeconfig.
    • Added a new field createRBAC to control the creation of RBAC resources.
  5. deploy/trivy-dojo-report-operator.yaml:

    • Added a new volume mount and volume to handle the kubeconfig file, if provided.
  6. src/handlers.py:

    • Updated the login_fn function to handle the kubeconfig scenario.
  7. src/settings.py:

    • Added a new environment variable KUBECONFIG to store the path to the kubeconfig file.

Rationale

The primary goal of these changes is to provide the flexibility to fetch vulnerabilities from a remote Kubernetes cluster, in addition to the default behavior of fetching them from the same cluster where the operator is running.

If the remoteClusterKubeconfig value is provided, the operator will use the kubeconfig file to authenticate and interact with the remote cluster. In this case, there is no need to create RBAC resources, as the remote cluster's RBAC configuration will be used.

If the remoteClusterKubeconfig value is not provided, the operator will continue to use the default behavior of fetching vulnerabilities from the same cluster where it is running, and the RBAC resources will be created as before.

The changes to the handlers.py file ensure that the login process handles both the kubeconfig scenario and the default scenario, maintaining backward compatibility.

@tidusete tidusete marked this pull request as ready for review November 14, 2024 17:14
@tidusete
Copy link
Contributor Author

tidusete commented Nov 22, 2024

Can you check it @rndmh3ro and @szEvEz whenever you have time? Thank you so much

@tidusete tidusete force-pushed the Monitor_remote_cluster branch from 60f1538 to 07ee332 Compare November 26, 2024 09:51
@szEvEz
Copy link
Collaborator

szEvEz commented Nov 26, 2024

Hi @tidusete,

thank you for your contribution and your thorough description.
I will try to find some time in the next couple of days to review your request.

As this is a bigger change, also on the general design of this operator, we need to put some more thought into that.

Currently what we were doing, was the following:

  • We had one central DefectDojo Instance
  • Per environment (cluster), we had one trivy-dojo-report-operator deployed, which was sending this information to the central instance

We need to think about where we wanna head with this solution. In the end, we also could support multiple ways/methods on doing that.

@rndmh3ro maybe you can add your 2 cents here as well (design wise)

@tidusete tidusete force-pushed the Monitor_remote_cluster branch from efea7e9 to 27d1ff8 Compare December 5, 2024 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants