This repository has been archived by the owner on Jan 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
/
qube-init
executable file
·62 lines (46 loc) · 1.53 KB
/
qube-init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/usr/bin/env ruby
require "yaml"
require "erb"
require 'optparse'
# set up flag options
options = {action: 'ask'}
OptionParser.new do |opts|
opts.banner = "Usage: ./qube-init [options]"
opts.on("-a", "--action [ACTION]", String,
"create: override out directory and generate new resources.
update: keep out directory and only add additional resources.") do |a|
options[:action] = a
end
opts.on("-h", "--help", "prints this help.") do
puts opts
exit
end
end.parse!
@action_flag=options[:action]
# setup the config file to use to generate the quorum resources and kubernetes API resources.
@config_file = "qubernetes.yaml"
@optional_config_file=ARGV[0]
ARGV.clear
if @optional_config_file != nil
@config_file = @optional_config_file
end
puts "using config file: " + @config_file
@config = YAML.load_file(@config_file)
# Generate deployments in a single file, or in separate files.
@sep_deployment_files=true
if @config["k8s"] and @config["k8s"]["sep_deployment_files"] != nil
@sep_deployment_files = @config["k8s"]["sep_deployment_files"]
end
puts " Running ./quorum-init to generate Quorum resources."
system("./quorum-init --action=#{@action_flag} #{@config_file}")
puts " Running ./qubernetes to generate Kubernetes resources."
puts ""
`
./qubernetes #{@config_file}
`
@Kubectl_Cmd=" $> kubectl apply -f out"
if @sep_deployment_files
@Kubectl_Cmd=" $> kubectl apply -f out -f out/deployments"
end
puts(" To deploy to kubernetes run:")
puts(@Kubectl_Cmd)