mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 05:03:09 +00:00
Merge pull request #125119 from mauriciopoppe/fix-npd-envvars
Create NPD kubeconfig conditionally if the installation mode is standalone
This commit is contained in:
commit
a06568062c
@ -258,6 +258,7 @@ function prepare-node-upgrade() {
|
||||
KUBE_PROXY_TOKEN=$(get-env-val "${node_env}" "KUBE_PROXY_TOKEN")
|
||||
export KUBE_PROXY_TOKEN
|
||||
NODE_PROBLEM_DETECTOR_TOKEN=$(get-env-val "${node_env}" "NODE_PROBLEM_DETECTOR_TOKEN")
|
||||
export NODE_PROBLEM_DETECTOR_TOKEN
|
||||
CA_CERT_BASE64=$(get-env-val "${node_env}" "CA_CERT")
|
||||
export CA_CERT_BASE64
|
||||
EXTRA_DOCKER_OPTS=$(get-env-val "${node_env}" "EXTRA_DOCKER_OPTS")
|
||||
|
@ -1130,7 +1130,7 @@ function Verify-WorkerServices {
|
||||
$timeout = 12
|
||||
$retries = 0
|
||||
$retryDelayInSeconds = 5
|
||||
|
||||
|
||||
Log-Output ("Testing node connection to API server...")
|
||||
do {
|
||||
$retries++
|
||||
@ -1138,17 +1138,17 @@ function Verify-WorkerServices {
|
||||
$host_status = & "${env:NODE_DIR}\kubectl.exe" get nodes (hostname) -o=custom-columns=:.status.conditions[4].type | Out-String
|
||||
Start-Sleep $retryDelayInSeconds
|
||||
} while (((-Not $nodes_list) -or (-Not $nodes_list.contains((hostname))) -or (-Not $host_status.contains("Ready")))-and ($retries -le $timeout))
|
||||
|
||||
|
||||
If (-Not $nodes_list){
|
||||
Throw ("Node: '$(hostname)' failed to connect to API server")
|
||||
|
||||
|
||||
}ElseIf (-Not $nodes_list.contains((hostname))) {
|
||||
Throw ("Node: '$(hostname)' failed to join the cluster; NODES: '`n $($nodes_list)'")
|
||||
|
||||
}ELseIf (-Not $host_status.contains("Ready")) {
|
||||
Throw ("Node: '$(hostname)' is not in Ready state")
|
||||
}
|
||||
|
||||
|
||||
Log-Output ("Node: $(hostname) successfully joined cluster `n NODES: `n $($nodes_list)")
|
||||
Verify_GceMetadataServerRouteIsPresent
|
||||
|
||||
@ -1543,10 +1543,21 @@ function DownloadAndInstall-NodeProblemDetector {
|
||||
# CA_CERT
|
||||
# NODE_PROBLEM_DETECTOR_TOKEN
|
||||
function Create-NodeProblemDetectorKubeConfig {
|
||||
if (-not [string]::IsNullOrEmpty(${env:NODEPROBLEMDETECTOR_KUBECONFIG_FILE})) {
|
||||
Create-Kubeconfig -Name 'node-problem-detector' `
|
||||
-Path ${env:NODEPROBLEMDETECTOR_KUBECONFIG_FILE} `
|
||||
-Token ${kube_env}['NODE_PROBLEM_DETECTOR_TOKEN']
|
||||
if ("${env:ENABLE_NODE_PROBLEM_DETECTOR}" -eq "standalone") {
|
||||
if (-not [string]::IsNullOrEmpty(${kube_env]['NODE_PROBLEM_DETECTOR_TOKEN']})) {
|
||||
Log-Output "Create-NodeProblemDetectorKubeConfig using Node Problem Detector token"
|
||||
Create-Kubeconfig -Name 'node-problem-detector' `
|
||||
-Path ${env:NODEPROBLEMDETECTOR_KUBECONFIG_FILE} `
|
||||
-Token ${kube_env}['NODE_PROBLEM_DETECTOR_TOKEN']
|
||||
} elseif (Test-Path ${env:BOOTSTRAP_KUBECONFIG}) {
|
||||
Log-Output "Create-NodeProblemDetectorKubeConfig creating kubeconfig from kubelet kubeconfig"
|
||||
Copy-Item ${env:BOOTSTRAP_KUBECONFIG} -Destination ${env:NODEPROBLEMDETECTOR_KUBECONFIG_FILE}
|
||||
Log-Output ("node-problem-detector bootstrap kubeconfig:`n" +
|
||||
"$(Get-Content -Raw ${env:NODEPROBLEMDETECTOR_KUBECONFIG_FILE})")
|
||||
} else {
|
||||
Log-Output "Either NODE_PROBLEM_DETECTOR_TOKEN or ${env:BOOTSTRAP_KUBECONFIG} must be set"
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user