kuby-core: Kuby Ingress Error: Could not apply https://raw.githubusercontent.com/kubernetes/ingress-nginx....
I’m getting this error when we are trying to setup the provider on Digital Ocean.
Kuby config
require 'active_support/core_ext'
require 'active_support/encrypted_configuration'
# Define a production Kuby deploy environment
Kuby.define('KubyApp') do
environment(:production) do
# Because the Rails environment isn't always loaded when
# your Kuby config is loaded, provide access to Rails
# credentials manually.
app_creds = ActiveSupport::EncryptedConfiguration.new(
config_path: File.join('config', 'credentials', 'production.yml.enc'),
key_path: File.join('config', 'credentials', 'production.key'),
env_key: 'RAILS_MASTER_KEY',
raise_if_missing_key: true
)
docker do
# Configure your Docker registry credentials here. Add them to your
# Rails credentials file by running `bundle exec rake credentials:edit`.
credentials do
username app_creds[:KUBY_DOCKER_USERNAME]
password app_creds[:KUBY_DOCKER_PASSWORD]
email app_creds[:KUBY_DOCKER_EMAIL]
end
# distro :alpine
# Configure the URL to your Docker image here, eg:
# image_url 'foo.bar.com/me/myproject'
#
# If you're using Gitlab's Docker registry, try something like this:
image_url 'registry.gitlab.com/user/repo'
end
kubernetes do
provider :digitalocean do
access_token app_creds[:DIGITALOCEAN_ACCESS_TOKEN]
cluster_id app_creds[:CLUSTER_ID]
end
# Add a plugin that facilitates deploying a Rails app.
add_plugin :rails_app do
hostname 'app2.domain.com'
manage_database false
env do
data do
add "DATABASE_URL", app_creds[:DATABASE_URL]
end
end
# configure database credentials
# database do
# user app_creds[:KUBY_DB_USER]
# password app_creds[:KUBY_DB_PASSWORD]
# end
end
# Use Docker Desktop as the provider.
# See: https://www.docker.com/products/docker-desktop
#
# Note: you will likely want to use a different provider when deploying
# your application into a production environment. To configure a different
# provider, add the corresponding gem to your gemfile and update the
# following line according to the provider gem's README.
end
end
end
Kuby terminal error on kuby setup
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
configmap/nginx-configuration created
configmap/tcp-services created
configmap/udp-services created
serviceaccount/nginx-ingress-serviceaccount created
deployment.apps/nginx-ingress-controller created
limitrange/ingress-nginx created
unable to recognize "https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.27.1/deploy/static/mandatory.yaml": no matches for kind "ClusterRole" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.27.1/deploy/static/mandatory.yaml": no matches for kind "Role" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.27.1/deploy/static/mandatory.yaml": no matches for kind "RoleBinding" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.27.1/deploy/static/mandatory.yaml": no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1beta1"
Could not apply https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.27.1/deploy/static/mandatory.yaml: kubectl exited with status code 1
error: Could not apply https://raw.githubusercontent.com/kubernetes/ingress-nginx/nginx-0.27.1/deploy/static/mandatory.yaml: kubectl exited with status code 1
Kuby terminal error on kuby deploy
bundle exec kuby -e production deploy
Error from server (NotFound): namespaces "app-production" not found
Validating global resource, namespace 'app-production'
namespace/app-production created (dry run)
Deploying namespace 'app-production'
namespace/app-production created
[INFO][2022-03-11 17:41:57 +0200]
[INFO][2022-03-11 17:41:57 +0200] ------------------------------------Phase 1: Initializing deploy------------------------------------
[INFO][2022-03-11 17:42:00 +0200] All required parameters and files are present
[INFO][2022-03-11 17:42:00 +0200] Discovering resources:
[INFO][2022-03-11 17:42:03 +0200] - Service/app-assets-svc
[INFO][2022-03-11 17:42:03 +0200] - Ingress/app-ingress
[INFO][2022-03-11 17:42:03 +0200] - Deployment/app-assets
[INFO][2022-03-11 17:42:03 +0200] - ConfigMap/app-config
[INFO][2022-03-11 17:42:03 +0200] - ConfigMap/app-assets-nginx-config
[INFO][2022-03-11 17:42:03 +0200] - ServiceAccount/app-assets-sa
[INFO][2022-03-11 17:42:03 +0200] - Service/app-svc
[INFO][2022-03-11 17:42:03 +0200] - ClusterIssuer/letsencrypt-production
[INFO][2022-03-11 17:42:03 +0200] - ServiceAccount/app-sa
[INFO][2022-03-11 17:42:03 +0200] - Deployment/app-web
[INFO][2022-03-11 17:42:03 +0200] - Secret/app-secrets
[INFO][2022-03-11 17:42:03 +0200] - Secret/app-registry-secret
[INFO][2022-03-11 17:42:07 +0200]
[INFO][2022-03-11 17:42:07 +0200] ------------------------------------------Result: FAILURE-------------------------------------------
[FATAL][2022-03-11 17:42:07 +0200] Template validation failed
[FATAL][2022-03-11 17:42:07 +0200]
[FATAL][2022-03-11 17:42:07 +0200] Invalid template: ClusterIssuer-letsencrypt-production20220311-21350-rc7rha.yml
[FATAL][2022-03-11 17:42:07 +0200] > Error message:
[FATAL][2022-03-11 17:42:07 +0200] W0311 17:42:03.089014 21380 helpers.go:557] --dry-run is deprecated and can be replaced with --dry-run=client.
[FATAL][2022-03-11 17:42:07 +0200] error: unable to recognize "/var/folders/hh/z_vjqk3j3dl5vw0whd7h7bp80000gn/T/ClusterIssuer-letsencrypt-production20220311-21350-rc7rha.yml": no matches for kind "ClusterIssuer" in version "cert-manager.io/v1alpha2"
[FATAL][2022-03-11 17:42:07 +0200] > Template content:
[FATAL][2022-03-11 17:42:07 +0200] ---
[FATAL][2022-03-11 17:42:07 +0200] apiVersion: cert-manager.io/v1alpha2
[FATAL][2022-03-11 17:42:07 +0200] kind: ClusterIssuer
[FATAL][2022-03-11 17:42:07 +0200] metadata:
[FATAL][2022-03-11 17:42:07 +0200] name: letsencrypt-production
[FATAL][2022-03-11 17:42:07 +0200] namespace: cert-manager
[FATAL][2022-03-11 17:42:07 +0200] spec:
[FATAL][2022-03-11 17:42:07 +0200] acme:
[FATAL][2022-03-11 17:42:07 +0200] server: https://acme-v02.api.letsencrypt.org/directory
[FATAL][2022-03-11 17:42:07 +0200] email: shopandfy@xmail8.com
[FATAL][2022-03-11 17:42:07 +0200] privateKeySecretRef:
[FATAL][2022-03-11 17:42:07 +0200] name: letsencrypt-production
[FATAL][2022-03-11 17:42:07 +0200] solvers:
[FATAL][2022-03-11 17:42:07 +0200] - http01:
[FATAL][2022-03-11 17:42:07 +0200] ingress:
[FATAL][2022-03-11 17:42:07 +0200] class: nginx
[FATAL][2022-03-11 17:42:07 +0200]
[FATAL][2022-03-11 17:42:07 +0200]
[FATAL][2022-03-11 17:42:07 +0200] Invalid template: Ingress-app-ingress20220311-21350-ht7nke.yml
[FATAL][2022-03-11 17:42:07 +0200] > Error message:
[FATAL][2022-03-11 17:42:07 +0200] W0311 17:42:05.241076 21398 helpers.go:557] --dry-run is deprecated and can be replaced with --dry-run=client.
[FATAL][2022-03-11 17:42:07 +0200] error: unable to recognize "/var/folders/hh/z_vjqk3j3dl5vw0whd7h7bp80000gn/T/Ingress-app-ingress20220311-21350-ht7nke.yml": no matches for kind "Ingress" in version "extensions/v1beta1"
[FATAL][2022-03-11 17:42:07 +0200] > Template content:
[FATAL][2022-03-11 17:42:07 +0200] ---
[FATAL][2022-03-11 17:42:07 +0200] apiVersion: extensions/v1beta1
[FATAL][2022-03-11 17:42:07 +0200] kind: Ingress
[FATAL][2022-03-11 17:42:07 +0200] metadata:
[FATAL][2022-03-11 17:42:07 +0200] annotations:
[FATAL][2022-03-11 17:42:07 +0200] kubernetes.io/ingress.class: nginx
[FATAL][2022-03-11 17:42:07 +0200] cert-manager.io/cluster-issuer: letsencrypt-production
[FATAL][2022-03-11 17:42:07 +0200] name: app-ingress
[FATAL][2022-03-11 17:42:07 +0200] namespace: app-production
[FATAL][2022-03-11 17:42:07 +0200] spec:
[FATAL][2022-03-11 17:42:07 +0200] rules:
[FATAL][2022-03-11 17:42:07 +0200] - host: app2.domain.com
[FATAL][2022-03-11 17:42:07 +0200] http:
[FATAL][2022-03-11 17:42:07 +0200] paths:
[FATAL][2022-03-11 17:42:07 +0200] - backend:
[FATAL][2022-03-11 17:42:07 +0200] serviceName: app-svc
[FATAL][2022-03-11 17:42:07 +0200] servicePort: 8080
[FATAL][2022-03-11 17:42:07 +0200] path: "/"
[FATAL][2022-03-11 17:42:07 +0200] - host: app2.domain.com
[FATAL][2022-03-11 17:42:07 +0200] http:
[FATAL][2022-03-11 17:42:07 +0200] paths:
[FATAL][2022-03-11 17:42:07 +0200] - backend:
[FATAL][2022-03-11 17:42:07 +0200] serviceName: app-assets-svc
[FATAL][2022-03-11 17:42:07 +0200] servicePort: 8082
[FATAL][2022-03-11 17:42:07 +0200] path: "/assets"
[FATAL][2022-03-11 17:42:07 +0200] - backend:
[FATAL][2022-03-11 17:42:07 +0200] serviceName: app-assets-svc
[FATAL][2022-03-11 17:42:07 +0200] servicePort: 8082
[FATAL][2022-03-11 17:42:07 +0200] path: "/packs"
[FATAL][2022-03-11 17:42:07 +0200] tls:
[FATAL][2022-03-11 17:42:07 +0200] - hosts:
[FATAL][2022-03-11 17:42:07 +0200] - app2.domain.com
[FATAL][2022-03-11 17:42:07 +0200] secretName: app-tls
[FATAL][2022-03-11 17:42:07 +0200]
error: Template validation failed
Is there anything I can do to fix it?
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 28
Solved. Problem was in DATABASE_URL and how I send it to database.yml.
Me too!
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, 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.
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 falsemay 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:There should be one pod in the
Init:CrashLoopBackOffstate. Copy the name of the pod and run the following command to print out the logs from the create-db init container:(This should be a lot easier, I’ll file an issue)
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
Setup seems to work better than before
I will try with v.1.20. Let’s see if it works.
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/v1beta1API, 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 falsein your Kuby config, you can sidestep these problems by using kuby-core@master. In other words, put this in your Gemfile: