Skip to content

Commit

Permalink
Add sleep to ensure cluster is ready
Browse files Browse the repository at this point in the history
add sleep to ensure cluster is ready
  • Loading branch information
KnicKnic authored Jul 28, 2020
1 parent 1a542f3 commit 3e455e6
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 4 deletions.
22 changes: 21 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1633,6 +1633,10 @@ sudo chmod 777 ~/.kube/config
# systemctl status k3s
# sleep 15
cat ~/.kube/config
# this is to ensure that everything settled (there are cases where default service accounts were not yet created)
sleep 4
kubectl get node
`

Expand Down Expand Up @@ -1709,7 +1713,7 @@ logMessage "copying kubeconfig"
copy "~/.kube/k3s.yaml" "~/.kube/config"
foreach ($seconds in 1..120) {
$empty = kubectl get node $env:COMPUTERNAME
$empty = kubectl get node $([Environment]::MachineName)
if($LASTEXITCODE -eq 0)
{
break;
Expand All @@ -1719,11 +1723,27 @@ foreach ($seconds in 1..120) {
logMessage "node exists"
# test for 120 to see if node will go ready
foreach($second in 1..120){
$n = kubectl get node $([Environment]::MachineName) -o json | ConvertFrom-Json
# not sure if there is a better way for testing that it went ready.. but this seems to work
if(($n.status.conditions |?{$_.reason -eq "KubeletReady"} |%{$_.status} )-contains "True"){
break
}
sleep 1;
}
logMessage "node ready"
type $logs_file
kubectl get node
logMessage "done"
# this is to ensure that everything settled (there are cases where default service accounts were not yet created)
sleep 2
`

let windowsShell = 'pwsh'
Expand Down
22 changes: 21 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ sudo chmod 777 ~/.kube/config
# systemctl status k3s
# sleep 15
cat ~/.kube/config
# this is to ensure that everything settled (there are cases where default service accounts were not yet created)
sleep 4
kubectl get node
`

Expand Down Expand Up @@ -121,7 +125,7 @@ logMessage "copying kubeconfig"
copy "~/.kube/k3s.yaml" "~/.kube/config"
foreach ($seconds in 1..120) {
$empty = kubectl get node $env:COMPUTERNAME
$empty = kubectl get node $([Environment]::MachineName)
if($LASTEXITCODE -eq 0)
{
break;
Expand All @@ -131,11 +135,27 @@ foreach ($seconds in 1..120) {
logMessage "node exists"
# test for 120 to see if node will go ready
foreach($second in 1..120){
$n = kubectl get node $([Environment]::MachineName) -o json | ConvertFrom-Json
# not sure if there is a better way for testing that it went ready.. but this seems to work
if(($n.status.conditions |?{$_.reason -eq "KubeletReady"} |%{$_.status} )-contains "True"){
break
}
sleep 1;
}
logMessage "node ready"
type $logs_file
kubectl get node
logMessage "done"
# this is to ensure that everything settled (there are cases where default service accounts were not yet created)
sleep 2
`

let windowsShell = 'pwsh'
Expand Down
4 changes: 4 additions & 0 deletions linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,8 @@ sudo chmod 777 ~/.kube/config
# systemctl status k3s
# sleep 15
cat ~/.kube/config

# this is to ensure that everything settled (there are cases where default service accounts were not yet created)
sleep 4

kubectl get node
20 changes: 18 additions & 2 deletions windows.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ logMessage "copying kubeconfig"
copy "~/.kube/k3s.yaml" "~/.kube/config"

foreach ($seconds in 1..120) {
$empty = kubectl get node $env:COMPUTERNAME
$empty = kubectl get node $([Environment]::MachineName)
if($LASTEXITCODE -eq 0)
{
break;
Expand All @@ -78,8 +78,24 @@ foreach ($seconds in 1..120) {

logMessage "node exists"


# test for 120 to see if node will go ready
foreach($second in 1..120){
$n = kubectl get node $([Environment]::MachineName) -o json | ConvertFrom-Json
# not sure if there is a better way for testing that it went ready.. but this seems to work
if(($n.status.conditions |?{$_.reason -eq "KubeletReady"} |%{$_.status} )-contains "True"){
break
}
sleep 1;
}

logMessage "node ready"

type $logs_file

kubectl get node

logMessage "done"
logMessage "done"

# this is to ensure that everything settled (there are cases where default service accounts were not yet created)
sleep 2

0 comments on commit 3e455e6

Please sign in to comment.