Remote Cluster Configuration for Trivy-Dojo-Report-Operator #84
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This MR introduces the following changes to the
trivy-dojo-report-operator
application:handlers.py
file to handle the kubeconfig scenario.Changes
charts/templates/deployment.yaml
:KUBECONFIG
with the value of the path of the mounted kubeconfig file.createRBAC
flag to set the service account name.charts/templates/rbac.yaml
:createRBAC
flag to create the service account, cluster role, and cluster role binding.charts/templates/secret.yaml
:charts/values.yaml
:remoteClusterKubeconfig
to store the base64-encoded remote cluster kubeconfig.createRBAC
to control the creation of RBAC resources.deploy/trivy-dojo-report-operator.yaml
:src/handlers.py
:login_fn
function to handle the kubeconfig scenario.src/settings.py
: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.