Closed scart88 closed 2 years ago
Hey @scart88, thanks for reaching out. I'm 99% sure the problem you're running into is related to your Kubernetes version. At the moment, Kuby only supports Kubernetes v1.19 or earlier. I can't tell from the output alone, but the error message suggests your cluster doesn't support the rbac.authorization.k8s.io/v1beta1
API, which was removed in k8s v1.22. I'm working on supporting later versions, but it's proving to be quite a bit of work.
There is hope however. Because you've set manage_database false
in your Kuby config, you can sidestep these problems by using kuby-core@master. In other words, put this in your Gemfile:
gem "kuby-core", github: "getkuby/kuby-core", ref: "9885015027e1ede7fd4f8e53fb7f10772f975845"
Thank you very much for your fast reply and help. I've updated the gem master version.
I'm unable to select version v.1.19, is not showing in the DigitalOcean dropdown anymore. I can only select v.1.20, v1.21 and v1.22.
Right now, my Kubernetes version is v1.22.7. However, with this gem version, I'm getting the following errors
> bundle exec kuby -e production build
error: undefined method `map' for nil:NilClass
> bundle exec kuby -e production push
error: undefined method `map' for nil:NilClass
Setup seems to work better than before
bundle exec kuby -e production setup
Refreshing kubeconfig...
Successfully refreshed kubeconfig!
Deploying nginx ingress resources
Error from server (NotFound): namespaces "ingress-nginx" not found
namespace/ingress-nginx created
serviceaccount/ingress-nginx created
configmap/ingress-nginx-controller created
clusterrole.rbac.authorization.k8s.io/ingress-nginx created
clusterrolebinding.rbac.authorization.k8s.io/ingress-nginx created
role.rbac.authorization.k8s.io/ingress-nginx created
rolebinding.rbac.authorization.k8s.io/ingress-nginx created
service/ingress-nginx-controller-admission created
service/ingress-nginx-controller created
deployment.apps/ingress-nginx-controller created
ingressclass.networking.k8s.io/nginx created
validatingwebhookconfiguration.admissionregistration.k8s.io/ingress-nginx-admission created
serviceaccount/ingress-nginx-admission created
clusterrole.rbac.authorization.k8s.io/ingress-nginx-admission created
clusterrolebinding.rbac.authorization.k8s.io/ingress-nginx-admission created
role.rbac.authorization.k8s.io/ingress-nginx-admission created
rolebinding.rbac.authorization.k8s.io/ingress-nginx-admission created
job.batch/ingress-nginx-admission-create created
job.batch/ingress-nginx-admission-patch created
Nginx ingress resources deployed!
Installing cert-manager...
namespace/cert-manager created
serviceaccount/cert-manager-cainjector created
serviceaccount/cert-manager created
serviceaccount/cert-manager-webhook created
clusterrole.rbac.authorization.k8s.io/cert-manager-webhook:webhook-requester created
clusterrole.rbac.authorization.k8s.io/cert-manager-view created
clusterrole.rbac.authorization.k8s.io/cert-manager-edit created
service/cert-manager created
service/cert-manager-webhook created
deployment.apps/cert-manager-cainjector created
deployment.apps/cert-manager created
deployment.apps/cert-manager-webhook created
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1beta1"
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1beta1"
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1beta1"
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1beta1"
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1beta1"
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1beta1"
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRole" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "Role" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "RoleBinding" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "RoleBinding" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "Role" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "RoleBinding" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRole" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRole" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRole" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRole" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRole" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRole" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "MutatingWebhookConfiguration" in version "admissionregistration.k8s.io/v1beta1"
unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ValidatingWebhookConfiguration" in version "admissionregistration.k8s.io/v1beta1"
Could not apply https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml: kubectl exited with status code 1
error: Could not apply https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml: kubectl exited with status code 1
I will try with v.1.20. Let's see if it works.
Thank you very much for your fast reply and help. I've updated the gem master version.
I'm unable to select version v.1.19, is not showing in the DigitalOcean dropdown anymore. I can only select v.1.20, v1.21 and v1.22.
Right now, my Kubernetes version is v1.22.7. However, with this gem version, I'm getting the following errors
> bundle exec kuby -e production build error: undefined method `map' for nil:NilClass > bundle exec kuby -e production push error: undefined method `map' for nil:NilClass
Setup seems to work better than before
bundle exec kuby -e production setup Refreshing kubeconfig... Successfully refreshed kubeconfig! Deploying nginx ingress resources Error from server (NotFound): namespaces "ingress-nginx" not found namespace/ingress-nginx created serviceaccount/ingress-nginx created configmap/ingress-nginx-controller created clusterrole.rbac.authorization.k8s.io/ingress-nginx created clusterrolebinding.rbac.authorization.k8s.io/ingress-nginx created role.rbac.authorization.k8s.io/ingress-nginx created rolebinding.rbac.authorization.k8s.io/ingress-nginx created service/ingress-nginx-controller-admission created service/ingress-nginx-controller created deployment.apps/ingress-nginx-controller created ingressclass.networking.k8s.io/nginx created validatingwebhookconfiguration.admissionregistration.k8s.io/ingress-nginx-admission created serviceaccount/ingress-nginx-admission created clusterrole.rbac.authorization.k8s.io/ingress-nginx-admission created clusterrolebinding.rbac.authorization.k8s.io/ingress-nginx-admission created role.rbac.authorization.k8s.io/ingress-nginx-admission created rolebinding.rbac.authorization.k8s.io/ingress-nginx-admission created job.batch/ingress-nginx-admission-create created job.batch/ingress-nginx-admission-patch created Nginx ingress resources deployed! Installing cert-manager... namespace/cert-manager created serviceaccount/cert-manager-cainjector created serviceaccount/cert-manager created serviceaccount/cert-manager-webhook created clusterrole.rbac.authorization.k8s.io/cert-manager-webhook:webhook-requester created clusterrole.rbac.authorization.k8s.io/cert-manager-view created clusterrole.rbac.authorization.k8s.io/cert-manager-edit created service/cert-manager created service/cert-manager-webhook created deployment.apps/cert-manager-cainjector created deployment.apps/cert-manager created deployment.apps/cert-manager-webhook created unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1beta1" unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1beta1" unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1beta1" unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1beta1" unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1beta1" unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "CustomResourceDefinition" in version "apiextensions.k8s.io/v1beta1" unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRole" in version "rbac.authorization.k8s.io/v1beta1" unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1beta1" unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "Role" in version "rbac.authorization.k8s.io/v1beta1" unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "RoleBinding" in version "rbac.authorization.k8s.io/v1beta1" unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1beta1" unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "RoleBinding" in version "rbac.authorization.k8s.io/v1beta1" unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "Role" in version "rbac.authorization.k8s.io/v1beta1" unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "RoleBinding" in version "rbac.authorization.k8s.io/v1beta1" unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRole" in version "rbac.authorization.k8s.io/v1beta1" unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRole" in version "rbac.authorization.k8s.io/v1beta1" unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRole" in version "rbac.authorization.k8s.io/v1beta1" unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRole" in version "rbac.authorization.k8s.io/v1beta1" unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRole" in version "rbac.authorization.k8s.io/v1beta1" unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRole" in version "rbac.authorization.k8s.io/v1beta1" unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1beta1" unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1beta1" unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1beta1" unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1beta1" unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1beta1" unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1beta1" unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "MutatingWebhookConfiguration" in version "admissionregistration.k8s.io/v1beta1" unable to recognize "https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml": no matches for kind "ValidatingWebhookConfiguration" in version "admissionregistration.k8s.io/v1beta1" Could not apply https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml: kubectl exited with status code 1 error: Could not apply https://github.com/jetstack/cert-manager/releases/download/v0.13.1/cert-manager.yaml: kubectl exited with status code 1
I will try with v.1.20. Let's see if it works.
Did you manage to make it work? Exactly same problem here. Stuck on cert-manager now.
I've downgraded Kubernetes cluster to version 1.20 and it helps.
Thanks. Setup bundle exec kuby -e production setup
command works on v1.20.
However, the deploy command is getting stuck at -create-db
on my end.
Thanks. Setup
bundle exec kuby -e production setup
command works on v1.20. However, the deploy command is getting stuck at-create-db
on my end.
Exactly same problem, fighting it right now. Let me know if you solve it, please.
Not yet, but I found this relevant issue #74. I'm kind of stuck, so I took a pause on trying k8s. Please let me know if you find a way to make it work.
Hey @denikus and @scart88, sorry for all the trouble. Getting all of these things to work together is quite a challenge.
Yes, it looks like v1.20 should work with kuby-core master as well 😄
@scart88 it sounds like Rails isn't able to connect to the database specified in your database.yml. Even though manage_database false
may be set in your Kuby config, Kuby will still try to create and/or migrate your database automatically. Try running the following command to get a list of running pods:
bundle exec kuby -e production remote status
There should be one pod in the Init:CrashLoopBackOff
state. Copy the name of the pod and run the following command to print out the logs from the create-db init container:
bundle exec kuby -e production kubectl -N -- logs -c app-create-db <pod name here>
(This should be a lot easier, I'll file an issue)
Unfortunately it didn't worked.
NAME READY STATUS RESTARTS AGE
cm-acme-http-solver-stpkj 1/1 Running 0 50s
hotwiresample-assets-77cbcb497c-kq6pg 1/1 Running 0 4m1s
hotwiresample-web-74df7f7d9b-ngkgh 0/1 Init:CrashLoopBackOff 3 4m1s
❯ bundle exec kuby -e production kubectl -N -- logs -c app-create-db hotwiresample-web-74df7f7d9b-ngkgh
rake aborted!
ActiveRecord::ConnectionNotEstablished: could not connect to server: Connection timed out
Is the server running on host "app-psql-do-user-------0.b.db.ondigitalocean.com" (0.0.0.0) and accepting
TCP/IP connections on port 25060?
/usr/local/bundle/gems/activerecord-6.1.5/lib/active_record/connection_adapters/postgresql_adapter.rb:83:in `rescue in new_client'
/usr/local/bundle/gems/activerecord-6.1.5/lib/active_record/connection_adapters/postgresql_adapter.rb:77:in `new_client'
/usr/local/bundle/gems/activerecord-6.1.5/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `postgresql_connection'
/usr/local/bundle/gems/activerecord-6.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `public_send'
/usr/local/bundle/gems/activerecord-6.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `new_connection'
/usr/local/bundle/gems/activerecord-6.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:926:in `checkout_new_connection'
/usr/local/bundle/gems/activerecord-6.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:905:in `try_to_checkout_new_connection'
/usr/local/bundle/gems/activerecord-6.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:866:in `acquire_connection'
/usr/local/bundle/gems/activerecord-6.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:588:in `checkout'
/usr/local/bundle/gems/activerecord-6.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:428:in `connection'
/usr/local/bundle/gems/activerecord-6.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:1128:in `retrieve_connection'
/usr/local/bundle/gems/activerecord-6.1.5/lib/active_record/connection_handling.rb:327:in `retrieve_connection'
/usr/local/bundle/gems/activerecord-6.1.5/lib/active_record/connection_handling.rb:283:in `connection'
/usr/local/bundle/bundler/gems/kuby-core-9885015027e1/lib/kuby/plugins/rails_app/tasks.rake:23:in `block (4 levels) in <main>'
/usr/local/bundle/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/usr/local/bundle/gems/bundler-2.3.9/lib/bundler/cli/exec.rb:58:in `load'
/usr/local/bundle/gems/bundler-2.3.9/lib/bundler/cli/exec.rb:58:in `kernel_load'
/usr/local/bundle/gems/bundler-2.3.9/lib/bundler/cli/exec.rb:23:in `run'
/usr/local/bundle/gems/bundler-2.3.9/lib/bundler/cli.rb:483:in `exec'
/usr/local/bundle/gems/bundler-2.3.9/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/bundle/gems/bundler-2.3.9/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/bundle/gems/bundler-2.3.9/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/usr/local/bundle/gems/bundler-2.3.9/lib/bundler/cli.rb:31:in `dispatch'
/usr/local/bundle/gems/bundler-2.3.9/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/usr/local/bundle/gems/bundler-2.3.9/lib/bundler/cli.rb:25:in `start'
/usr/local/bundle/gems/bundler-2.3.9/exe/bundle:48:in `block in <top (required)>'
/usr/local/bundle/gems/bundler-2.3.9/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
/usr/local/bundle/gems/bundler-2.3.9/exe/bundle:36:in `<top (required)>'
/usr/src/app/bin/bundle:113:in `load'
/usr/src/app/bin/bundle:113:in `<main>'
Caused by:
PG::ConnectionBad: could not connect to server: Connection timed out
Is the server running on host "app-psql-do-user-------0.b.db.ondigitalocean.com" (0.0.0.0) and accepting
TCP/IP connections on port 25060?
/usr/local/bundle/gems/pg-1.2.3/lib/pg.rb:58:in `initialize'
/usr/local/bundle/gems/pg-1.2.3/lib/pg.rb:58:in `new'
/usr/local/bundle/gems/pg-1.2.3/lib/pg.rb:58:in `connect'
/usr/local/bundle/gems/activerecord-6.1.5/lib/active_record/connection_adapters/postgresql_adapter.rb:78:in `new_client'
/usr/local/bundle/gems/activerecord-6.1.5/lib/active_record/connection_adapters/postgresql_adapter.rb:37:in `postgresql_connection'
/usr/local/bundle/gems/activerecord-6.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `public_send'
/usr/local/bundle/gems/activerecord-6.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:882:in `new_connection'
/usr/local/bundle/gems/activerecord-6.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:926:in `checkout_new_connection'
/usr/local/bundle/gems/activerecord-6.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:905:in `try_to_checkout_new_connection'
/usr/local/bundle/gems/activerecord-6.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:866:in `acquire_connection'
/usr/local/bundle/gems/activerecord-6.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:588:in `checkout'
/usr/local/bundle/gems/activerecord-6.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:428:in `connection'
/usr/local/bundle/gems/activerecord-6.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:1128:in `retrieve_connection'
/usr/local/bundle/gems/activerecord-6.1.5/lib/active_record/connection_handling.rb:327:in `retrieve_connection'
/usr/local/bundle/gems/activerecord-6.1.5/lib/active_record/connection_handling.rb:283:in `connection'
/usr/local/bundle/bundler/gems/kuby-core-9885015027e1/lib/kuby/plugins/rails_app/tasks.rake:23:in `block (4 levels) in <main>'
/usr/local/bundle/gems/rake-13.0.6/exe/rake:27:in `<top (required)>'
/usr/local/bundle/gems/bundler-2.3.9/lib/bundler/cli/exec.rb:58:in `load'
/usr/local/bundle/gems/bundler-2.3.9/lib/bundler/cli/exec.rb:58:in `kernel_load'
/usr/local/bundle/gems/bundler-2.3.9/lib/bundler/cli/exec.rb:23:in `run'
/usr/local/bundle/gems/bundler-2.3.9/lib/bundler/cli.rb:483:in `exec'
/usr/local/bundle/gems/bundler-2.3.9/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/local/bundle/gems/bundler-2.3.9/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
/usr/local/bundle/gems/bundler-2.3.9/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
/usr/local/bundle/gems/bundler-2.3.9/lib/bundler/cli.rb:31:in `dispatch'
/usr/local/bundle/gems/bundler-2.3.9/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
/usr/local/bundle/gems/bundler-2.3.9/lib/bundler/cli.rb:25:in `start'
/usr/local/bundle/gems/bundler-2.3.9/exe/bundle:48:in `block in <top (required)>'
/usr/local/bundle/gems/bundler-2.3.9/lib/bundler/friendly_errors.rb:103:in `with_friendly_errors'
/usr/local/bundle/gems/bundler-2.3.9/exe/bundle:36:in `<top (required)>'
/usr/src/app/bin/bundle:113:in `load'
/usr/src/app/bin/bundle:113:in `<main>'
Tasks: TOP => kuby:rails_app:db:create_unless_exists
(See full trace by running task with --trace)
I added the cluster to verified sources to the DO managed database as well and it worked.
❯ bundle exec kuby -e production remote status
NAME READY STATUS RESTARTS AGE
cm-acme-http-solver-stpkj 1/1 Running 0 16m
hotwiresample-assets-77cbcb497c-kq6pg 1/1 Running 0 20m
hotwiresample-web-74df7f7d9b-ngkgh 1/1 Running 0 20m
I pointed the Load Balancer to the A records on subdomain and the only issue now is the SSL certificate.
Your connection is not private
It took some time, and finally the SSL certificate did his thing and now it works.
Considering it took so much time to figure out how to make this to work. I'm a little afraid to go in production with this. I don't want to abuse the issues and your time every time I get an error.
Do you have any recommendations on what would be my next steps in learning more? Do I have to worry about rollbacks, log rotation, backups (I already have backups on the DO managed db), cron jobs ?
Hey @scart88, glad you were able to get things working!
It took some time, and finally the SSL certificate did his thing and now it works.
Yeah, sometimes certs are slow to issue because of DNS propagation lag. Unfortunately I don't know of any workarounds for that, but 1) usually it's just a matter of waiting for a bit, and 2) you should only have to worry about it once.
Considering it took so much time to figure out how to make this to work. I'm a little afraid to go in production with this. I don't want to abuse the issues and your time every time I get an error.
Yes, I totally understand. Kuby is pre-1.0 software, and I'm still actively working out the kinks. I really appreciate you taking the time to give it a try and report your experience back to me. It's super helpful to see where folks are getting tripped up.
Do you have any recommendations on what would be my next steps in learning more?
That's a good question. What specifically are you interested in learning more about? Kuby uses Docker and Kubernetes under the hood. I'd be happy to point you at some resources for either or both of those things. A good place to start for now might be to run kuby dockerfiles
and kuby resources
. Those will print out the Dockerfiles and Kubernetes resource manifests Kuby will use to build and deploy your app. They might not make sense right away, but it's good to know what parts of Docker and k8s Kuby is using so you can narrow your focus.
Do I have to worry about rollbacks, log rotation, backups (I already have backups on the DO managed db), cron jobs?
Rollbacks are baked into Kuby. You should be able to run kuby rollback
to deploy the previous release.
In Kubernetes, logs are automatically sent to STDOUT. I believe k8s will keep a certain number of lines around if you want to see log output later, but other than that logs are simply discarded. So no log rotation is necessary as far as I know. If you're interested in looking at old logs, I would recommend a log aggregation service like SumoLogic, etc.
You don't have to worry about backups unless you're writing to the local disk for some reason. If you are, I believe DigitalOcean has a backup feature you could look into.
I'm not sure what you mean about cron jobs? Kubernetes has a cron feature that Kuby doesn't expose.
Yeah, sometimes certs are slow to issue because of DNS propagation lag. Unfortunately I don't know of any workarounds for that, but 1) usually it's just a matter of waiting for a bit, and 2) you should only have to worry about it once.
I don't much about the Kubernetes ingress, but I found it so easy to run the caddy docker file and do a reverse proxy like in the example below. However, I guess is much more complicated in Kubernetes.
docker run -d --name p-caddy --restart always --network host -v /home/Caddyfile:/etc/caddy/Caddyfile -v /home/caddy-data:/data caddy
Caddyfile
example-domain.com {
reverse_proxy 0.0.0.0:3000
}
Yes, I totally understand. Kuby is pre-1.0 software, and I'm still actively working out the kinks. I really appreciate you taking the time to give it a try and report your experience back to me. It's super helpful to see where folks are getting tripped up.
I will try to help if I can, however my Rails / Ruby experience is pretty basic. I'm really glad you built this and I have the chance to play with it.
That's a good question. What specifically are you interested in learning more about? Kuby uses Docker and Kubernetes under the hood. I'd be happy to point you at some resources for either or both of those things. A good place to start for now might be to run kuby dockerfiles and kuby resources. Those will print out the Dockerfiles and Kubernetes resource manifests Kuby will use to build and deploy your app. They might not make sense right away, but it's good to know what parts of Docker and k8s Kuby is using so you can narrow your focus.
Thanks. I got a basic docker course from Nick Janetakis, however didn't had much time to go through everything.
Rollbacks are baked into Kuby. You should be able to run kuby rollback to deploy the previous release.
That handy. I notice on every kuby build, the registry on Gitlab is growing bigger. Should I remove old images?
I'm not sure what you mean about cron jobs? Kubernetes has a cron feature that Kuby doesn't expose.
I will have to play with the whenever gem
and see if it works.
@camertron maybe you can help. Seems like Puma just crashing for some db reason. No details even in pods' logs.
[25] Early termination of worker [23] ! Unable to start worker [23] /usr/local/bundle/gems/activerecord-7.0.2.2/lib/active_record/enum.rb:301:in
raise_conflict_error'
[23] Early termination of worker
`
What could it possibly be?
Database in separate db cluster and connection open.
Solved. Problem was in DATABASE_URL and how I send it to database.yml.
Yeah, sometimes certs are slow to issue because of DNS propagation lag. Unfortunately I don't know of any workarounds for that, but 1) usually it's just a matter of waiting for a bit, and 2) you should only have to worry about it once.
I found that it works faster with kind: Issuer
(about 1 or 2 minutes), however it must live in the same namespace with the App / Service / Deployment / Pod
This is on DO with a Load Balancer and ingress-nginx helm
---
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: letsencrypt-nginx
namespace: app-production-namespace <--- the issuer is is the same namespace
spec:
# ACME issuer configuration
# `email` - the email address to be associated with the ACME account (make sure it's a valid one)
# `server` - the URL used to access the ACME server’s directory endpoint
# `privateKeySecretRef` - Kubernetes Secret to store the automatically generated ACME account private key
acme:
email: email...
server: https://acme-v02.api.letsencrypt.org/directory
privateKeySecretRef:
name: letsencrypt-nginx-private-key
solvers:
# Use the HTTP-01 challenge provider
- http01:
ingress:
class: nginx
apiVersion: v1
kind: Service
metadata:
name: app-production-service
namespace: app-production-namespace
spec:
selector:
app: app-production
ports:
- protocol: TCP
port: 80
targetPort: 8080 <--- the ingress is targeting this port
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: app-production-ingress
namespace: app-production-namespace
annotations:
cert-manager.io/issuer: letsencrypt-nginx
spec:
ingressClassName: nginx
tls:
- hosts:
- example.com
secretName: letsencrypt-nginx
rules:
- host: example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: app-production-service
port:
number: 8080
I have the same problem on Linode. Error when running bundle exec kuby -e production setup. I get the "services ingress-nginx not found"-error. I don't seem to be able to downgrade Kubernetes to a lower version than 1.22 on Linode. As I understand it, there's no workaround for this scenario?
Hey @JorgenIvarsson, thanks for your comment. I'm getting ready to publish a big Kuby release ahead of my talk at RailsConf that should address this issue (and a bunch of others). If you can wait a week or so, the upcoming release should unblock you.
Greate news @camertron! As a new Rails user I am struggling with how deploy my first app. Learning Rails, and at the same time having to learn Docker and Kubernetes is just too much. Just the amount of configuration files blows my mind! My last hope to deploy my app is getting Kuby to work. I will be waiting for the update :-)
@JorgenIvarsson yes, it's quite a lot to learn and manage. There are a number of other deployment solutions out there that might work for you - have you considered Heroku for example?
@JorgenIvarsson, if Heroku is not an option, you can also check Hatchbox, developed by Chris Oliver from GoRails. It's far easier to get started as a new Rails developer than something like Kubernetes.
Thank you for your helpful suggestions @camertron and @scart88 . I am familiar with these services. I have tested Heroku, but not yet Hatchbox.
Heroku seems to be the suggested solution in 90% in all discussions I have read. The other 10% seem to be varying degrees of complicated setup of a VM and then using Capistrano with application servers such as Puma/Passenger/Unicorn together with Postgresql on that VM. So, I must choose between Heroku or a lot of tinkering (If I don’t want to pay Hatchbox to take care of the tinkering).
But what I want is a solution where I can follow along when DHH builds his famous demo blog, and where I can continue the demo with a deployment that is as easy as it was creating the blog.
Do you remember when you first saw Rail's scaffolding? Pure magic!
I want the deployment of an app to give the same feeling of magic (But using industry standard solutions like Docker and Kubernetes) In short, Active Deployment.
Do you think that Kuby could be that solution for a developer of small and simple rails apps (typically a monolithic rails app + redis + postgresql )? Or should I look elsewhere?
But what I want is a solution where I can follow along when DHH builds his famous demo blog, and where I can continue the demo with a deployment that is as easy as it was creating the blog.
Me too!
Do you think that Kuby could be that solution for a developer of small and simple rails apps (typically a monolithic rails app + redis + postgresql )? Or should I look elsewhere?
That's exactly what I want Kuby to be. It's amazing to me that a large number of Rails developers are still using Capistrano in 2022. Don't get me wrong, Capistrano is a great tool, but I believe there are better ways to deploy apps these days.
Hey @JorgenIvarsson, good news! At the end of last week I released the promised big update. Let me know if it works better for you :) Here's the changelog entry if you're curious.
Thanks for the info @camertron! But I am following this project closely and have already upgraded to the new version. I was (and still is) unsure of the best way to upgrade the gem files and the kuby core. I think that I got it right, but it would be nice to have an instruction on how to upgrade from one version to the next. Anyhow, when I continued the instruction I encountered another problem. When I ran bundle exec kuby -e production setup I got ..Refreshing kubeconfig... And then the error: 404 Not Found: NOT FOUND. I have no clue what this means. I know I have been follow along a guide on Kubernetes, using googles gcloud tool and kubectl. Maybe this has altered something in the kubeconf? Anyway I am going to start over with a completely new app and see if I succeed with a fresh project (and credentials). If that doesn't work I will look in to this kubeconfig-file and see if there is something wrong or missing in that file.
I am following this project closely and have already upgraded to the new version.
🎉 🎉
I was (and still is) unsure of the best way to upgrade the gem files and the kuby core.
That's good feedback, Kuby does need to have a better upgrade story. I'll have an answer for that before v1.0 (whenever that is).
When I ran bundle exec kuby -e production setup I got ..Refreshing kubeconfig... And then the error: 404 Not Found: NOT FOUND.
Hmm, did Kuby print any message saying it had successfully refreshed the kubeconfig? If not, then it sounds like a problem communicating with the cloud provider. Which cloud provider are you using, and are your credentials correct? Kuby doesn't support Google k8s yet. In any case, sounds like an opportunity for a better error message.
Thanks for the tip @camertron! Yes, it turns out when I left off I hadn't fully configured the kubernets section. But once I manage to deploy i got a 404 nginx error message. Tried both with Linode and DigitalOcean. My app did not use a database and maybe that caused some problems?
Anyhow, I created a new simple app from scratch, this time using a database (just in case using a database is a prerequisite). But when I run "bundle exec kuby -e production build" i get an error: Kuby does not support the 'postgresql' database adapter. This error message really surprised me. I thought that Postgresql was one of the most popular databases in the Rails community? Or is it that there is more than one database adapter for postgres, and I am using the wrong one?
But once I manage to deploy i got a 404 nginx error message. Tried both with Linode and DigitalOcean. My app did not use a database and maybe that caused some problems?
Hmm interesting. How were you attempting to make requests to the app? Was there TLS involved? Enabling/disabling the managed database feature shouldn't be able to cause a connectivity issue like that.
This error message really surprised me. I thought that Postgresql was one of the most popular databases in the Rails community? Or is it that there is more than one database adapter for postgres, and I am using the wrong one?
I can't believe this, but I forgot to document the database changes from the previous Kuby release 🤦 Kuby used to support both Postgres and MySQL, but now only supports CockroachDB. There are a lot of good reasons for this, one of the biggest being that Cockroach is wire-compatible with Postgres. In other words they're both almost 100% compatible with each other. More importantly however, Cockroach has been designed to run in the cloud. You'll need to add the cockroach-activerecord-adapter to your Gemfile and set the adapter to cockroachdb
in your database.yml. I will update the docs right now.
Yes, that was strange and I have no explanation for not being able to connect to the app. I could l connect to the app through the command "bundle exec kuby -e production remote shell". I could even spin up the puma server with "Rails server". I did not configure a domain name. Instead I tried to connect via the public ip-adress provided by the load balancer. So on one hand the app was running via the shell and I could also access the log files. And on the other hand I could not connet via ip-adress in the browser or curl. All I got was a 404 error message from nginx. Here is the docker image I used: https://hub.docker.com/repository/docker/jorgenivarsson/kuby
So now I have a created a new fresh app that uses a database (Postgresql). If I want to use Kuby, do I have to switch to cockroach completely or can I use postgres as a development database and only use cockroach as a production database in my database.yml? Maybe load the gem file for cockroach under a production group? I'm not sure what happens when the app is dockerized? Is the database actually involved in the dockerization/kubernetization of the app or is only the database schema and migrations used? The reason I ask is that I already have mysql/mariadb and postgres installed on my computer. I rather not install (or learn) yet another database if I can avoid it. I understand the reasons for choosing Cockroach. But the demands for using a specific database complicates things if there is no simple way of switching from say Postgres to Cockroach. Or is Cockroach a new default for all cloud based applications so it is expected that you use it together with Kubernetes from the start when developing a new application? Anyway, thanks for your help and patience @camertron!
UPDATE: It seems that cockroach-activerecord-adapter don't work with Rails 7. The gem won't install in a Rails 7 project. An issue asking for Rails 7 support was published on Januari 1 and is still today not fixed: https://github.com/cockroachdb/activerecord-cockroachdb-adapter/issues/239
Hey @JorgenIvarsson, apologies for the delayed response.
If I want to use Kuby, do I have to switch to cockroach completely or can I use postgres as a development database and only use cockroach as a production database in my database.yml?
Yes, what you've described is absolutely possible. Kuby doesn't offer a solution for development environments at the moment.
Maybe load the gem file for cockroach under a production group?
Yes, that's what I'd suggest 😄
Is the database actually involved in the dockerization/kubernetization of the app or is only the database schema and migrations used?
The schema and migrations are part of your app and are copied into the Docker image, and the CockroachDB adapter gem is installed inside the image as well. Other than that, the choice of database isn't considered during the Docker build.
Kuby instructs Kubernetes to launch several CockroachDB pods (older versions launched Postgres or MySQL pods). You can tell Kuby to not create any database pods (for example, if you're using a managed database offering from your cloud provider) by setting manage_database false
as documented here.
I rather not install (or learn) yet another database if I can avoid it.
Right, I understand. Cockroach is very similar to Postgres from what I understand, so most of your existing knowledge should transfer easily.
Or is Cockroach a new default for all cloud based applications so it is expected that you use it together with Kubernetes from the start when developing a new application?
It's not necessarily expected by the industry at large; most companies still use MySQL or Postgres I believe. I chose it for Kuby because it's specifically designed for the cloud. As the cool kids say, it's "cloud native" and much easier to upgrade in-place. That's actually one of the biggest reasons Kuby doesn't have a good upgrade story right now, because MySQL and Postgres are difficult to upgrade in-place and without incurring downtime.
It seems that cockroach-activerecord-adapter don't work with Rails 7.
Oh no, that's not good! Thanks for letting me know 😓
I'm getting this error when we are trying to setup the provider on Digital Ocean.
Kuby config
Kuby terminal error on kuby setup
Kuby terminal error on kuby deploy
Is there anything I can do to fix it?