cuber-cloud / cuber-gem

An automation tool that simplify the deployment of your apps on Kubernetes.
https://cuber.cloud
Apache License 2.0
656 stars 24 forks source link

cuber run rails console failing #3

Closed ghost closed 2 years ago

ghost commented 2 years ago

Running

cuber run rails console

Produces this error

lmackay@Ls-MacBook-Pro myapp % cuber run rails console
pod/pod-rails-console-20220608090959 created
pod/pod-rails-console-20220608090959 condition met
error: Internal error occurred: error executing command in container: failed to exec in container: failed to start exec "e96168cb2b05018ce5652f48f9e349d05a252eec71590cabd18f1b958eb498b5": OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "launcher": executable file not found in $PATH: unknown
Cuber: "kubectl --kubeconfig kubeconfig.yml -n myapp exec -it pod-rails-console-20220608090959 -- launcher rails console" failed

Running the kubectl command without launcher works.

kubectl --kubeconfig kubeconfig.yml -n myapp exec -it pod-rails-console-20220608085854 -- rails console

Produces a rails console and pod and works perfectly.

Loading production environment (Rails 7.0.3) irb(main):001:0>

My Docker file is Identical to the docs except for addition of libvips42

FROM ruby:3.0.2 ARG RAILS_ENV=production RUN curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - RUN curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.list.d/yarn.list RUN apt-get update && apt-get install -y nodejs yarn postgresql-client default-mysql-client libvips42 RUN mkdir /app WORKDIR /app COPY Gemfile Gemfile.lock ./ RUN gem install bundler RUN bundle config set without 'development test' RUN bundle install COPY . . RUN SECRET_KEY_BASE=bin/rake secret rails assets:precompile EXPOSE 8080 CMD ["rails", "server", "-b", "0.0.0.0", "-p", "8080"]

If I switch and use 'heroku/buildpacks:20' everything works, only issue with the heroku setup was it does not have vips out of the box so I'm preferring the Dockerfile setup.

collimarco commented 2 years ago

Hello, thanks for reporting this issue.

This is how Cuber works:

Check out this file: https://github.com/cuber-cloud/cuber-gem/blob/master/lib/cuber/commands/run.rb

Cuber detects whether you are using buildpacks or not based on an annotation that keeps in the K8s cluster (i.e. it keeps a note saying if the last deploy used buildpacks or not).

In your case it seems that Cuber finds the annotation, and thus adds the launcher prefix.

The line that generates the annotation seems correct.

Can you try to run cuber deploy again and see if that fixes the annotation and the issue? You can easily inspect the annotation on the namespace using K8s lens.

collimarco commented 2 years ago

If you can inspect the annotations on the namespace using K8s lens (or any other tool) and tell me what is the current value, that would help solving this issue.

collimarco commented 2 years ago

I was able to reproduce the problem, I'll release a fix as soon as possible.

ghost commented 2 years ago

Installed K8 Lens, it made me feel powerful, sorry for being a slow poke. Just started to learn what Kubernetes is yesterday.

Have worked with people who know it well, some of the stuff they have said to me helped.

Thank you.

collimarco commented 2 years ago

@leigh-mackay I have just released v1.2.1 of this gem which fixes this issue.