-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from ananace/improve-first-run
Add a wait online class to improve the first-run experience
- Loading branch information
Showing
7 changed files
with
69 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# @summary Creates a dummy exec to allow deferring applies until the Kubernetes API server has started | ||
class k8s::server::wait_online { | ||
# Wait up to 30 seconds for kube-apiserver to start | ||
exec { 'k8s apiserver wait online': | ||
command => 'kubectl --kubeconfig /root/.kube/config version', | ||
path => $facts['path'], | ||
refreshonly => true, | ||
tries => 15, | ||
try_sleep => 2, | ||
} | ||
|
||
# Require possibly managed components before checking online state | ||
Kubeconfig <| title == '/root/.kube/config' |> -> Exec['k8s apiserver wait online'] | ||
K8s::Binary <| title == 'kubectl' |> -> Exec['k8s apiserver wait online'] | ||
Service <| title == 'kube-apiserver' |> ~> Exec['k8s apiserver wait online'] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'spec_helper' | ||
|
||
describe 'k8s::server::wait_online' do | ||
let(:pre_condition) do | ||
<<~PUPPET | ||
function assert_private() {} | ||
include ::k8s | ||
class { '::k8s::server': | ||
manage_etcd => false, | ||
manage_certs => true, | ||
manage_components => false, | ||
manage_resources => false, | ||
node_on_server => false, | ||
} | ||
class { '::k8s::server::apiserver': | ||
etcd_servers => [], | ||
} | ||
PUPPET | ||
end | ||
|
||
on_supported_os.each do |os, os_facts| | ||
context "on #{os}" do | ||
let(:facts) { os_facts } | ||
|
||
it { is_expected.to compile } | ||
|
||
it do | ||
is_expected.to contain_exec('k8s apiserver wait online'). | ||
that_requires('Kubeconfig[/root/.kube/config]'). | ||
that_requires('K8s::Binary[kubectl]'). | ||
that_requires('Service[kube-apiserver]') | ||
end | ||
end | ||
end | ||
end |