Skip to content

Service export should handle securityContext field #1788

Open

Description

@dsimansk

Feature request

With more Pod Security Standards enabled clusters we need to address the securityContext being present in PodSpec and Containers definitions. Since the two cluster with different PSS config might not be compatible for the same export.

I'd suggest that we remove it in default behavior and add a flag to include it optionally

UI Example


kn service export <ksvc> --with-securityContext
or
kn service export <ksvc> --with-sc

/kind good-first-issue
/kind proposal

/cc @rhuss @mvinkler

Activity

  1. added this to the Knative 1.10 milestone on Mar 23, 2023
  2. moved this to Ready To Work in Client Planningon Mar 23, 2023
  3. moved this from Ready To Work to Backlog in Client Planningon Mar 23, 2023
  4. moved this from Backlog to Ready To Work in Client Planningon Mar 23, 2023
  5. taniaduggal commented on May 8, 2023

    @taniaduggal

    I want to work on this issue, can you please tell from where i can start?

  6. rhuss commented on May 12, 2023

    @rhuss
    Contributor

    @taniaduggal, that is great! Before we start, I would like to discuss this update's background briefly.

    I think this story is part of a larger story, where we allow user to filter out certain information when doing an export so that it can be later used in a GitOps scenario.

    Besides the securityContext, I can also see fields we should not export by default, e.g. the namespace.

    So I suggest that we make a new option flexible so that we can fine granularly specify what to include (if excluded by default) and what to included (if included by default).

    My suggestion would be to have an option like

    kn service export myservice --include securityContext,namespace
    

    or

    kn service export myservice --include securityContext --include namespace
    

    @dsimansk what is your take on this ?

    (using multiple options here).

    @taniaduggal for starting its best to look at https://github.com/knative/client/blob/main/pkg/kn/commands/service/export.go which has all the logic for an export. This would be the place where we would evaluate that option and do the filtering.

    Thanks again @taniaduggal that you want to jump on the train, greatly appreciated!

  7. Rahul-Kumar-prog commented on Aug 16, 2023

    @Rahul-Kumar-prog

    @rhuss I read you idea and you want that users can filter certain info... that good idea.
    I have some questions:
    like: why we should not use

    kn service export <ksvc> --with-securityContext
    or
    kn service export <ksvc> --with-sc
    
  8. dsimansk commented on Aug 17, 2023

    @dsimansk
    ContributorAuthor

    @Rahul-Kumar-prog I'd go with @rhuss's suggestion, the --include flag might be more flexible in the term of adding new known variables, instread of adding the whole new flag, with near infinite growth (hopefully not).

    I'd go with this variant. And the valid values are predefined and listed in the help message.

    kn service export myservice --include securityContext,namespace
    
  9. rhuss commented on Aug 17, 2023

    @rhuss
    Contributor

    +1 for not use options inflationary but have an easy way to extend this feature without changing the "option API surface". In addition to provide the options as a comma separated list, multiple --include options should also work, like in --include securityContext --include namespace (it then also easy to add shortcuts like --include sc,ns without blowing up the options)

  10. Rahul-Kumar-prog commented on Aug 17, 2023

    @Rahul-Kumar-prog

    Ok, @rhuss @dsimansk
    I got your points and rhuss suggestion is perfect to go with.
    Is there anything else I need to know?

  11. Rahul-Kumar-prog commented on Aug 18, 2023

    @Rahul-Kumar-prog

    I want to work on this but i am already working on knative-kafka-broker repo issue so after finishing that i would love to work on this if its ok then please let me know.

  12. rhuss commented on Aug 21, 2023

    @rhuss
    Contributor

    Thanks! It's totally fine if you want to jump on this issue later, and we can then work on a PR as soon as you have something to share.

  13. dsimansk commented on Aug 21, 2023

    @dsimansk
    ContributorAuthor

    +1 @rhuss

    Assigning to you @Rahul-Kumar-prog to indicate it's being looked at some point. It's still ~2 months until next release v1.12. There's no time pressure right now. Feel free to proceed at your convenience.

    /assign @Rahul-Kumar-prog

  14. EraKin575 commented on Jun 17, 2024

    @EraKin575

    I would like to take this one

  15. Rahul-Kumar-prog commented on Jun 17, 2024

    @Rahul-Kumar-prog

    Feel free to start working or you can assign it to yourself.

  16. EraKin575 commented on Jun 21, 2024

    @EraKin575

    /assign

  17. removed their assignment
    on Oct 16, 2024
  18. thiagomedina commented on Aug 25, 2025

    @thiagomedina
    Member

    /assign

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

Metadata

Metadata

Labels

good first issueDenotes an issue ready for a new contributor.kind/featureNew feature or requesttriage/acceptedIssues which should be fixed (post-triage)

Type

No type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions