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

Added logic to watch all namespaces #38

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

orifici
Copy link

@orifici orifici commented Oct 13, 2021

The motivation for this PR is that currently, this helm chart only provides the option to watch a single namespace either be it the release namespace or the value in the k8WatchNamespace . This PR provides the functionality to explicitly allow the operator to watch all namespaces.

This pull request adds:

  • A .Values flag watchAllNamespaces (default to false) to watch for workspace CRDs in all namespaces
  • A helper function that returns a Role or ClusterRole based on the value of the original k8WatchNamespace var and the new watchAllNamespaces var

⚠️ Please note
We're raising this as a draft PR and then If you folks are OK with these changes - we can add all the required tests as per guidelines.

James-Newman and others added 6 commits October 13, 2021 14:20
Default value is false to maintain backward compatability
Updated logic around RoleBinding vs ClusterRoleBinding
based on watchAllNamespaces value
@hashicorp-cla
Copy link

hashicorp-cla commented Oct 13, 2021

CLA assistant check
All committers have signed the CLA.




### Helm Chart
Copy link

Choose a reason for hiding this comment

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

I would skip this paragraph completely.


The Helm chart consists of several components. The Kubernetes configurations associated with the Helm chart are located under `crds/` and `templates/`.

#### Custom Resource Definition
Copy link

Choose a reason for hiding this comment

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

I would skip this paragraph completely.


The Custom Resource Definition under `crds/app.terraform.io_workspaces_crd.yaml` defines that the Workspace Custom Resource schema.

#### Role-Based Access Control
Copy link

Choose a reason for hiding this comment

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

I would skip this paragraph completely.

fieldPath: metadata.namespace
```

When deploying, if you want to explicitly watch all namespaces,
Copy link

Choose a reason for hiding this comment

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

Line wrapping should be on 80 characters.


#### Namespace Scope

To ensure the operator does not have access to secrets or resource beyond the namespace, the Helm chart scopes the operator's deployment to a namespace.
Copy link

Choose a reason for hiding this comment

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

Line wrapping should be on 80 characters.

Define the kind of Role to use
*/}}
{{- define "terraform.getRole" -}}
{{- if .Values.syncWorkspace.watchAllNamespaces -}}
Copy link

Choose a reason for hiding this comment

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

I would change this to this:

{{/*
Define the kind of Role to use
*/}}
{{- define "terraform.getRole" -}}
  {{- if or .Values.syncWorkspace.watchAllNamespaces (or (empty .Values.syncWorkspace.k8WatchNamespace) (eq (.Values.syncWorkspace.k8WatchNamespace | toString) .Release.Namespace)) }}
    {{- "ClusterRole" }}
  {{- else }}
    {{- "Role" }}
  {{- end }}
{{- end -}}

@robcoward
Copy link

I would love to see this PR merged - any chance of getting some traction here please ?

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.

None yet

5 participants