kuber_kit 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +7 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +67 -0
- data/LICENSE.txt +21 -0
- data/README.md +19 -0
- data/Rakefile +6 -0
- data/TODO.md +2 -0
- data/bin/console +14 -0
- data/bin/kit +8 -0
- data/example/app_data/service.yml +7 -0
- data/example/app_data/test.env +2 -0
- data/example/app_data/test.txt +1 -0
- data/example/configurations/review.rb +4 -0
- data/example/images/app_sources/Dockerfile +6 -0
- data/example/images/app_sources/build_context/source.rb +2 -0
- data/example/images/app_sources/image.rb +4 -0
- data/example/images/ruby/Dockerfile +1 -0
- data/example/images/ruby/image.rb +3 -0
- data/example/images/ruby_app/Dockerfile +11 -0
- data/example/images/ruby_app/build_context/example_file.txt +2 -0
- data/example/images/ruby_app/image.rb +15 -0
- data/example/images/ruby_app2/Dockerfile +8 -0
- data/example/images/ruby_app2/build_context/example_file.txt +2 -0
- data/example/images/ruby_app2/image.rb +4 -0
- data/example/infrastructure/artifacts.rb +13 -0
- data/example/infrastructure/env_files.rb +4 -0
- data/example/infrastructure/registries.rb +4 -0
- data/example/infrastructure/services.rb +3 -0
- data/example/infrastructure/templates.rb +4 -0
- data/kuber_kit.gemspec +35 -0
- data/lib/kuber_kit.rb +205 -0
- data/lib/kuber_kit/actions/configuration_loader.rb +74 -0
- data/lib/kuber_kit/actions/env_file_reader.rb +17 -0
- data/lib/kuber_kit/actions/image_compiler.rb +56 -0
- data/lib/kuber_kit/actions/kubectl_applier.rb +17 -0
- data/lib/kuber_kit/actions/service_applier.rb +39 -0
- data/lib/kuber_kit/actions/service_reader.rb +17 -0
- data/lib/kuber_kit/actions/template_reader.rb +17 -0
- data/lib/kuber_kit/artifacts_sync/abstract_artifact_resolver.rb +5 -0
- data/lib/kuber_kit/artifacts_sync/artifacts_updater.rb +42 -0
- data/lib/kuber_kit/artifacts_sync/git_artifact_resolver.rb +31 -0
- data/lib/kuber_kit/artifacts_sync/null_artifact_resolver.rb +7 -0
- data/lib/kuber_kit/cli.rb +72 -0
- data/lib/kuber_kit/configs.rb +42 -0
- data/lib/kuber_kit/container.rb +207 -0
- data/lib/kuber_kit/core/artifacts/abstract_artifact.rb +13 -0
- data/lib/kuber_kit/core/artifacts/artifact_store.rb +45 -0
- data/lib/kuber_kit/core/artifacts/git.rb +22 -0
- data/lib/kuber_kit/core/artifacts/local.rb +14 -0
- data/lib/kuber_kit/core/configuration.rb +20 -0
- data/lib/kuber_kit/core/configuration_definition.rb +67 -0
- data/lib/kuber_kit/core/configuration_definition_factory.rb +5 -0
- data/lib/kuber_kit/core/configuration_factory.rb +61 -0
- data/lib/kuber_kit/core/configuration_store.rb +72 -0
- data/lib/kuber_kit/core/context_helper/base_helper.rb +28 -0
- data/lib/kuber_kit/core/context_helper/context_helper_factory.rb +23 -0
- data/lib/kuber_kit/core/context_helper/image_helper.rb +2 -0
- data/lib/kuber_kit/core/context_helper/service_helper.rb +19 -0
- data/lib/kuber_kit/core/env_files/abstract_env_file.rb +9 -0
- data/lib/kuber_kit/core/env_files/artifact_file.rb +9 -0
- data/lib/kuber_kit/core/env_files/env_file_store.rb +45 -0
- data/lib/kuber_kit/core/image.rb +39 -0
- data/lib/kuber_kit/core/image_definition.rb +85 -0
- data/lib/kuber_kit/core/image_definition_factory.rb +5 -0
- data/lib/kuber_kit/core/image_factory.rb +40 -0
- data/lib/kuber_kit/core/image_store.rb +60 -0
- data/lib/kuber_kit/core/registries/abstract_registry.rb +25 -0
- data/lib/kuber_kit/core/registries/registry.rb +24 -0
- data/lib/kuber_kit/core/registries/registry_store.rb +49 -0
- data/lib/kuber_kit/core/service.rb +14 -0
- data/lib/kuber_kit/core/service_definition.rb +33 -0
- data/lib/kuber_kit/core/service_definition_factory.rb +5 -0
- data/lib/kuber_kit/core/service_factory.rb +17 -0
- data/lib/kuber_kit/core/service_store.rb +68 -0
- data/lib/kuber_kit/core/templates/abstract_template.rb +9 -0
- data/lib/kuber_kit/core/templates/artifact_file.rb +9 -0
- data/lib/kuber_kit/core/templates/template_store.rb +45 -0
- data/lib/kuber_kit/env_file_reader/abstract_env_file_reader.rb +5 -0
- data/lib/kuber_kit/env_file_reader/artifact_file_reader.rb +86 -0
- data/lib/kuber_kit/env_file_reader/reader.rb +35 -0
- data/lib/kuber_kit/extensions/colored_string.rb +43 -0
- data/lib/kuber_kit/extensions/contracts.rb +4 -0
- data/lib/kuber_kit/extensions/indocker_compat.rb +19 -0
- data/lib/kuber_kit/extensions/inspectable.rb +10 -0
- data/lib/kuber_kit/image_compiler/compiler.rb +21 -0
- data/lib/kuber_kit/image_compiler/image_build_dir_creator.rb +37 -0
- data/lib/kuber_kit/image_compiler/image_builder.rb +26 -0
- data/lib/kuber_kit/image_compiler/image_dependency_resolver.rb +40 -0
- data/lib/kuber_kit/image_compiler/version_tag_builder.rb +5 -0
- data/lib/kuber_kit/preprocessing/dir_preprocessor.rb +19 -0
- data/lib/kuber_kit/preprocessing/file_preprocessor.rb +33 -0
- data/lib/kuber_kit/preprocessing/text_preprocessor.rb +7 -0
- data/lib/kuber_kit/service_deployer/service_list_resolver.rb +56 -0
- data/lib/kuber_kit/service_deployer/service_reader.rb +20 -0
- data/lib/kuber_kit/shell/abstract_shell.rb +20 -0
- data/lib/kuber_kit/shell/bash_commands.rb +25 -0
- data/lib/kuber_kit/shell/command_counter.rb +19 -0
- data/lib/kuber_kit/shell/docker_commands.rb +16 -0
- data/lib/kuber_kit/shell/git_commands.rb +28 -0
- data/lib/kuber_kit/shell/kubectl_commands.rb +12 -0
- data/lib/kuber_kit/shell/local_shell.rb +64 -0
- data/lib/kuber_kit/shell/rsync_commands.rb +20 -0
- data/lib/kuber_kit/template_reader/abstract_template_reader.rb +5 -0
- data/lib/kuber_kit/template_reader/artifact_file_reader.rb +14 -0
- data/lib/kuber_kit/template_reader/reader.rb +35 -0
- data/lib/kuber_kit/tools/file_presence_checker.rb +25 -0
- data/lib/kuber_kit/tools/files_sync.rb +10 -0
- data/lib/kuber_kit/tools/logger_factory.rb +34 -0
- data/lib/kuber_kit/ui.rb +18 -0
- data/lib/kuber_kit/ui/interactive.rb +44 -0
- data/lib/kuber_kit/ui/simple.rb +75 -0
- data/lib/kuber_kit/version.rb +3 -0
- metadata +273 -0
@@ -0,0 +1,74 @@
|
|
1
|
+
class KuberKit::Actions::ConfigurationLoader
|
2
|
+
include KuberKit::Import[
|
3
|
+
"core.registry_store",
|
4
|
+
"core.image_store",
|
5
|
+
"core.configuration_store",
|
6
|
+
"artifacts_sync.artifacts_updater",
|
7
|
+
"tools.logger",
|
8
|
+
"shell.local_shell",
|
9
|
+
"ui",
|
10
|
+
"configs"
|
11
|
+
]
|
12
|
+
|
13
|
+
Contract Hash => Any
|
14
|
+
def call(options)
|
15
|
+
root_path = options[:path] || File.join(Dir.pwd, configs.kuber_kit_dirname)
|
16
|
+
images_path = options[:images_path] || File.join(root_path, configs.images_dirname)
|
17
|
+
infra_path = options[:infra_path] || File.join(root_path, configs.infra_dirname)
|
18
|
+
configurations_path = options[:configurations_path] || File.join(root_path, configs.configurations_dirname)
|
19
|
+
configuration_name = options[:configuration]
|
20
|
+
|
21
|
+
logger.info "Launching kuber_kit with:"
|
22
|
+
logger.info " Root path: #{root_path.to_s.yellow}"
|
23
|
+
logger.info " Images path: #{images_path.to_s.yellow}"
|
24
|
+
logger.info " Infrastructure path: #{infra_path.to_s.yellow}"
|
25
|
+
logger.info " Configurations path: #{configurations_path.to_s.yellow}"
|
26
|
+
logger.info " Configuration name: #{configuration_name.to_s.yellow}"
|
27
|
+
|
28
|
+
unless File.exists?(root_path)
|
29
|
+
ui.print_warning "WARNING", "KuberKit root path #{root_path} doesn't exist. You may want to pass it --path parameter."
|
30
|
+
end
|
31
|
+
|
32
|
+
load_configurations(configurations_path, configuration_name)
|
33
|
+
load_infrastructure(infra_path)
|
34
|
+
|
35
|
+
ui.create_task("Updating artifacts") do |task|
|
36
|
+
artifacts = KuberKit.current_configuration.artifacts.values
|
37
|
+
artifacts_updater.update(local_shell, artifacts)
|
38
|
+
task.update_title("Updated #{artifacts.count} artifacts")
|
39
|
+
end
|
40
|
+
|
41
|
+
ui.create_task("Loading image definitions") do |task|
|
42
|
+
files = image_store.load_definitions(images_path)
|
43
|
+
task.update_title("Loaded #{files.count} image definitions")
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def load_configurations(configurations_path, configuration_name)
|
48
|
+
configuration_store.load_definitions(configurations_path)
|
49
|
+
|
50
|
+
if configuration_store.count.zero?
|
51
|
+
configuration_store.define(:_default_)
|
52
|
+
configuration_name ||= :_default_
|
53
|
+
end
|
54
|
+
|
55
|
+
if configuration_store.count == 1 && configuration_name.nil?
|
56
|
+
first_configurations = configuration_store.all_definitions.values.first
|
57
|
+
configuration_name = first_configurations.configuration_name
|
58
|
+
end
|
59
|
+
|
60
|
+
if configuration_store.count > 1 && configuration_name.nil?
|
61
|
+
raise KuberKit::Error, "Please set configuration name using -C option"
|
62
|
+
end
|
63
|
+
|
64
|
+
KuberKit.set_configuration_name(configuration_name)
|
65
|
+
end
|
66
|
+
|
67
|
+
def load_infrastructure(infra_path)
|
68
|
+
local_shell.recursive_list_files(infra_path).each do |path|
|
69
|
+
require(path)
|
70
|
+
end
|
71
|
+
rescue KuberKit::Shell::AbstractShell::DirNotFoundError
|
72
|
+
logger.warn("Directory with infrastructure not found: #{infra_path}")
|
73
|
+
end
|
74
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
class KuberKit::Actions::EnvFileReader
|
4
|
+
include KuberKit::Import[
|
5
|
+
"core.env_file_store",
|
6
|
+
"env_file_reader.reader",
|
7
|
+
"shell.local_shell",
|
8
|
+
"ui"
|
9
|
+
]
|
10
|
+
|
11
|
+
Contract Symbol, Hash => Any
|
12
|
+
def call(env_file_name, options)
|
13
|
+
env_file = env_file_store.get(env_file_name)
|
14
|
+
result = reader.read(local_shell, env_file)
|
15
|
+
ui.print_info(env_file_name.to_s, JSON.pretty_generate(result))
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
class KuberKit::Actions::ImageCompiler
|
2
|
+
include KuberKit::Import[
|
3
|
+
"image_compiler.compiler",
|
4
|
+
"image_compiler.image_dependency_resolver",
|
5
|
+
"shell.local_shell",
|
6
|
+
"tools.logger",
|
7
|
+
"configs",
|
8
|
+
"ui"
|
9
|
+
]
|
10
|
+
|
11
|
+
Contract ArrayOf[Symbol], Hash => Any
|
12
|
+
def call(image_names, options)
|
13
|
+
build_id = generate_build_id
|
14
|
+
|
15
|
+
resolved_dependencies = []
|
16
|
+
dependencies = image_dependency_resolver.get_next(image_names)
|
17
|
+
|
18
|
+
while (dependencies - resolved_dependencies).any?
|
19
|
+
compile_simultaneously(dependencies, build_id)
|
20
|
+
resolved_dependencies += dependencies
|
21
|
+
dependencies = image_dependency_resolver.get_next(image_names, resolved: resolved_dependencies)
|
22
|
+
end
|
23
|
+
|
24
|
+
compile_simultaneously(image_names - resolved_dependencies, build_id)
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
def compile_simultaneously(image_names, build_id)
|
29
|
+
task_group = ui.create_task_group
|
30
|
+
image_names.map do |image_name|
|
31
|
+
|
32
|
+
logger.info("Started compiling: #{image_name.to_s.green}")
|
33
|
+
task_group.add("Compiling #{image_name.to_s.yellow}") do |task|
|
34
|
+
compile_image(image_name, build_id)
|
35
|
+
|
36
|
+
task.update_title("Compiled #{image_name.to_s.green}")
|
37
|
+
logger.info("Finished compiling: #{image_name.to_s.green}")
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
task_group.wait
|
42
|
+
end
|
43
|
+
|
44
|
+
def compile_image(image_name, build_id)
|
45
|
+
compile_dir = generate_compile_dir(build_id: build_id)
|
46
|
+
image_compiler.compile(local_shell, image_name, compile_dir)
|
47
|
+
end
|
48
|
+
|
49
|
+
def generate_build_id
|
50
|
+
Time.now.strftime("%H%M%S")
|
51
|
+
end
|
52
|
+
|
53
|
+
def generate_compile_dir(build_id:)
|
54
|
+
File.join(configs.image_compile_dir, build_id)
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class KuberKit::Actions::KubectlApplier
|
2
|
+
include KuberKit::Import[
|
3
|
+
"shell.kubectl_commands",
|
4
|
+
"shell.local_shell",
|
5
|
+
"ui"
|
6
|
+
]
|
7
|
+
|
8
|
+
Contract String, Hash => Any
|
9
|
+
def call(file_path, options)
|
10
|
+
kubecfg_path = KuberKit.current_configuration.kubecfg_path
|
11
|
+
ui.create_task("Applying file: #{file_path}") do |task|
|
12
|
+
kubectl_commands.apply_file(local_shell, file_path, kubecfg_path: kubecfg_path)
|
13
|
+
task.update_title("Applied file: #{file_path}")
|
14
|
+
end
|
15
|
+
nil
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
class KuberKit::Actions::ServiceApplier
|
2
|
+
include KuberKit::Import[
|
3
|
+
"core.service_store",
|
4
|
+
"service_deployer.service_reader",
|
5
|
+
"service_deployer.service_list_resolver",
|
6
|
+
"shell.local_shell",
|
7
|
+
"shell.kubectl_commands",
|
8
|
+
"configs",
|
9
|
+
"ui"
|
10
|
+
]
|
11
|
+
|
12
|
+
Contract KeywordArgs[
|
13
|
+
services: Maybe[ArrayOf[String]],
|
14
|
+
tags: Maybe[ArrayOf[String]],
|
15
|
+
] => Any
|
16
|
+
def call(services:, tags:)
|
17
|
+
service_names = service_list_resolver.resolve(
|
18
|
+
services: services || [],
|
19
|
+
tags: tags || []
|
20
|
+
)
|
21
|
+
service_names.each do |service_name|
|
22
|
+
apply_service(service_name.to_sym)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def apply_service(service_name)
|
27
|
+
service = service_store.get_service(service_name)
|
28
|
+
kubecfg_path = KuberKit.current_configuration.kubecfg_path
|
29
|
+
|
30
|
+
result = service_reader.read(local_shell, service)
|
31
|
+
file_path = "#{configs.service_config_dir}/#{service.name}.yml"
|
32
|
+
local_shell.write(file_path, result)
|
33
|
+
|
34
|
+
ui.create_task("Applying file: #{file_path}") do |task|
|
35
|
+
kubectl_commands.apply_file(local_shell, file_path, kubecfg_path: kubecfg_path)
|
36
|
+
task.update_title("Applied file: #{file_path}")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class KuberKit::Actions::ServiceReader
|
2
|
+
include KuberKit::Import[
|
3
|
+
"core.service_store",
|
4
|
+
"service_deployer.service_reader",
|
5
|
+
"shell.local_shell",
|
6
|
+
"ui"
|
7
|
+
]
|
8
|
+
|
9
|
+
Contract Symbol, Hash => Any
|
10
|
+
def call(service_name, options)
|
11
|
+
service = service_store.get_service(service_name)
|
12
|
+
|
13
|
+
result = service_reader.read(local_shell, service)
|
14
|
+
|
15
|
+
ui.print_info(service_name.to_s, result)
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class KuberKit::Actions::TemplateReader
|
2
|
+
include KuberKit::Import[
|
3
|
+
"core.template_store",
|
4
|
+
"template_reader.reader",
|
5
|
+
"shell.local_shell",
|
6
|
+
"ui"
|
7
|
+
]
|
8
|
+
|
9
|
+
Contract Symbol, Hash => Any
|
10
|
+
def call(template_name, options)
|
11
|
+
template = template_store.get(template_name)
|
12
|
+
|
13
|
+
result = reader.read(local_shell, template)
|
14
|
+
|
15
|
+
ui.print_info(template_name.to_s, result)
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class KuberKit::ArtifactsSync::ArtifactsUpdater
|
2
|
+
ResolverNotFoundError = Class.new(KuberKit::NotFoundError)
|
3
|
+
|
4
|
+
include KuberKit::Import[
|
5
|
+
"artifacts_sync.git_artifact_resolver",
|
6
|
+
"artifacts_sync.null_artifact_resolver",
|
7
|
+
"tools.logger"
|
8
|
+
]
|
9
|
+
|
10
|
+
def use_resolver(artifact_resolver, artifact_class:)
|
11
|
+
@@resolvers ||= {}
|
12
|
+
|
13
|
+
if !artifact_resolver.is_a?(KuberKit::ArtifactsSync::AbstractArtifactResolver)
|
14
|
+
raise ArgumentError.new("should be an instance of KuberKit::ArtifactsSync::AbstractArtifactResolver, got: #{artifact_resolver.inspect}")
|
15
|
+
end
|
16
|
+
|
17
|
+
@@resolvers[artifact_class] = artifact_resolver
|
18
|
+
end
|
19
|
+
|
20
|
+
def update(shell, artifacts)
|
21
|
+
add_default_resolvers
|
22
|
+
|
23
|
+
artifacts.each do |artifact|
|
24
|
+
resolver = @@resolvers[artifact.class]
|
25
|
+
|
26
|
+
logger.info "Updating artifact #{artifact.name.to_s.green}"
|
27
|
+
|
28
|
+
raise ResolverNotFoundError, "Can't find resolver for artifact #{artifact}" if resolver.nil?
|
29
|
+
|
30
|
+
resolver.resolve(shell, artifact)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def add_default_resolvers
|
35
|
+
use_resolver(git_artifact_resolver, artifact_class: KuberKit::Core::Artifacts::Git)
|
36
|
+
use_resolver(null_artifact_resolver, artifact_class: KuberKit::Core::Artifacts::Local)
|
37
|
+
end
|
38
|
+
|
39
|
+
def reset!
|
40
|
+
@@resolvers = {}
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class KuberKit::ArtifactsSync::GitArtifactResolver < KuberKit::ArtifactsSync::AbstractArtifactResolver
|
2
|
+
|
3
|
+
include KuberKit::Import[
|
4
|
+
"shell.git_commands",
|
5
|
+
]
|
6
|
+
|
7
|
+
Contract KuberKit::Shell::AbstractShell, KuberKit::Core::Artifacts::Git => Any
|
8
|
+
def resolve(shell, artifact)
|
9
|
+
already_cloned = artifact_already_cloned?(
|
10
|
+
shell: shell,
|
11
|
+
target_path: artifact.cloned_path,
|
12
|
+
remote_url: artifact.remote_url,
|
13
|
+
)
|
14
|
+
|
15
|
+
if already_cloned
|
16
|
+
git_commands.force_pull_repo(shell,
|
17
|
+
path: artifact.cloned_path, branch: artifact.branch
|
18
|
+
)
|
19
|
+
else
|
20
|
+
git_commands.download_repo(shell,
|
21
|
+
remote_url: artifact.remote_url, path: artifact.cloned_path, branch: artifact.branch
|
22
|
+
)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
def artifact_already_cloned?(shell:, target_path:, remote_url:)
|
28
|
+
target_remote_url = git_commands.get_remote_url(shell, target_path)
|
29
|
+
target_remote_url == remote_url
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
class KuberKit::CLI < Thor
|
4
|
+
class_option :path, :type => :string
|
5
|
+
class_option :images_path, :type => :string
|
6
|
+
class_option :infra_path, :type => :string
|
7
|
+
class_option :configurations_path, :type => :string
|
8
|
+
class_option :debug, :type => :boolean, aliases: ["-d"]
|
9
|
+
class_option :configuration, :type => :string, aliases: ["-C"]
|
10
|
+
|
11
|
+
desc "compile IMAGE_NAMES", "Compile image with IMAGE_NAMES (comma-separated)"
|
12
|
+
def compile(image_names_str)
|
13
|
+
KuberKit.set_debug_mode(options[:debug])
|
14
|
+
|
15
|
+
image_names = image_names_str.split(",").map(&:strip).map(&:to_sym)
|
16
|
+
|
17
|
+
KuberKit::Container['actions.configuration_loader'].call(options)
|
18
|
+
KuberKit::Container['actions.image_compiler'].call(image_names, options)
|
19
|
+
|
20
|
+
logger = KuberKit::Container['tools.logger']
|
21
|
+
logger.info("---------------------------")
|
22
|
+
logger.info("Image compilation finished!")
|
23
|
+
logger.info("---------------------------")
|
24
|
+
end
|
25
|
+
|
26
|
+
desc "env ENV_FILE_NAME", "Return content of Env File ENV_FILE_NAME"
|
27
|
+
def env(env_file_name)
|
28
|
+
KuberKit.set_debug_mode(options[:debug])
|
29
|
+
|
30
|
+
KuberKit::Container['actions.configuration_loader'].call(options)
|
31
|
+
KuberKit::Container['actions.env_file_reader'].call(env_file_name.to_sym, options)
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "template TEMPLATE_NAME", "Return content of Template TEMPLATE_NAME"
|
35
|
+
def template(template_name)
|
36
|
+
KuberKit.set_debug_mode(options[:debug])
|
37
|
+
|
38
|
+
KuberKit::Container['actions.configuration_loader'].call(options)
|
39
|
+
KuberKit::Container['actions.template_reader'].call(template_name.to_sym, options)
|
40
|
+
end
|
41
|
+
|
42
|
+
desc "service SERVICE_NAME", "Return content of Service SERVICE_NAME"
|
43
|
+
def service(service_name)
|
44
|
+
KuberKit.set_debug_mode(options[:debug])
|
45
|
+
|
46
|
+
KuberKit::Container['actions.configuration_loader'].call(options)
|
47
|
+
KuberKit::Container['actions.service_reader'].call(service_name.to_sym, options)
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "apply FILE_PATH", "Apply FILE_PATH with kubectl"
|
51
|
+
def apply(file_path)
|
52
|
+
KuberKit.set_debug_mode(options[:debug])
|
53
|
+
|
54
|
+
KuberKit::Container['actions.configuration_loader'].call(options)
|
55
|
+
KuberKit::Container['actions.kubectl_applier'].call(File.expand_path(file_path), options)
|
56
|
+
end
|
57
|
+
|
58
|
+
desc "deploy CONTEXT_NAME", "Deploy CONTEXT_NAME with kubectl"
|
59
|
+
method_option :services, :type => :array, aliases: ["-s"]
|
60
|
+
method_option :tags, :type => :array, aliases: ["-t"]
|
61
|
+
def deploy
|
62
|
+
KuberKit.set_debug_mode(options[:debug])
|
63
|
+
|
64
|
+
KuberKit::Container['actions.configuration_loader'].call(options)
|
65
|
+
|
66
|
+
KuberKit::Container['actions.service_applier'].call(services: options[:services], tags: options[:tags])
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.exit_on_failure?
|
70
|
+
true
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
class KuberKit::Configs
|
2
|
+
IMAGE_DOCKERFILE_NAME = "Dockerfile".freeze
|
3
|
+
IMAGE_BUILD_CONTEXT_DIR = "build_context".freeze
|
4
|
+
IMAGE_TAG = 'latest'.freeze
|
5
|
+
IMAGE_COMPILE_DIR = "/tmp/kuber_kit/image_builds"
|
6
|
+
DOCKER_IGNORE_LIST = [
|
7
|
+
'Dockerfile',
|
8
|
+
'.DS_Store',
|
9
|
+
'**/.DS_Store',
|
10
|
+
'**/*.log',
|
11
|
+
'node_modules',
|
12
|
+
'.vagrant',
|
13
|
+
'.vscode',
|
14
|
+
'tmp',
|
15
|
+
'logs'
|
16
|
+
]
|
17
|
+
INDOCKER_DIRNAME = "kuber_kit".freeze
|
18
|
+
IMAGES_DIRNAME = "images".freeze
|
19
|
+
INFRA_DIRNAME = "infrastructure".freeze
|
20
|
+
CONFIGURATIONS_DIRNAME = "configurations".freeze
|
21
|
+
ARTIFACT_CLONE_DIR = "/tmp/kuber_kit/artifacts"
|
22
|
+
SERVICE_CONFIG_DIR = "/tmp/kuber_kit/services"
|
23
|
+
|
24
|
+
attr_accessor :image_dockerfile_name, :image_build_context_dir, :image_tag,
|
25
|
+
:docker_ignore_list, :image_compile_dir,
|
26
|
+
:kuber_kit_dirname, :images_dirname, :infra_dirname, :configurations_dirname,
|
27
|
+
:artifact_clone_dir, :service_config_dir
|
28
|
+
|
29
|
+
def initialize
|
30
|
+
@image_dockerfile_name = IMAGE_DOCKERFILE_NAME
|
31
|
+
@image_build_context_dir = IMAGE_BUILD_CONTEXT_DIR
|
32
|
+
@image_tag = IMAGE_TAG
|
33
|
+
@image_compile_dir = IMAGE_COMPILE_DIR
|
34
|
+
@docker_ignore_list = DOCKER_IGNORE_LIST
|
35
|
+
@kuber_kit_dirname = INDOCKER_DIRNAME
|
36
|
+
@images_dirname = IMAGES_DIRNAME
|
37
|
+
@infra_dirname = INFRA_DIRNAME
|
38
|
+
@configurations_dirname = CONFIGURATIONS_DIRNAME
|
39
|
+
@artifact_clone_dir = ARTIFACT_CLONE_DIR
|
40
|
+
@service_config_dir = SERVICE_CONFIG_DIR
|
41
|
+
end
|
42
|
+
end
|