uffizzi
uffizzi copied to clipboard
Helm chart: Create admin user
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/orJob
that executes thecreate_user
rake task after all installation is complete (andpostgres
is running.) It should retry until it succeeds, and then be deleted. - This
Job
and/orPod
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
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
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
-
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 -
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 -
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 -
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 -
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) -
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
-
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
-
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 ./
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
- https://artifacthub.io/packages/helm/uffizzi-app/uffizzi-app#example-helm-values-file
- add "image: uffizzi/app:pr-121" param to the local values.yaml
- make small change to the install command
helm install my-uffizzi-app charts/uffizzi-app/ -f values.yaml --namespace uffizzi --create-namespace
-
kubectl get pods -n uffizzi
-
kubectl exec -it -n uffizzi-local my-uffizzi-app-web-6f64b9b97b-kl968 bash
-
rails c
- check there are user with the email from the "values.yaml"
user = UffizziCore::User.first
- check password
user.authenticate(your_password_from_values_yaml)
1. TESTED - OK

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

3. TESTED - OK

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
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
Waiting for setting up cluster.
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
Request to the session with the data from helm values is ok
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: