kubernetes-client / c

Official C client library for Kubernetes
Apache License 2.0
141 stars 45 forks source link

Pod specifying runAsUser: 0 not working #176

Closed caesar0301 closed 2 weeks ago

caesar0301 commented 1 year ago

Accoding to kubernetes bug fix https://github.com/kubernetes/kubernetes/issues/78308, pods that explicitly specifying runAsUser: <uid> or runAsGroup: <gid> should start the container always in every launch using given user or group. If runAsUser or runAsGroup is not set, the container should run with USER specified when building the image.

Now we get the sdk implementation that runAsUser: 0 is ignored when the user forces to launch the container with root, overwriting default image USER. The same to runAsGroup: 0.

https://github.com/kubernetes-client/c/blob/859fc3f5eecda59f4eea6b07431aa2ebf38db779/kubernetes/model/v1_security_context.c#L134

https://github.com/kubernetes-client/c/blob/859fc3f5eecda59f4eea6b07431aa2ebf38db779/kubernetes/model/v1_security_context.c#L118

I have a local fix to remain the semantics meaning to introduce the invalid user and group as -1: image

ityuhui commented 1 year ago

This issue is similar to https://github.com/kubernetes-client/c/issues/158. If we always pass "0" to API server, the default value in Kubernetes will be broken (that might introduce the issue https://github.com/kubernetes-client/c/issues/170)

It seems the best solution would be to replace int run_as_user with int *run_as_user, but this will bing great changes to openapi-generator/c template. https://github.com/kubernetes-client/c/pull/160#issuecomment-1332782208 The second solution is to introduce a magic number just like you did. https://github.com/kubernetes-client/c/pull/160#issuecomment-1331611270

I'm thinking of a better solution. What do you recommend?

k8s-triage-robot commented 1 year ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

ityuhui commented 1 year ago

/remove-lifecycle stale

k8s-triage-robot commented 5 months ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

ityuhui commented 5 months ago

/remove-lifecycle stale

k8s-triage-robot commented 2 months ago

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

k8s-triage-robot commented 1 month ago

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle rotten

k8s-triage-robot commented 2 weeks ago

The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs.

This bot triages issues according to the following rules:

You can:

Please send feedback to sig-contributor-experience at kubernetes/community.

/close not-planned

k8s-ci-robot commented 2 weeks ago

@k8s-triage-robot: Closing this issue, marking it as "Not Planned".

In response to [this](https://github.com/kubernetes-client/c/issues/176#issuecomment-2182207546): >The Kubernetes project currently lacks enough active contributors to adequately respond to all issues and PRs. > >This bot triages issues according to the following rules: >- After 90d of inactivity, `lifecycle/stale` is applied >- After 30d of inactivity since `lifecycle/stale` was applied, `lifecycle/rotten` is applied >- After 30d of inactivity since `lifecycle/rotten` was applied, the issue is closed > >You can: >- Reopen this issue with `/reopen` >- Mark this issue as fresh with `/remove-lifecycle rotten` >- Offer to help out with [Issue Triage][1] > >Please send feedback to sig-contributor-experience at [kubernetes/community](https://github.com/kubernetes/community). > >/close not-planned > >[1]: https://www.kubernetes.dev/docs/guide/issue-triage/ Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes-sigs/prow](https://github.com/kubernetes-sigs/prow/issues/new?title=Prow%20issue:) repository.