Skip to content

feat(test): Allow extension of test pod to allow matching local policy#182

Merged
rhamzeh merged 3 commits intoopenfga:mainfrom
grimly:test-pod-extension
Mar 31, 2025
Merged

feat(test): Allow extension of test pod to allow matching local policy#182
rhamzeh merged 3 commits intoopenfga:mainfrom
grimly:test-pod-extension

Conversation

@grimly
Copy link
Contributor

@grimly grimly commented Jan 3, 2025

Provides the ability to extends the definition of the connection test pod.

Description

The helm chart uses a pod to test its correct deployment.
There is no ability to extend the definition of this pod and therefore to make the pod match any policy in place.

Such policy preventing the test pod deployment might be (not exhaustive):

  • Resource quota without ability to provide a default value with a limit range
  • ValidatingWebhookConfiguration based constraints with products such as kyverno or OPA

Here is a working example of a configuration matching the resource quota constraint :

testContainerSpec:
  resources:
    limits:
      cpu: 1
      memory: 250M
    requests:
      cpu: 50m
      memory: 250M
testPodSpec:
  securityContext:
    runAsNonRoot: true
    runAsUser: 1000
    runAsGroup: 1000

References

This feature is documented by the value schemas.

Review Checklist

  • I have clicked on "allow edits by maintainers".
  • I have added documentation for new/changed functionality in this PR or in a PR to openfga.dev [Provide a link to any relevant PRs in the references section above]
  • The correct base branch is being used, if not main
  • I have added tests to validate that the change in functionality is working as expected

@grimly grimly requested review from a team as code owners January 3, 2025 17:12
@whoisxx
Copy link
Contributor

whoisxx commented Jan 29, 2025

@grimly It could lead to unexpected security and deployment issues if we allow such broad configuration. Could you share the specific problem or challenge that led to this PR, so we can better understand the intent behind it?

@grimly
Copy link
Contributor Author

grimly commented Jan 31, 2025

Hello,

It is specifically security concerns that made me open this PR.

As it is without this PR merged, the test pod run as root while it doesn't need to.

It also lack resource allocation.

My company enforces quota and limit ranges without default values and uses a validating webhook to enforce running as non-root.

My goal was to provide configuration and not to apply limitations from my own experience to the rest of the community.

@whoisxx
Copy link
Contributor

whoisxx commented Feb 3, 2025

Right now, testContainerSpec seems too broad in scope, allowing arbitrary configurations for the test container.
Since the main goal is to adjust resource limits and security settings, wouldn't it make sense to replace testContainerSpec with explicit resources and securityContext fields like below?

            command: ["grpc_health_probe", '-addr={{ include "openfga.fullname" . }}:{{ (split ":" .Values.grpc.addr)._1 }}']
            {{- with .Values.test.resources }}
            resources:
              {{- toYaml . | nindent 8 }}
            {{- end }}
            {{- with .Values.test.securityContext }}
            securityContext:
              {{- toYaml . | nindent 8 }}
            {{- end }}

Copy link
Member

@rhamzeh rhamzeh left a comment

Choose a reason for hiding this comment

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

Thanks @grimly!

@rhamzeh rhamzeh requested a review from a team as a code owner March 19, 2025 16:01
@rhamzeh rhamzeh enabled auto-merge (squash) March 31, 2025 16:02
@rhamzeh rhamzeh merged commit c7dbdda into openfga:main Mar 31, 2025
4 checks passed
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.

3 participants

Comments