Skip to content

How to automatically create initial user Kubernetes #6417

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

Closed
mh013370 opened this issue Mar 2, 2023 · 7 comments
Closed

How to automatically create initial user Kubernetes #6417

mh013370 opened this issue Mar 2, 2023 · 7 comments

Comments

@mh013370
Copy link
Contributor

mh013370 commented Mar 2, 2023

Question!

When installing Coder in Kubernetes via the Helm chart, what is the preferred way to bootstrap the deployment with an initial user?

I see the initial user API call, but i'm wondering if there's an undocumented standard way of doing this (check for initial user, if not there then create it). I'm trying to avoid manually creating an initial user each time i deploy Coder from scratch.

I don't see a way this can be specified via environment variables via the coder server command.

@dcarrion87
Copy link
Contributor

dcarrion87 commented Mar 2, 2023

We do this via the first user flags: 0f3221f

@mh013370
Copy link
Contributor Author

mh013370 commented Mar 3, 2023

We do this via the first user flags: 0f3221f

When & how do you run the coder login command through the Helm chart? I don't see any container lifecycle hooks exposed and i don't believe it's possible via an initContainer. Or are you deploying an external resource to do this after Coder has been deployed?

@dcarrion87
Copy link
Contributor

dcarrion87 commented Mar 3, 2023

@mh013370 ah yes sorry we don't use Coder's Helm chart. We've got too many "special" requirements and prefer to have full control over this. One of them being PostStart lifecycle hook that manages the first user creation.

@mh013370
Copy link
Contributor Author

mh013370 commented Mar 3, 2023

This makes sense. Perhaps i'll raise a PR to add lifecycle config to the helm chart, since we don't want to maintain our own. I think this is the only way to do it without adding an external resource.

Did you have any issues using postStart anyone should be aware of given the following condition?

There is no guarantee, however, that the postStart handler is called before the Container's entrypoint is called.

source: https://kubernetes.io/docs/tasks/configure-pod-container/attach-handler-lifecycle-event/

@dcarrion87
Copy link
Contributor

dcarrion87 commented Mar 3, 2023

It's be a while where we've had to rely on this to set up a new coder server instance but I don't recall any. The initial headaches was figuring out which environment variables did it and then the project changing to first-login- later. For all I know it may fall over for the next coder server we set up 😄. Things are changing pretty fast with this project.

@matifali
Copy link
Member

matifali commented May 5, 2023

@mh013370 Should we mark this as completed?

@mh013370
Copy link
Contributor Author

mh013370 commented May 19, 2023

Yes i'll close this. Pod lifecycle hooks are sufficient to satisfy the original need. Thanks!

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

No branches or pull requests

3 participants