Fix stanley_rsa permissions via postStart pod lifecycle hook by cognifloyd · Pull Request #219 · StackStorm/stackstorm-k8s

Skip to content

Navigation Menu

Sign in

Appearance settings

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

Conversation

@cognifloyd

Copy link Copy Markdown

Member

@cognifloyd cognifloyd commented

Jul 8, 2021

edited

Loading

I extracted this change from #206.

Use the postStart lifecycle event in st2actionrunner and st2client pods to correct file permissions on the stanley ssh private key.
Includes a test to ensure the key permissions are correct.

see:
https://kubernetes.io/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/
https://kubernetes.io/docs/concepts/containers/container-lifecycle-hooks/

  • Fix stanley_rsa file permissions with postStart lifecycle hook script for st2actionrunner and st2client
  • bash needs to run the script directly not with -c
  • make the ssh key writable so we can change permissions at runtime
  • mount ssh-key to separate directory, cp, and fix permissions
  • add test for stanley_rsa file ownership
  • use st2 as test intermediary
  • add changelog entry

Fixes #84

@pull-request-size pull-request-size bot added the size/M

PR that changes 30-99 lines. Good size to review.

label

Jul 8, 2021

@cognifloyd cognifloyd force-pushed the stanley_rsa-permissions branch from 7ddca4a to 0a87e8a Compare

July 8, 2021 01:10

@cognifloyd cognifloyd added enhancement

New feature or request

RFR security labels

Jul 8, 2021
assert_line --partial 'succeeded: true'
}

@test 'stanley_rsa file has correct permissions and ownership' {
Copy link Copy Markdown

Member

Choose a reason for hiding this comment

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

👍 Thanks for the tests!

cognifloyd reacted with thumbs up emoji
Copy link Copy Markdown

Member

@arm4b arm4b left a comment

Choose a reason for hiding this comment

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

That's an elegant solution, thanks for contributing this fix 👍

cognifloyd reacted with thumbs up emoji

@arm4b arm4b merged commit b2d31f3 into StackStorm:master

Jul 10, 2021

@cognifloyd cognifloyd removed the RFR label

Jul 10, 2021

@cognifloyd cognifloyd deleted the stanley_rsa-permissions branch

November 11, 2021 18:55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

1 more reviewer

@arm4b arm4b arm4b approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

enhancement

New feature or request

security size/M

PR that changes 30-99 lines. Good size to review.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

stanley_rsa is owned by root:root instead of stanley user in k8s

2 participants

@cognifloyd @arm4b