diff --git a/README.md b/README.md index 98a99c2..1f98dd1 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,10 @@ $ cuber info Check out the [Cuberfile configuration](https://cuber.cloud/docs/cuberfile) and the [Cuber CLI commands](https://cuber.cloud/docs/cli) for more information. +## Node Pool Keys +GKE: cloud.google.com/gke-nodepool +Digital Ocean: doks.digitalocean.com/node-pool + ## Production-ready We have built Cuber for scaling [Pushpad](https://pushpad.xyz). Cuber has been used in production for over a year and it is stable and reliable. We had 100% uptime and we saved 80% on cloud costs. @@ -85,4 +89,3 @@ Cuber is released under the [Apache-2.0 license](https://opensource.org/licenses ## Learn more You can find more information and documentation on [cuber.cloud](https://cuber.cloud). - diff --git a/lib/cuber/cli.rb b/lib/cuber/cli.rb index 48ec6cb..73bd27d 100644 --- a/lib/cuber/cli.rb +++ b/lib/cuber/cli.rb @@ -13,9 +13,11 @@ module Cuber class CLI def initialize + file_path = ARGV[1] || 'Cuberfile' + @options = {} parse_command! - parse_cuberfile + parse_cuberfile(file_path) validate_cuberfile execute end @@ -26,9 +28,9 @@ def parse_command! @options[:cmd] = ARGV.shift&.to_sym end - def parse_cuberfile - abort 'Cuberfile not found in current directory' unless File.exist? 'Cuberfile' - content = File.read 'Cuberfile' + def parse_cuberfile(file_path) + abort 'Cuberfile not found in current directory' unless File.exist? file_path + content = File.read file_path parser = CuberfileParser.new parser.instance_eval(content) cuberfile_options = parser.instance_variables.map do |name| diff --git a/lib/cuber/cuberfile_parser.rb b/lib/cuber/cuberfile_parser.rb index d92cfa2..ebb5421 100644 --- a/lib/cuber/cuberfile_parser.rb +++ b/lib/cuber/cuberfile_parser.rb @@ -65,8 +65,8 @@ def migrate cmd, check: nil @migrate = { cmd: cmd, check: check } end - def proc name, cmd, scale: 1, cpu: nil, ram: nil, term: 60, env: {} - @procs[name] = { cmd: cmd, scale: scale, cpu: cpu, ram: ram, term: term, env: env } + def proc name, cmd, scale: 1, cpu: nil, ram: nil, term: 60, env: {}, node_pool_key: nil, node_pool_name: nil + @procs[name] = { cmd: cmd, scale: scale, cpu: cpu, ram: ram, term: term, env: env, node_pool_key: node_pool_key, node_pool_name: node_pool_name } end def cron name, schedule, cmd diff --git a/lib/cuber/templates/deployment.yml.erb b/lib/cuber/templates/deployment.yml.erb index 1bb213b..78b5b57 100644 --- a/lib/cuber/templates/deployment.yml.erb +++ b/lib/cuber/templates/deployment.yml.erb @@ -149,6 +149,10 @@ spec: app.kubernetes.io/managed-by: cuber app: <%= procname %>-proc spec: + <%- if proc[:node_pool_key] && proc[:node_pool_name] -%> + nodeSelector: + <%= proc[:node_pool_key] %>: <%= proc[:node_pool_name]%> + <%- end -%> containers: - name: <%= procname %>-proc image: <%= @options[:image] %>:<%= @options[:release] %>