source
stringclasses
1 value
repo
stringlengths
5
63
repo_url
stringlengths
24
82
path
stringlengths
5
167
language
stringclasses
1 value
license
stringclasses
5 values
stars
int64
10
51.4k
ref
stringclasses
23 values
size_bytes
int64
200
258k
text
stringlengths
137
258k
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases.rb
Ruby
apache-2.0
307
master
1,482
# frozen_string_literal: true require 'dry-struct' module Pharos module Phases class Component < Dry::Struct attribute :name, Pharos::Types::String attribute :version, Pharos::Types::String attribute :license, Pharos::Types::String attribute :os_release, Pharos::Configuration::OsRelease....
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phase.rb
Ruby
apache-2.0
307
master
4,566
# frozen_string_literal: true require 'logger' require 'concurrent' module Pharos class Phase using Pharos::CoreExt::Colorize RESOURCE_PATH = Pathname.new(File.expand_path(File.join(__dir__, 'resources'))).freeze # @return [String] def self.title(title = nil) @title = title if title @t...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/autoload.rb
Ruby
apache-2.0
307
master
2,895
# frozen_string_literal: true autoload :Base64, 'base64' autoload :SecureRandom, 'securerandom' autoload :YAML, 'yaml' autoload :JSON, 'json' autoload :Logger, 'logger' autoload :Rouge, 'rouge' autoload :K8s, 'k8s-client' autoload :Excon, 'excon' autoload :Open3, 'open3' autoload :Pathname, 'pathname' autoload :OpenSS...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/version_command.rb
Ruby
apache-2.0
307
master
747
# frozen_string_literal: true module Pharos class VersionCommand < Pharos::Command def execute puts "Kontena Pharos:" puts " - #{File.basename($PROGRAM_NAME)} version #{Pharos.version}" ClusterManager.new(Pharos::Config.new({})).load phases.each do |os, phases| title = (os || 'C...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/command.rb
Ruby
apache-2.0
307
master
2,471
# frozen_string_literal: true require 'pry' if Gem.loaded_specs.key?('pry') module Pharos class Command < Clamp::Command include Pharos::Logging # @param [Array<Symbol>] a list of CommandOption module names in snake_case, for example :filtered_hosts def self.options(*option_names) option_names.ea...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phase_manager.rb
Ruby
apache-2.0
307
master
2,841
# frozen_string_literal: true require_relative 'kube' module Pharos class PhaseManager include Pharos::Logging class Error < Pharos::Error def initialize(errors) @errors = errors end def to_s "Phase failed on #{@errors.size} host#{'s' if @errors.size > 1}:\n#{YAML.dump(@e...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/kubeconfig_command.rb
Ruby
apache-2.0
307
master
1,342
# frozen_string_literal: true module Pharos class KubeconfigCommand < Pharos::Command options :load_config, :tf_json option ['-n', '--name'], 'NAME', 'overwrite cluster name', attribute_name: :new_name option ['-C', '--context'], 'CONTEXT', 'overwrite context name', attribute_name: :new_context opti...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/terraform_command.rb
Ruby
apache-2.0
307
master
374
# frozen_string_literal: true require_relative 'terraform/apply_command' require_relative 'terraform/destroy_command' module Pharos class TerraformCommand < Pharos::Command subcommand "apply", "apply terraform configuration", Pharos::Terraform::ApplyCommand subcommand "destroy", "destroy terraformed infrast...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/config.rb
Ruby
apache-2.0
307
master
4,598
# frozen_string_literal: true require_relative 'types' require_relative 'configuration/host' require_relative 'configuration/api' require_relative 'configuration/network' require_relative 'configuration/etcd' require_relative 'configuration/authentication' require_relative 'configuration/cloud' require_relative 'confi...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/kube.rb
Ruby
apache-2.0
307
master
690
# frozen_string_literal: true module Pharos module Kube def self.init_logging! # rubocop:disable Style/GuardClause if Pharos::Logging.debug? K8s::Logging.debug! K8s::Transport.verbose! end # rubocop:enable Style/GuardClause end # @param host [String] # @param ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/retry.rb
Ruby
apache-2.0
307
master
1,356
# frozen_string_literal: true module Pharos module Retry DEFAULT_RETRY_ERRORS = [ OpenSSL::SSL::SSLError, Excon::Error, K8s::Error ].freeze # @param seconds [Integer] seconds for how long the block will be retried # @param yield_object [Object] object to yield into block # @par...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/reset_command.rb
Ruby
apache-2.0
307
master
1,980
# frozen_string_literal: true module Pharos class ResetCommand < Pharos::Command using Pharos::CoreExt::Colorize options :filtered_hosts, :tf_json, :yes? def execute puts "==> KONTENA PHAROS v#{Pharos.version} (Kubernetes v#{Pharos::KUBE_VERSION})".bright_green Dir.chdir(config_yaml.dirnam...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/logging.rb
Ruby
apache-2.0
307
master
968
# frozen_string_literal: true require 'logger' module Pharos module Logging def self.debug? !!@debug end def self.debug! @debug = true end def self.format_exception(exc, severity = "ERROR") if !ENV['DEBUG'].to_s.empty? || severity == "DEBUG" backtrace = "\n #{exc.b...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/config_schema.rb
Ruby
apache-2.0
307
master
8,906
# frozen_string_literal: true require 'fugit' require 'dry-validation' module Pharos class ConfigSchema DEFAULT_DATA = { 'hosts' => [], 'api' => {}, 'network' => {}, 'authentication' => {}, 'kube_proxy' => {}, 'kubelet' => { 'system_reserved' => { 'cpu' => '50m', 'mem...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/up_command.rb
Ruby
apache-2.0
307
master
3,689
# frozen_string_literal: true module Pharos class UpCommand < Pharos::Command using Pharos::CoreExt::Colorize options :load_config, :tf_json, :yes? option ['-n', '--name'], 'NAME', 'use as cluster name', attribute_name: :new_name option ['-f', '--force'], :flag, "force upgrade" option ['--trust...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/error.rb
Ruby
apache-2.0
307
master
900
# frozen_string_literal: true module Pharos class Error < StandardError; end class InvalidHostError < Error; end class InvalidAddonError < Error; end class ConfigError < Error attr_reader :errors def initialize(errors) @errors = errors end def to_s "Invalid configuration:\n#{YAML...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/transport/transport_file.rb
Ruby
apache-2.0
307
master
3,619
# frozen_string_literal: true require 'shellwords' require 'securerandom' module Pharos module Transport class TransportFile attr_reader :path # Initializes an instance of a remote file # @param [Pharos::Transport::Base] # @param path [String] def initialize(client, path) @...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/transport/base.rb
Ruby
apache-2.0
307
master
3,379
# frozen_string_literal: true require 'monitor' module Pharos module Transport class Base EXPORT_ENVS = { http_proxy: '$http_proxy', https_proxy: '$https_proxy', no_proxy: '$no_proxy', HTTP_PROXY: '$HTTP_PROXY', HTTPS_PROXY: '$HTTPS_PROXY', NO_PROXY: '$NO_PR...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/transport/local.rb
Ruby
apache-2.0
307
master
723
# frozen_string_literal: true module Pharos module Transport class Local < Base def forward(*_args) raise TypeError, "Non-SSH connections do not provide port forwarding" end def close(*_args) raise TypeError, "Non-SSH connections do not provide port forwarding" end ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/transport/interactive_ssh.rb
Ruby
apache-2.0
307
master
1,471
# frozen_string_literal: true require 'io/console' require 'io/wait' module Pharos module Transport class InteractiveSSH attr_reader :client # @param client [Pharos::Transport::SSH] def initialize(client) @client = client end def run $stdin.raw! $stdin.ech...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/transport/ssh.rb
Ruby
apache-2.0
307
master
4,475
# frozen_string_literal: true require 'net/ssh' module Pharos module Transport class SSH < Base attr_reader :session def self.class_mutex @class_mutex ||= Mutex.new end def class_mutex self.class.class_mutex end RETRY_CONNECTION_ERRORS = [ Net::SSH:...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/transport/tempfile.rb
Ruby
apache-2.0
307
master
1,618
# frozen_string_literal: true require 'securerandom' require_relative 'transport_file' module Pharos module Transport # A temporary filename on a host # Optionally uploads given content. # When used with a block, removes the temporary file after execution. class Tempfile < Pharos::Transport::Transpo...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/transport/command/result.rb
Ruby
apache-2.0
307
master
3,301
# frozen_string_literal: true module Pharos module Transport module Command class Result using Pharos::CoreExt::Colorize attr_reader :stdin, :stdout, :stderr, :output, :hostname, :exit_status def self.mutex @mutex ||= Mutex.new end # @param hostname [Str...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/transport/command/ssh.rb
Ruby
apache-2.0
307
master
1,366
# frozen_string_literal: true module Pharos module Transport module Command class SSH < Pharos::Transport::Command::Local attr_reader :cmd, :result def hostname @client.host.to_s end # @return [Pharos::Transport::CommandResult] def run @client.c...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/transport/command/local.rb
Ruby
apache-2.0
307
master
2,346
# frozen_string_literal: true require 'shellwords' module Pharos module Transport module Command class Local attr_reader :cmd, :result # @param client [Pharos::Transport::Local] client instance # @param cmd [String,Array<String>] command to execute # @param stdin [String,I...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/etcd/client.rb
Ruby
apache-2.0
307
master
1,661
# frozen_string_literal: true require 'json' module Pharos module Etcd class Client CURL = 'sudo curl -sSf --connect-timeout 2 --cacert /etc/pharos/pki/ca.pem --cert /etc/pharos/pki/etcd/client.pem --key /etc/pharos/pki/etcd/client-key.pem https://localhost:2379' class Error < StandardError; end ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/host/configurer.rb
Ruby
apache-2.0
307
master
6,127
# frozen_string_literal: true module Pharos module Host class Configurer attr_reader :host SCRIPT_LIBRARY = File.join(__dir__, '..', 'scripts', 'pharos.sh').freeze def self.load_configurers Dir.glob(File.join(__dir__, '**', '*.rb')).each { |f| require(f) } end # @return [...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/host/debian/debian_stretch.rb
Ruby
apache-2.0
307
master
2,584
# frozen_string_literal: true require_relative 'debian' module Pharos module Host class DebianStretch < Debian register_config 'debian', '9' CFSSL_VERSION = '1.2' DOCKER_VERSION = '19.03' CONTAINERD_VERSION = '1.3.7' register_component( name: 'cfssl', version: CFSSL_VERSI...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/host/debian/debian.rb
Ruby
apache-2.0
307
master
1,405
# frozen_string_literal: true module Pharos module Host class Debian < Configurer def install_essentials exec_script( 'configure-essentials.sh' ) end def configure_netfilter exec_script('configure-netfilter.sh') end def configure_cfssl exe...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/host/el7/el7.rb
Ruby
apache-2.0
307
master
3,798
# frozen_string_literal: true module Pharos module Host class El7 < Configurer DOCKER_VERSION = '19.03.8' CONTAINERD_VERSION = '1.3.7' CFSSL_VERSION = '1.2' # @param path [Array] # @return [String] def script_path(*path) File.join(__dir__, 'scripts', *path) end ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/host/el7/rhel7.rb
Ruby
apache-2.0
307
master
648
# frozen_string_literal: true require_relative 'el7' module Pharos module Host class Rhel7 < El7 register_config 'rhel', '7.4' register_config 'rhel', '7.5' register_config 'rhel', '7.6' register_config 'rhel', '7.7' register_config 'rhel', '7.8' register_component( ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/host/el7/centos7.rb
Ruby
apache-2.0
307
master
506
# frozen_string_literal: true require_relative 'el7' module Pharos module Host class Centos7 < El7 register_config 'centos', '7' register_component( name: 'docker', version: DOCKER_VERSION, license: 'Apache License 2.0', enabled: proc { |c| c.hosts.any? { |h| h.container_runtime == ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/host/ubuntu/ubuntu_bionic.rb
Ruby
apache-2.0
307
master
1,425
# frozen_string_literal: true require_relative 'ubuntu' module Pharos module Host class UbuntuBionic < Ubuntu register_config 'ubuntu', '18.04' register_component( name: 'docker', version: DOCKER_VERSION, license: 'Apache License 2.0', enabled: proc { |c| c.hosts.any? { |h| h.contai...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/host/ubuntu/ubuntu.rb
Ruby
apache-2.0
307
master
2,712
# frozen_string_literal: true module Pharos module Host class Ubuntu < Configurer DOCKER_VERSION = '19.03' CONTAINERD_VERSION = '1.3.7' CFSSL_VERSION = '1.4' def install_essentials exec_script('configure-essentials.sh') end def configure_netfilter exec_script...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/host/ubuntu/ubuntu_focal.rb
Ruby
apache-2.0
307
master
1,424
# frozen_string_literal: true require_relative 'ubuntu' module Pharos module Host class UbuntuFocal < Ubuntu register_config 'ubuntu', '20.04' register_component( name: 'docker', version: DOCKER_VERSION, license: 'Apache License 2.0', enabled: proc { |c| c.hosts.any? { |h| h.contain...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/host/ubuntu/ubuntu_xenial.rb
Ruby
apache-2.0
307
master
1,926
# frozen_string_literal: true require_relative 'ubuntu' module Pharos module Host class UbuntuXenial < Ubuntu register_config 'ubuntu', '16.04' register_component( name: 'docker', version: DOCKER_VERSION, license: 'Apache License 2.0', enabled: proc { |c| c.hosts.any? { |h| h.contai...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/command_options/yes.rb
Ruby
apache-2.0
307
master
689
# frozen_string_literal: true module Pharos module CommandOptions module Yes def self.included(base) base.prepend(InstanceMethods) base.option ['-y', '--yes'], :flag, 'answer automatically yes to prompts' end module InstanceMethods def confirm_yes!(message, default: tru...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/command_options/load_config.rb
Ruby
apache-2.0
307
master
2,472
# frozen_string_literal: true module Pharos module CommandOptions module LoadConfig using Pharos::CoreExt::Colorize def self.included(base) base.prepend(InstanceMethods) base.option ['-c', '--config'], 'PATH', 'path to config file (default: cluster.yml)', attribute_name: :config_yaml...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/command_options/filtered_hosts.rb
Ruby
apache-2.0
307
master
1,458
# frozen_string_literal: true module Pharos module CommandOptions module FilteredHosts def self.included(base) base.prepend(InstanceMethods) base.options :load_config base.option ['-r', '--role'], 'ROLE', 'select a host by role' base.option ['-l', '--label'], 'LABEL=VALUE', ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/command_options/tf_json.rb
Ruby
apache-2.0
307
master
1,920
# frozen_string_literal: true module Pharos module CommandOptions module TfJson using Pharos::CoreExt::Colorize using K8s::Util::HashDeepMerge def self.included(base) base.prepend(InstanceMethods) base.option '--tf-json', 'PATH', 'path to terraform output json' do |config_path...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/kube/stack.rb
Ruby
apache-2.0
307
master
1,050
# frozen_string_literal: true require 'k8s-client' module Pharos module Kube class Stack < K8s::Stack # custom labels LABEL = 'pharos.kontena.io/stack' CHECKSUM_ANNOTATION = 'pharos.kontena.io/stack-checksum' # Load stack with resources from path containing erb-templated YAML files ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/kube/config.rb
Ruby
apache-2.0
307
master
3,432
# frozen_string_literal: true require 'pharos/yaml_file' module Pharos module Kube # Loads and manipulates kubeconfig files class Config InvalidConfigError = Class.new(Pharos::Error) # @param content [String] configuration content def initialize(content = nil) @content = content ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/yaml_file/namespace.rb
Ruby
apache-2.0
307
master
319
# frozen_string_literal: true module Pharos class YamlFile class Namespace def initialize(variables) variables.each do |key, value| singleton_class.send(:define_method, key) { value } end end def with_binding(&block) yield binding end end end end
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/core-ext/string_casing.rb
Ruby
apache-2.0
307
master
1,187
# frozen_string_literal: true module Pharos module CoreExt module StringCasing def underscore return self if empty? result = gsub(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2') result.gsub!(/([a-z\d])([A-Z])/, '\1_\2') result.tr!('-', '_') result.gsub!(/\s+/, '_') resul...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/core-ext/colorize.rb
Ruby
apache-2.0
307
master
581
# frozen_string_literal: true require 'pastel' module Pharos module CoreExt module Colorize def self.pastel @pastel ||= Pastel.new(enabled: true) end def self.disable! @pastel = Pastel.new(enabled: false) end def self.enabled? pastel.enabled? end ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/core-ext/deep_transform_keys.rb
Ruby
apache-2.0
307
master
1,549
# frozen_string_literal: true module Pharos module CoreExt module DeepTransformKeys using Pharos::CoreExt::StringCasing def self.deep_transform_keys(value = nil, &block) case value when Array value.map { |v| deep_transform_keys(v, &block) } when Hash value...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/cloud/pharos.rb
Ruby
apache-2.0
307
master
206
# frozen_string_literal: true require_relative "provider" module Pharos module Cloud class PharosCloud < Provider register_as :pharos def csi? false end end end end
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/cloud/hcloud.rb
Ruby
apache-2.0
307
master
349
# frozen_string_literal: true require_relative "provider" module Pharos module Cloud class HCloud < Provider register_as :hcloud # @return [Hash] def feature_gates { 'CSINodeInfo' => true, 'CSIDriverRegistry' => true } end def csi? true...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/cloud/provider.rb
Ruby
apache-2.0
307
master
415
# frozen_string_literal: true require_relative "provider_registry" module Pharos module Cloud class Provider # @param name [String] def self.register_as(name) Pharos::Cloud::ProviderRegistry.instance.register_as(name, self) end # @return [Hash] def feature_gates {}...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/cloud/provider_registry.rb
Ruby
apache-2.0
307
master
678
# frozen_string_literal: true require "singleton" module Pharos module Cloud class ProviderRegistry include Singleton def initialize @registry = {} end # @param provider_name [String,Symbol] # @return [Pharos::Cloud::Provider] def provider(provider_name) (@r...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/cloud/packet.rb
Ruby
apache-2.0
307
master
201
# frozen_string_literal: true require_relative "provider" module Pharos module Cloud class Packet < Provider register_as :packet def csi? false end end end end
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/terraform/base_command.rb
Ruby
apache-2.0
307
master
1,405
# frozen_string_literal: true require 'open3' module Pharos module Terraform class BaseCommand < Pharos::Command options :yes? option "--workspace", "NAME", "terraform workspace", default: "default" option "--var", "VAR", "set a variable in the terraform configuration.", multivalued: true ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/terraform/json_parser.rb
Ruby
apache-2.0
307
master
567
# frozen_string_literal: true require 'json' module Pharos module Terraform class ParserError < Pharos::Error; end class JsonParser # @param json [String] def initialize(json) @json = json end def data @data ||= JSON.parse(@json) rescue JSON::ParserError => ex...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/terraform/destroy_command.rb
Ruby
apache-2.0
307
master
593
# frozen_string_literal: true require_relative 'base_command' module Pharos module Terraform class DestroyCommand < BaseCommand def execute tf_workspace tf_destroy end def tf_destroy cmd = ["terraform", "destroy"] cmd += common_tf_options run_cmd!(cmd....
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/terraform/apply_command.rb
Ruby
apache-2.0
307
master
985
# frozen_string_literal: true require_relative 'base_command' module Pharos module Terraform class ApplyCommand < BaseCommand options :load_config option ['-f', '--force'], :flag, "force upgrade" option ['--trust-hosts'], :flag, "removes addresses from ~/.ssh/known_hosts before connecting" ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/terraform/legacy_json_parser.rb
Ruby
apache-2.0
307
master
2,337
# frozen_string_literal: true require 'json' require_relative 'json_parser' module Pharos module Terraform class LegacyJsonParser # @param json [String] def initialize(json) @json = json end def data @data ||= JSON.parse(@json) rescue JSON::ParserError => ex ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/reset_host.rb
Ruby
apache-2.0
307
master
265
# frozen_string_literal: true module Pharos module Phases class ResetHost < Pharos::Phase title "Reset hosts" def call logger.info { "Removing all traces of Kontena Pharos ..." } host_configurer.reset end end end end
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/configure_metrics.rb
Ruby
apache-2.0
307
master
859
# frozen_string_literal: true module Pharos module Phases class ConfigureMetrics < Pharos::Phase title "Configure metrics" METRICS_SERVER_VERSION = '0.3.2' register_component( name: 'metrics-server', version: METRICS_SERVER_VERSION, license: 'Apache License 2.0' ) def cal...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/connect_ssh.rb
Ruby
apache-2.0
307
master
368
# frozen_string_literal: true module Pharos module Phases class ConnectSSH < Pharos::Phase title "Open SSH connection" def call Retry.perform(60, logger: logger, exceptions: [Net::SSH::Disconnect, Net::SSH::Timeout, Net::SSH::ConnectionTimeout, Errno::EHOSTDOWN]) do host.transport....
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/validate_configuration_changes.rb
Ruby
apache-2.0
307
master
907
# frozen_string_literal: true module Pharos module Phases class ValidateConfigurationChanges < Pharos::Phase title "Validate configuration changes" DEFAULT_PROC = proc { |key, old_val, new_val| raise Pharos::ConfigError, key => "can't change #{key} from #{old_val} to #{new_val}" } def call ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/label_node.rb
Ruby
apache-2.0
307
master
903
# frozen_string_literal: true module Pharos module Phases class LabelNode < Pharos::Phase title "Configure node labels and taints" def call @config.hosts.each do |host| kube_nodes.update_resource( find_node(host).merge(host_patch_data(host)) ) end ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/configure_calico.rb
Ruby
apache-2.0
307
master
2,663
# frozen_string_literal: true module Pharos module Phases class ConfigureCalico < Pharos::Phase title "Configure Calico network" CALICO_VERSION = '3.12.2' register_component( name: 'calico-node', version: CALICO_VERSION, license: 'Apache License 2.0', enabled: proc { |c| c.net...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/join_node.rb
Ruby
apache-2.0
307
master
661
# frozen_string_literal: true module Pharos module Phases class JoinNode < Pharos::Phase title "Join nodes" def already_joined? transport.file("/etc/kubernetes/kubelet.conf").exist? end def call if already_joined? logger.info { "Already joined ..." } r...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/configure_dns.rb
Ruby
apache-2.0
307
master
3,954
# frozen_string_literal: true module Pharos module Phases class ConfigureDNS < Pharos::Phase DNS_CACHE_STACK_NAME = 'node_local_dns' title "Configure DNS" register_component( name: 'coredns', version: Pharos::COREDNS_VERSION, license: 'Apache License 2.0' ) register_compo...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/drain.rb
Ruby
apache-2.0
307
master
452
# frozen_string_literal: true module Pharos module Phases class Drain < Pharos::Phase title "Drain node" def call logger.info { "draining ..." } master_host.transport.exec!("kubectl drain --grace-period=120 --force --timeout=5m --ignore-daemonsets --delete-local-data #{@host.hostname...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/configure_kubelet_csr_approver.rb
Ruby
apache-2.0
307
master
540
# frozen_string_literal: true module Pharos module Phases class ConfigureKubeletCsrApprover < Pharos::Phase title "Configure kubelet csr auto-approver" RUBBER_STAMP_VERSION = '0.3.1' register_component( name: 'kubelet-rubber-stamp', version: RUBBER_STAMP_VERSION, license: 'Apache Lice...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/validate_host.rb
Ruby
apache-2.0
307
master
3,626
# frozen_string_literal: true module Pharos module Phases class ValidateHost < Pharos::Phase title "Validate hosts" def call logger.info { "Validating current role matches ..." } check_role logger.info { "Validating distro and version ..." } check_distro_version ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/configure_psp.rb
Ruby
apache-2.0
307
master
359
# frozen_string_literal: true require_relative 'mixins/psp' module Pharos module Phases class ConfigurePSP < Pharos::Phase include Pharos::Phases::Mixins::PSP title "Configure pod security policies" def call logger.info { "Configuring default pod security policies ..." } apply...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/configure_etcd_ca.rb
Ruby
apache-2.0
307
master
764
# frozen_string_literal: true module Pharos module Phases class ConfigureEtcdCa < Pharos::Phase title "Configure etcd certificate authority" CA_PATH = '/etc/pharos/pki' CA_FILES = %w(ca.pem ca-key.pem).freeze def call logger.info { 'Configuring etcd certificate authority ...' } ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/pull_master_images.rb
Ruby
apache-2.0
307
master
552
# frozen_string_literal: true module Pharos module Phases class PullMasterImages < Pharos::Phase title "Pull control plane images" def call logger.info { "Pulling control plane images ..." } cfg = kubeadm.generate_yaml_config transport.tempfile(content: cfg, prefix: "kubeadm....
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/configure_etcd.rb
Ruby
apache-2.0
307
master
2,767
# frozen_string_literal: true module Pharos module Phases class ConfigureEtcd < Pharos::Phase title 'Configure etcd' CA_PATH = '/etc/pharos/pki' register_component( name: 'etcd', version: Pharos::ETCD_VERSION, license: 'Apache License 2.0', enabled: proc { |c| !c.etcd&.endpoint...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/reconfigure_kubelet.rb
Ruby
apache-2.0
307
master
831
# frozen_string_literal: true module Pharos module Phases class ReconfigureKubelet < Pharos::Phase title "Reconfigure kubelet" def call return if host.new? logger.info { 'Reconfiguring kubelet ...' } reconfigure_kubelet end def reconfigure_kubelet config...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/configure_helm_controller.rb
Ruby
apache-2.0
307
master
739
# frozen_string_literal: true module Pharos module Phases class ConfigureHelmController < Pharos::Phase title "Configure Helm Controller" HELM_CONTROLLER_VERSION = '0.4.1' register_component( name: 'helm-controller', version: HELM_CONTROLLER_VERSION, license: 'Apache License 2.0' ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/configure_cloud_provider.rb
Ruby
apache-2.0
307
master
1,105
# frozen_string_literal: true module Pharos module Phases class ConfigureCloudProvider < Pharos::Phase title "Configure cloud provider" def call unless @config.cloud&.provider logger.info "Cloud provider not set, skipping." return end if @config.cloud.int...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/configure_host.rb
Ruby
apache-2.0
307
master
3,233
# frozen_string_literal: true module Pharos module Phases class ConfigureHost < Pharos::Phase title "Configure hosts" ROLLOUT_PERCENTAGE = 10 def call unless @host.environment.nil? || @host.environment.empty? logger.info "Updating environment file ..." host_configu...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/delete_host.rb
Ruby
apache-2.0
307
master
410
# frozen_string_literal: true module Pharos module Phases class DeleteHost < Pharos::Phase title "Delete node" def call logger.info { "deleting node from kubernetes api ..." } master_host.transport.exec!("kubectl delete node #{@host.hostname}") rescue Pharos::ExecError => ex ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/configure_secrets_encryption.rb
Ruby
apache-2.0
307
master
1,859
# frozen_string_literal: true require "base64" module Pharos module Phases class ConfigureSecretsEncryption < Pharos::Phase title "Configure secrets encryption" PHAROS_DIR = '/etc/pharos' SECRETS_CFG_DIR = (PHAROS_DIR + '/secrets-encryption').freeze SECRETS_CFG_FILE = (SECRETS_CFG_DIR +...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/configure_weave.rb
Ruby
apache-2.0
307
master
4,201
# frozen_string_literal: true module Pharos module Phases class ConfigureWeave < Pharos::Phase title "Configure Weave network" WEAVE_VERSION = '2.6.5' WEAVE_FLYING_SHUTTLE_VERSION = '0.3.2' register_component( name: 'weave-net', version: WEAVE_VERSION, license: 'Apache License 2...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/configure_kubelet.rb
Ruby
apache-2.0
307
master
4,477
# frozen_string_literal: true module Pharos module Phases class ConfigureKubelet < Pharos::Phase title "Configure kubelet" register_component( name: 'kubernetes', version: Pharos::KUBE_VERSION, license: 'Apache License 2.0' ) register_component( name: 'kubernetes-cni', v...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/configure_priority_classes.rb
Ruby
apache-2.0
307
master
237
# frozen_string_literal: true module Pharos module Phases class ConfigurePriorityClasses < Pharos::Phase title "Configure priority classes" def call apply_stack('priority_classes') end end end end
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/gather_facts.rb
Ruby
apache-2.0
307
master
4,484
# frozen_string_literal: true require 'ipaddr' module Pharos module Phases class GatherFacts < Pharos::Phase title "Gather host facts" FULL_HOSTNAME_CLOUD_PROVIDERS = %w(aws vsphere).freeze def call logger.info { "Checking sudo access ..." } check_sudo logger.info { "...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/upgrade_master.rb
Ruby
apache-2.0
307
master
2,091
# frozen_string_literal: true require_relative 'mixins/psp' module Pharos module Phases class UpgradeMaster < Pharos::Phase include Pharos::Phases::Mixins::PSP title "Upgrade master" def kubeadm Pharos::Kubeadm::ConfigGenerator.new(@config, @host) end def upgrade? ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/configure_client.rb
Ruby
apache-2.0
307
master
1,380
# frozen_string_literal: true module Pharos module Phases class ConfigureClient < Pharos::Phase title "Configure kube client" REMOTE_FILE = "/etc/kubernetes/admin.conf" def call return unless kubeconfig? if host.local? cluster_context['kube_client'] = Pharos::Kube.c...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/configure_cfssl.rb
Ruby
apache-2.0
307
master
263
# frozen_string_literal: true module Pharos module Phases class ConfigureCfssl < Pharos::Phase title "Configure cfssl" def call logger.info { 'Installing cfssl ...' } host_configurer.configure_cfssl end end end end
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/migrate_master.rb
Ruby
apache-2.0
307
master
582
# frozen_string_literal: true require_relative 'mixins/cluster_version' module Pharos module Phases class MigrateMaster < Pharos::Phase include Pharos::Phases::Mixins::ClusterVersion title "Migrate master" def call if existing_version < build_version('2.4.0-alpha.0') migrat...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/configure_etcd_changes.rb
Ruby
apache-2.0
307
master
2,201
# frozen_string_literal: true require 'json' module Pharos module Phases class ConfigureEtcdChanges < Pharos::Phase title 'Configure etcd member changes' def call store_initial_cluster_state return if initial_cluster_state != 'existing' || !etcd.healthy? removed = remove_o...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/load_cluster_configuration.rb
Ruby
apache-2.0
307
master
2,432
# frozen_string_literal: true module Pharos module Phases class LoadClusterConfiguration < Pharos::Phase title "Load cluster configuration" def call return unless kube_client? logger.info { "Loading cluster configuration configmap ..." } pharos_config_map = pharos_config_co...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/apply_manifests.rb
Ruby
apache-2.0
307
master
1,332
# frozen_string_literal: true module Pharos module Phases class ApplyManifests < Pharos::Phase title "Apply configured kubernetes manifests" def call manifest_paths = config.manifests.to_a logger.info "Applying configured manifests: " manifest_paths.each do |path| l...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/configure_cluster_name.rb
Ruby
apache-2.0
307
master
2,883
# frozen_string_literal: true module Pharos module Phases class ConfigureClusterName < Pharos::Phase using Pharos::CoreExt::Colorize title "Configure cluster name" ADJECTIVES = %w( autumn hidden bitter misty silent empty dry dark summer icy delicate quiet white cool spring win...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/validate_version.rb
Ruby
apache-2.0
307
master
1,817
# frozen_string_literal: true require_relative "mixins/cluster_version" module Pharos module Phases class ValidateVersion < Pharos::Phase title "Validate cluster version" include Pharos::Phases::Mixins::ClusterVersion def call return unless cluster_context['previous-config-map'] ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/configure_firewalld.rb
Ruby
apache-2.0
307
master
3,299
# frozen_string_literal: true module Pharos module Phases class ConfigureFirewalld < Pharos::Phase title "Configure firewalld" def call if @config.network&.firewalld&.enabled configure_firewalld else disable_firewalld end end def configure_fir...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/configure_master.rb
Ruby
apache-2.0
307
master
5,721
# frozen_string_literal: true module Pharos module Phases class ConfigureMaster < Pharos::Phase title "Configure master" KUBE_DIR = '/etc/kubernetes' SHARED_CERT_FILES = %w(ca.crt ca.key sa.key sa.pub front-proxy-ca.key front-proxy-ca.crt).freeze APISERVER_CERT = '/etc/kubernetes/pki/api...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/configure_bootstrap.rb
Ruby
apache-2.0
307
master
596
# frozen_string_literal: true module Pharos module Phases class ConfigureBootstrap < Pharos::Phase title "Configure bootstrap tokens" def call if new_hosts? logger.info { "Creating node bootstrap token ..." } cluster_context['join-command'] = transport.exec!("sudo kubeadm...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/setup_master.rb
Ruby
apache-2.0
307
master
3,742
# frozen_string_literal: true module Pharos module Phases class SetupMaster < Pharos::Phase title "Setup master configuration files" def kubeadm Pharos::Kubeadm::ConfigGenerator.new(@config, @host) end def call push_external_etcd_certs if @config.etcd&.certificate ...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/configure_custom_network.rb
Ruby
apache-2.0
307
master
606
# frozen_string_literal: true module Pharos module Phases class ConfigureCustomNetwork < Pharos::Phase title "Configure Custom network" def call logger.info { "Configuring custom network ..." } stack = Pharos::Kube.stack( 'custom-network', @config.network.custom.m...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/upgrade_check.rb
Ruby
apache-2.0
307
master
1,348
# frozen_string_literal: true module Pharos module Phases class UpgradeCheck < Pharos::Phase title "Check for Pharos upgrade" VERSION_URL = ENV["PHAROS_UPGRADE_CHECK_URL"] || 'https://get.pharos.sh/versions/latest' def call logger.info 'Checking for a new version ...' check_ve...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/store_cluster_configuration.rb
Ruby
apache-2.0
307
master
1,205
# frozen_string_literal: true module Pharos module Phases class StoreClusterConfiguration < Pharos::Phase using Pharos::CoreExt::DeepTransformKeys title "Store cluster configuration" def call logger.info { "Storing cluster configuration to configmap ..." } ensure_resource(reso...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/mixins/psp.rb
Ruby
apache-2.0
307
master
286
# frozen_string_literal: true module Pharos module Phases module Mixins module PSP def apply_psp_stack apply_stack( 'psp', default_psp: @config.pod_security_policy.default_policy ) end end end end end
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/phases/mixins/cluster_version.rb
Ruby
apache-2.0
307
master
692
# frozen_string_literal: true module Pharos module Phases module Mixins module ClusterVersion # @return [Gem::Version] def existing_version if cluster_version = cluster_context['existing-pharos-version'] build_version(cluster_version) else build_v...
github
kontena/pharos-cluster
https://github.com/kontena/pharos-cluster
lib/pharos/kubeadm/kubeproxy_config.rb
Ruby
apache-2.0
307
master
708
# frozen_string_literal: true module Pharos module Kubeadm class KubeProxyConfig # @param config [Pharos::Config] cluster config # @param host [Pharos::Configuration::Host] master host-specific config def initialize(config, host) @config = config @host = host end # ...