Skip to content

Conversation

@jtyr
Copy link
Contributor

@jtyr jtyr commented Dec 14, 2023

This PR is adding securityContext to make the Jobs created by this controller more secure. The default securityContext is set to comply with the Restricted Pod Security Standard profile but it can be further tweaked via the podSecurityContext and the securityContext fields of the HelmChart Custom Resource. Jobs created by the controller are further hardened by enabling readOnlyRootFilesystem and enabling write access only to tmpfs mounts /home/klipper-helm/.(helm|cache|config).

Signed-off-by: Jiri Tyr <[email protected]>
Copy link
Member

@brandond brandond left a comment

Choose a reason for hiding this comment

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

nits/questions

Copy link
Contributor Author

@jtyr jtyr left a comment

Choose a reason for hiding this comment

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

Thanks for the review. All issues should be fixed now.

Signed-off-by: Jiri Tyr <[email protected]>
Copy link
Member

@brandond brandond left a comment

Choose a reason for hiding this comment

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

Can you also call out more specifically the other changes in the PR description? Namely, that in addition to making the SecurityContexts configurable, it also hardens the default values by:

  • Enabling ReadOnlyRootFilesystem
  • Enabling RunAsNonRoot
  • Dropping all capabilities
  • Adding tmpfs mounts for /home/klipper-helm/.(helm|cache|config)

@brandond
Copy link
Member

Looks like one of the tests is failing:

  [FAILED] Expected
      <v1.PodSecurityContext>: {
          SELinuxOptions: nil,
          WindowsOptions: nil,
          RunAsUser: nil,
          RunAsGroup: nil,
          RunAsNonRoot: false,
          SupplementalGroups: nil,
          FSGroup: nil,
          Sysctls: nil,
          FSGroupChangePolicy: nil,
          SeccompProfile: nil,
      }
  to equal
      <v1.PodSecurityContext>: {
          SELinuxOptions: nil,
          WindowsOptions: nil,
          RunAsUser: nil,
          RunAsGroup: nil,
          RunAsNonRoot: false,
          SupplementalGroups: nil,
          FSGroup: nil,
          Sysctls: nil,
          FSGroupChangePolicy: nil,
          SeccompProfile: {
              Type: "RuntimeDefault",
              LocalhostProfile: nil,
          },
      }

@jtyr jtyr force-pushed the jtyr-secctx branch 2 times, most recently from 2dd636f to f60e171 Compare December 17, 2023 16:03
Signed-off-by: Jiri Tyr <[email protected]>
@brandond brandond merged commit f9103f6 into k3s-io:master Dec 19, 2023
@jtyr jtyr deleted the jtyr-secctx branch December 19, 2023 23:52
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