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

Issue-468: Run pravega segmentstore sts with runAsUser = 0 #469

Merged
merged 9 commits into from
Oct 21, 2020

Conversation

Prabhaker24
Copy link
Contributor

@Prabhaker24 Prabhaker24 commented Oct 20, 2020

Signed-off-by: prabhaker24 [email protected]

Change log description

Pravega with ECS as LTS is failing to deploy in Openshift environment, as container needs to inject cert bundle into trust store, but the security context selected by openshift is preventing it.
To solve the above problem we have to set runAsUser = 0 for pravega segmentstore sts.

Purpose of the change

Fixes #468

What the code does

These changes allow the segmentstore pod's to run as root user. For enabling this user has to give the following things in the manifest file while deploying it manually

 pravega:
   segmenStoreSecurityContext: 
    runAsUser: 0  

If he is using charts he needs to uncomment the line in the values.yaml in the pravega charts:-

segmentStoreSecurityContext: 
  runAsUser: 0

For controller he needs to set like this:-

controllerSecurityContext:
   runAsUser: 0

How to verify it

Deploy the pravega cluster with runAsUser: 0 and check the segment store sts and controller deployment post-deployment it should have the following in it's described output

      securityContext:
        runAsUser: 0

Signed-off-by: prabhaker24 <[email protected]>
Signed-off-by: prabhaker24 <[email protected]>
@@ -167,6 +168,9 @@ type PravegaSpec struct {

// SegmentStoreExternalTrafficPolicy defines the ExternalTrafficPolicy it can have cluster or local
SegmentStoreExternalTrafficPolicy string `json:"segmentStoreExternalTrafficPolicy,omitempty"`

// SecurityContext holds security configuration that will be applied to a container
SecurityContext *corev1.PodSecurityContext `json:"securityContext,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

The PodSecurityContext is getting applied to the segment store only in this PR. And indeed the controller pods don't necessarily need the same PSC. (in particular, SegmentStores pod have more requirements in terms of requiring access to NFS for example, versus controllers which require less).

While the changes look correct, perhaps calling out that this is only getting applied to the SS, (renaming it accordingly?) , or also adding a separate one for the controller pods as well, might help avoid confusion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have changed the name and added securitycontext for controller as well.

@@ -392,6 +392,128 @@ spec:
to the Pravega processes as JAVA_OPTS. See the following file
for a complete list of options: https://github.com/pravega/pravega/blob/master/config/config.properties'
type: object
securityContext:
Copy link

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, it's from this only.

prabhaker24 added 4 commits October 21, 2020 13:14
Signed-off-by: prabhaker24 <[email protected]>
Signed-off-by: prabhaker24 <[email protected]>
Signed-off-by: prabhaker24 <[email protected]>
@@ -99,3 +99,5 @@ The following table lists the configurable parameters of the pravega chart and t
| `storage.cache.className` | Storage class for cache volume | `` |
| `storage.cache.size` | Storage requests for cache volume | `20Gi` |
| `options` | List of Pravega options | |
| `segmentStoreSecurityContext.runAsUser` | The UID to run the entrypoint of the container process | `0` |
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we mention that by default we are not setting any value for security context.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Signed-off-by: prabhaker24 <[email protected]>
@codecov-io
Copy link

codecov-io commented Oct 21, 2020

Codecov Report

Merging #469 into master will decrease coverage by 2.71%.
The diff coverage is 20.24%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #469      +/-   ##
==========================================
- Coverage   75.29%   72.58%   -2.72%     
==========================================
  Files          15       15              
  Lines        3068     3297     +229     
==========================================
+ Hits         2310     2393      +83     
- Misses        669      805     +136     
- Partials       89       99      +10     
Impacted Files Coverage Δ
pkg/apis/pravega/v1beta1/pravega.go 97.36% <ø> (ø)
pkg/apis/pravega/v1beta1/pravegacluster_types.go 26.20% <5.71%> (+3.46%) ⬆️
...roller/pravegacluster/pravegacluster_controller.go 50.45% <22.95%> (-10.46%) ⬇️
pkg/controller/pravega/pravega_controller.go 99.00% <50.00%> (-1.00%) ⬇️
pkg/controller/pravega/pravega_segmentstore.go 99.42% <50.00%> (-0.58%) ⬇️
pkg/apis/pravega/v1beta1/zz_generated.deepcopy.go 97.08% <100.00%> (+0.10%) ⬆️
pkg/util/pravegacluster.go 97.03% <100.00%> (+0.09%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1c5f0ce...b3100d5. Read the comment docs.

Copy link
Contributor

@anishakj anishakj left a comment

Choose a reason for hiding this comment

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

LGTM

@anishakj anishakj merged commit 95c21d3 into master Oct 21, 2020
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.

Run pravega segmentstore sts with runAsUser: 0
5 participants