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

🐛 Fix running as non-root on vanilla kubernetes #762

Merged
merged 1 commit into from
Nov 14, 2024

Conversation

jmontleon
Copy link
Member

It looks like running as root is failing on minikube (and probably vanilla kubernetes) because there is no /etc/passwd entry to correspond to the UID. This is the source of the current test failures.

golang/go#38599

In a minikube environment the operator runs as UID 1001 and assigns this to the hub as well.

My thoughts on this were that we could:

  • Add a /etc/passwd for uid 1001 to cover the default vanilla kube/minikube scenario
  • Check in the operator if the operators uid is 1001 and if so set the hub_uid to 0 instead, which I guess mimics the current status quo.
  • Find a different way to get the UID in go... (no luck so far and I'd guess if there were an option it would have been mentioned on the issue linked above).

@jortel also mentioned we could:

  • Have the hub exec and run id -u instead of os.user.Current().
  • If the ansible module in the operator has access to the real uid, it can set the "TASK_UID" env var.

I am happy to rework this however we want.

Signed-off-by: Jason Montleon <jmontleo@redhat.com>
@jmontleon jmontleon requested review from jortel and dymurray November 14, 2024 21:17
Copy link
Contributor

@jortel jortel left a comment

Choose a reason for hiding this comment

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

LGTM
This seems reasonable and specifically addresses the problem use-case which is running the hub in a container on kubernetes.

@jmontleon jmontleon merged commit a4c11db into konveyor:main Nov 14, 2024
13 checks passed
dymurray pushed a commit to dymurray/tackle2-hub that referenced this pull request Nov 20, 2024
It looks like running as root is failing on minikube (and probably
vanilla kubernetes) because there is no /etc/passwd entry to correspond
to the UID. This is the source of the current test failures.

golang/go#38599

In a minikube environment the operator runs as UID 1001 and assigns this
to the hub as well.

My thoughts on this were that we could:
- Add a /etc/passwd for uid 1001 to cover the default vanilla
kube/minikube scenario
- Check in the operator if the operators uid is 1001 and if so set the
hub_uid to 0 instead, which I guess mimics the current status quo.
- Find a different way to get the UID in go... (no luck so far and I'd
guess if there were an option it would have been mentioned on the issue
linked above).

@jortel  also mentioned we could:
- Have the hub exec and run id -u instead of os.user.Current().
- If the ansible module in the operator has access to the real uid, it
can set the "TASK_UID" env var.

I am happy to rework this however we want.

Signed-off-by: Jason Montleon <jmontleo@redhat.com>
(cherry picked from commit a4c11db)
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.

2 participants