Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop phase master: parameter #1028

Merged
merged 4 commits into from
Jan 30, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 20 additions & 19 deletions lib/pharos/cluster_manager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,23 +60,24 @@ def gather_facts
apply_phase(Phases::ConnectSSH, config.hosts, parallel: true)
apply_phase(Phases::AuthenticateSSH, config.hosts.reject(&:ssh?), parallel: false)
apply_phase(Phases::GatherFacts, config.hosts, parallel: true)
apply_phase(Phases::ConfigureClient, [config.master_host], master: config.master_host, parallel: false, optional: true)
apply_phase(Phases::ConfigureClient, [config.master_host], parallel: false, optional: true)
end

def validate
apply_phase(Phases::UpgradeCheck, %w(localhost))
addon_manager.validate
gather_facts
apply_phase(Phases::ValidateHost, config.hosts, parallel: true)
apply_phase(Phases::ValidateVersion, [config.master_host], master: config.master_host, parallel: false)
apply_phase(Phases::ValidateVersion, [config.master_host], parallel: false)
end

def apply_phases
master_hosts = config.master_hosts
master_only = [config.master_host]
apply_phase(Phases::MigrateMaster, master_hosts, parallel: true)
apply_phase(Phases::ConfigureHost, config.hosts, master: master_hosts.first, parallel: true)
apply_phase(Phases::ConfigureHost, config.hosts, parallel: true)
apply_phase(Phases::ConfigureFirewalld, config.hosts, parallel: true)
apply_phase(Phases::ConfigureClient, [master_hosts.first], master: master_hosts.first, parallel: false, optional: true)
apply_phase(Phases::ConfigureClient, master_only, parallel: false, optional: true)

unless @config.etcd&.endpoints
etcd_hosts = config.etcd_hosts
Expand All @@ -88,40 +89,40 @@ def apply_phases

apply_phase(Phases::ConfigureSecretsEncryption, master_hosts, parallel: false)
apply_phase(Phases::SetupMaster, master_hosts, parallel: true)
apply_phase(Phases::UpgradeMaster, master_hosts, master: master_hosts.first, parallel: false) # requires optional early ConfigureClient
apply_phase(Phases::UpgradeMaster, master_hosts, parallel: false) # requires optional early ConfigureClient

apply_phase(Phases::MigrateWorker, config.worker_hosts, parallel: true, master: master_hosts.first)
apply_phase(Phases::MigrateWorker, config.worker_hosts, parallel: true)
apply_phase(Phases::ConfigureKubelet, config.hosts, parallel: true)

apply_phase(Phases::PullMasterImages, master_hosts, parallel: true)
apply_phase(Phases::ConfigureMaster, master_hosts, parallel: false)
apply_phase(Phases::ConfigureClient, [master_hosts.first], master: master_hosts.first, parallel: false)
apply_phase(Phases::ConfigureClient, master_only, parallel: false)

# master is now configured and can be used
apply_phase(Phases::LoadClusterConfiguration, [master_hosts.first], master: master_hosts.first)
apply_phase(Phases::LoadClusterConfiguration, master_only)
# configure essential services
apply_phase(Phases::ConfigurePSP, [master_hosts.first], master: master_hosts.first)
apply_phase(Phases::ConfigureDNS, [master_hosts.first], master: master_hosts.first)
apply_phase(Phases::ConfigureWeave, [master_hosts.first], master: master_hosts.first) if config.network.provider == 'weave'
apply_phase(Phases::ConfigureCalico, [master_hosts.first], master: master_hosts.first) if config.network.provider == 'calico'
apply_phase(Phases::ConfigureCustomNetwork, [master_hosts.first], master: master_hosts.first) if config.network.provider == 'custom'
apply_phase(Phases::ConfigurePSP, master_only)
apply_phase(Phases::ConfigureDNS, master_only)
apply_phase(Phases::ConfigureWeave, master_only) if config.network.provider == 'weave'
apply_phase(Phases::ConfigureCalico, master_only) if config.network.provider == 'calico'
apply_phase(Phases::ConfigureCustomNetwork, master_only) if config.network.provider == 'custom'

apply_phase(Phases::ConfigureBootstrap, [master_hosts.first]) # using `kubeadm token`, not the kube API
apply_phase(Phases::ConfigureBootstrap, master_only) # using `kubeadm token`, not the kube API

apply_phase(Phases::JoinNode, config.worker_hosts, parallel: true)
apply_phase(Phases::LabelNode, config.hosts, master: master_hosts.first, parallel: false) # NOTE: uses the @master kube API for each node, not threadsafe
apply_phase(Phases::LabelNode, config.hosts, parallel: false) # NOTE: uses the @master kube API for each node, not threadsafe

# configure services that need workers
apply_phase(Phases::ConfigureMetrics, [master_hosts.first], master: master_hosts.first)
apply_phase(Phases::ConfigureTelemetry, [master_hosts.first], master: master_hosts.first)
apply_phase(Phases::ConfigureMetrics, master_only)
apply_phase(Phases::ConfigureTelemetry, master_only)
end

# @param hosts [Array<Pharos::Configuration::Host>]
def apply_reset_hosts(hosts)
master_hosts = config.master_hosts
if master_hosts.first.master_sort_score.zero?
apply_phase(Phases::Drain, hosts, parallel: false)
apply_phase(Phases::DeleteHost, hosts, parallel: false, master: master_hosts.first)
apply_phase(Phases::DeleteHost, hosts, parallel: false)
end
addon_manager.each do |addon|
next unless addon.enabled?
Expand Down Expand Up @@ -168,7 +169,7 @@ def post_install_messages

def save_config
master_host = config.master_host
apply_phase(Phases::StoreClusterConfiguration, [master_host], master: master_host)
apply_phase(Phases::StoreClusterConfiguration, [master_host])
end

def disconnect
Expand Down
4 changes: 1 addition & 3 deletions lib/pharos/phase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@ def self.register_component(component)

# @param host [Pharos::Configuration::Host]
# @param config [Pharos::Config]
# @param master [Pharos::Configuration::Host]
def initialize(host, config: nil, master: nil, cluster_context: nil)
def initialize(host, config: nil, cluster_context: nil)
@host = host
@config = config
@master = master
@cluster_context = cluster_context
end

Expand Down
6 changes: 1 addition & 5 deletions non-oss/pharos_pro/phases/configure_host.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,8 @@ def drain_host!
master_ssh.exec!("kubectl drain --force --grace-period=0 --ignore-daemonsets --delete-local-data #{@host.hostname}")
end

def master_ssh
@master.ssh
end

def master_healthy?
@master.master_sort_score.zero?
@config.master_host.master_sort_score.zero?
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/pharos/phases/configure_calico_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
kubelet: {read_only_port: false}
) }

subject { described_class.new(host, config: config, master: host) }
subject { described_class.new(host, config: config) }

describe '#get_ippool' do
let(:kube_client) { instance_double(K8s::Client) }
Expand Down
2 changes: 1 addition & 1 deletion spec/pharos/phases/configure_dns_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
allow(master).to receive(:cpu_arch).and_return(cpu_arch)
end

subject { described_class.new(master, config: config, master: master) }
subject { described_class.new(master, config: config) }

describe '#call' do
context "with one host" do
Expand Down
2 changes: 1 addition & 1 deletion spec/pharos/phases/label_node_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
describe Pharos::Phases::LabelNode do
let(:master) { Pharos::Configuration::Host.new(address: '192.0.2.1') }
let(:host) { Pharos::Configuration::Host.new(address: '192.0.2.2', labels: { foo: 'bar' } ) }
let(:subject) { described_class.new(host, master: master) }
let(:subject) { described_class.new(host) }

let(:kube_client) { instance_double(K8s::Client) }
let(:kube_api_v1) { instance_double(K8s::APIClient) }
Expand Down