uffizzi icon indicating copy to clipboard operation
uffizzi copied to clipboard

Helm chart: Create admin user

Open axisofentropy opened this issue 2 years ago • 7 comments

Tell us about your request Currently, open-source Uffizzi users must run rake uffizzi_core:create_user to create the first user after installing Uffizzi using Helm. I believe Helm can do this for them.

Which service(s) is this request for? open-source Helm chart

Describe the solution you'd like

  • The Helm chart should recognize global values for the username, password, and project name.
  • IF the username and password are specified, the Helm chart should specify a Pod and/or Job that executes the create_user rake task after all installation is complete (and postgres is running.) It should retry until it succeeds, and then be deleted.
  • This Job and/or Pod should be created upon after every new release, using Helm hooks. https://helm.sh/docs/topics/charts_hooks/

Are you currently working around the issue? We will probably document how to execute this command using kubectl to make it easier until this is implemented.

Additional context This builds upon #30

axisofentropy avatar May 12 '22 21:05 axisofentropy

Yeah, helm has a post-install hook and we can use it. But we discussed it with Anton and decided to make it before the Ruby application loading. It must be simpler. That's why I'm working in this way

sergeykirillovdb avatar May 16 '22 14:05 sergeykirillovdb

For QA

First of all, I fixed the function for the admin user creating. It can be executed everytime when application starts Pull last 'qa' branch (open source version from github) to your local machine

Test cases

  1. User created successfully a) docker-compose run --rm web bash -c "rake uffizzi_core:create_user" b) press enter on "Enter User Email" if you don't have user with the default email or enter another email (I use default [email protected]) c) enter any non-empty password d) press enter on "Enter Project Name" e) check console is ready for new commands f) check user created

  2. User not created through the console if it has already exists Steps to check a) docker-compose run --rm web bash -c "rake uffizzi_core:create_user" b) enter email of the existing user ([email protected]) c) check the error about email duplicate d) check console is ready for new commands

  3. User not created through the console if there are no password Steps to check a) docker-compose run --rm web bash -c "rake uffizzi_core:create_user" b) enter any new email (not [email protected]) c) press enter on "Enter Password" d) check the error about blank password e) check console is ready for new commands

  4. User not created through the console with env param if it has already exists Steps to check a) docker-compose run --rm -e [email protected] -e UFFIZZI_USER_PASSWORD=password -e UFFIZZI_PROJECT_NAME=project web bash -c "rake uffizzi_core:create_user" b) check there are no errors c) check console is ready for new commands

  5. Application up well if there are problems with default user data a) Edit command for the web service in the "docker-compose.yml" file (near to the 35 string now) command: bash -c "bundle install && bundle exec rails db:create db:migrate && bundle exec rake uffizzi_core:create_user && bundle exec puma -C config/puma.rb" b) docker-compose up c) check application is working (web_1 | * Listening on tcp://0.0.0.0:7000 in the console logs is ok)

  6. User created successfully if it's the first compose launch a) Like in the 5. case, edit command for the web service in the "docker-compose.yml" file (near to the 35 string now) command: bash -c "bundle install && bundle exec rails db:create db:migrate && bundle exec rake uffizzi_core:create_user && bundle exec puma -C config/puma.rb" b) Add several variables to the "x-web-environment" section

UFFIZZI_USER_EMAIL: [email protected]
UFFIZZI_USER_PASSWORD: password
UFFIZZI_PROJECT_NAME: default

c) docker-compose up d) check application is working e) check that user with email "[email protected]" exists

  1. User not created if there are problems with email a) Like in the 5. case, edit command for the web service in the "docker-compose.yml" file (near to the 35 string now) command: bash -c "bundle install && bundle exec rails db:create db:migrate && bundle exec rake uffizzi_core:create_user && bundle exec puma -C config/puma.rb" b) Add several variables to the "x-web-environment" section
UFFIZZI_USER_EMAIL: [email protected]"
UFFIZZI_USER_PASSWORD: password
UFFIZZI_PROJECT_NAME: default

c) docker-compose up d) check application is working e) check that user with email "[email protected]" doesn't exist

  1. User not created if there are empty password a) Like in the 5. case, edit command for the web service in the "docker-compose.yml" file (near to the 35 string now) command: bash -c "bundle install && bundle exec rails db:create db:migrate && bundle exec rake uffizzi_core:create_user && bundle exec puma -C config/puma.rb" b) Add several variables to the "x-web-environment" section
UFFIZZI_USER_EMAIL: [email protected]
UFFIZZI_USER_PASSWORD: ""
UFFIZZI_PROJECT_NAME: default

c) docker-compose up d) check application is working e) check that user with email "[email protected]" doesn't exist

Remove all changes from the code after the QA

git restore ./

sergeykirillovdb avatar May 18 '22 16:05 sergeykirillovdb

Second one about helm installation I'm not sure about free GKE, AKS and EKS, so you can try to use local minikube. It looks like you can check the installation with it

  1. https://artifacthub.io/packages/helm/uffizzi-app/uffizzi-app#example-helm-values-file
  2. add "image: uffizzi/app:pr-121" param to the local values.yaml
  3. make small change to the install command helm install my-uffizzi-app charts/uffizzi-app/ -f values.yaml --namespace uffizzi --create-namespace
  4. kubectl get pods -n uffizzi
  5. kubectl exec -it -n uffizzi-local my-uffizzi-app-web-6f64b9b97b-kl968 bash
  6. rails c
  7. check there are user with the email from the "values.yaml" user = UffizziCore::User.first
  8. check password user.authenticate(your_password_from_values_yaml)

sergeykirillovdb avatar May 19 '22 13:05 sergeykirillovdb

1. TESTED - OK

image
bash-5.1# bundle exec uffizzi login -u [email protected]
Login to Uffizzi to view and manage your previews.

2. TESTED - OK

image

3. TESTED - OK

image

4. TESTED - OK

5. TESTED - OK

web_1           | Validation failed: Password can't be blank, Email can't be blank, Email is invalid
web_1           | * Listening on tcp://0.0.0.0:7000

6. TESTED - OK image

web_1           | * Listening on tcp://0.0.0.0:7000
bash-5.1# bundle exec uffizzi login -u [email protected]
Login to Uffizzi to view and manage your previews.

7 TESTED - OK

web_1           | D, [2022-05-23T13:07:37.634529 #15] DEBUG -- :   TRANSACTION (0.4ms)  ROLLBACK
web_1           | Validation failed: Email is invalid

8 TESTED - OK

web_1           | Validation failed: Password can't be blank

NealArw avatar May 23 '22 13:05 NealArw

Waiting for setting up cluster.

NealArw avatar May 24 '22 09:05 NealArw

Made setup on the AWS "install-training-2022-05" URL for the https://helm-test.app.qa-gke.uffizzi.com/

Cases

  • [x] First install. The user is created. Application works
  • [x] Uninstall and install once again. The user already exists because uninstall doesn't remove the database. Application works

User and default project exists Снимок экрана 2022-06-02 в 14 09 51

Request to the session with the data from helm values is ok Снимок экрана 2022-06-02 в 14 07 33

sergeykirillovdb avatar Jun 02 '22 10:06 sergeykirillovdb

I've added another commit that changed the value names and bumped the Helm Chart version number. This all looks good; I approve.

I also successfully tested the common use case after this commit: image

axisofentropy avatar Jun 02 '22 16:06 axisofentropy