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 the SecurityContext for Driver #1001

Merged
merged 1 commit into from
May 17, 2023

Conversation

mskanth972
Copy link
Contributor

Is this a bug fix or adding new feature?

What is this PR about? / Why do we need it?
This PR adds the Security Context for the EFS CSI driver.

What testing is done?
Deployed the CSI driver with the latest yaml which has the changes and working fine.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label May 10, 2023
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 10, 2023
# securityContext on the node pod
securityContext:
# The node pod must be run as root to bind to the registration/driver sockets
runAsNonRoot: false
Copy link
Contributor

@Ashley-wenyizha Ashley-wenyizha May 16, 2023

Choose a reason for hiding this comment

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

Bit confused here

From the comment it's saying that The node pod must be run as root to bind to the registration/driver sockets

but then why we set runAsNonRoot: false ?

^^ Ignore this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

runAsNonRoot: false which means root: true. We are explicitly declaring important security configurations.

# securityContext on the controller pod
securityContext:
runAsNonRoot: false
runAsUser: 0
Copy link
Contributor

Choose a reason for hiding this comment

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

So if understand right, runAsUser allows us to specify UID that should be used when running a container and enforce user-level access controls and provides additional security within the cluster per reading k8s docs

I understand that value we should set for runAsUser depends on specific requirements and the user privileges needed by the application. I see you are using 0 and that will be running containers as the root user (UID 0) and why did we pick to run as root use?

I think running as a non-root user provides an additional layer of security by reducing the potential impact of a container compromise.

We can maybe choose a specific non-root user ID to use, such as 1000? Unless we have another reason here to use 0.

Copy link
Contributor

Choose a reason for hiding this comment

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

Same to other '0's we set below and in other yaml files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Only efs-plugin needs the root user to mount the efs storage at nodes root level folder. Other containers are running as non root.

Copy link
Member

Choose a reason for hiding this comment

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

I believe the Pod & container securityContext config is merged but I don't see the override in the containers. As it is right now are the containers running as root now?

@Ashley-wenyizha
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 17, 2023
@Ashley-wenyizha
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Ashley-wenyizha, mskanth972

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [Ashley-wenyizha,mskanth972]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@TobiasRD
Copy link

TobiasRD commented Aug 16, 2023

Hey @mskanth972 when updating the helm chart to 2.4.8, which includes this change, I get trouble with the readOnlyRootFilesystem=true for the csi-driber-registrar.
I get the following error:
"Failed to create registration probe file" err="mkdir /var/lib/kubelet: read-only file system" registrationProbePath="/var/lib/kubelet/plugins/efs.csi.aws.com/registration"

Still the pod turns ready and mounting efs works.

Do you have any idea? (beside setting it to false)

@mauriciopoppe
Copy link
Member

@TobiasRD this is a known issue in node-driver-registrar which will be fixed soon in kubernetes-csi/node-driver-registrar#316. The workaround is to not use readOnlyRootFilesystem for now but once there's a new node-driver-registrar release with the above fix then you'd be able to use readOnlyRootFilesystem: true.

@mskanth972
Copy link
Contributor Author

@TobiasRD this is a known issue in node-driver-registrar which will be fixed soon in kubernetes-csi/node-driver-registrar#316. The workaround is to not use readOnlyRootFilesystem for now but once there's a new node-driver-registrar release with the above fix then you'd be able to use readOnlyRootFilesystem: true.

Thanks for pointing the known issue @mauriciopoppe

@TobiasRD
Copy link

Thanks @mauriciopoppe and @mskanth972.
Yeah that would be a workaround. But does the error actually affect any functionality?

Glad to hear, that you're about to fix it!

@mauriciopoppe
Copy link
Member

@TobiasRD it doesn't affect the functionality, if you see the error consider it a false negative error :(.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants