mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-26 21:17:23 +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")
|
KUBE_PROXY_TOKEN=$(get-env-val "${node_env}" "KUBE_PROXY_TOKEN")
|
||||||
export KUBE_PROXY_TOKEN
|
export KUBE_PROXY_TOKEN
|
||||||
NODE_PROBLEM_DETECTOR_TOKEN=$(get-env-val "${node_env}" "NODE_PROBLEM_DETECTOR_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")
|
CA_CERT_BASE64=$(get-env-val "${node_env}" "CA_CERT")
|
||||||
export CA_CERT_BASE64
|
export CA_CERT_BASE64
|
||||||
EXTRA_DOCKER_OPTS=$(get-env-val "${node_env}" "EXTRA_DOCKER_OPTS")
|
EXTRA_DOCKER_OPTS=$(get-env-val "${node_env}" "EXTRA_DOCKER_OPTS")
|
||||||
|
@ -1130,7 +1130,7 @@ function Verify-WorkerServices {
|
|||||||
$timeout = 12
|
$timeout = 12
|
||||||
$retries = 0
|
$retries = 0
|
||||||
$retryDelayInSeconds = 5
|
$retryDelayInSeconds = 5
|
||||||
|
|
||||||
Log-Output ("Testing node connection to API server...")
|
Log-Output ("Testing node connection to API server...")
|
||||||
do {
|
do {
|
||||||
$retries++
|
$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
|
$host_status = & "${env:NODE_DIR}\kubectl.exe" get nodes (hostname) -o=custom-columns=:.status.conditions[4].type | Out-String
|
||||||
Start-Sleep $retryDelayInSeconds
|
Start-Sleep $retryDelayInSeconds
|
||||||
} while (((-Not $nodes_list) -or (-Not $nodes_list.contains((hostname))) -or (-Not $host_status.contains("Ready")))-and ($retries -le $timeout))
|
} while (((-Not $nodes_list) -or (-Not $nodes_list.contains((hostname))) -or (-Not $host_status.contains("Ready")))-and ($retries -le $timeout))
|
||||||
|
|
||||||
If (-Not $nodes_list){
|
If (-Not $nodes_list){
|
||||||
Throw ("Node: '$(hostname)' failed to connect to API server")
|
Throw ("Node: '$(hostname)' failed to connect to API server")
|
||||||
|
|
||||||
}ElseIf (-Not $nodes_list.contains((hostname))) {
|
}ElseIf (-Not $nodes_list.contains((hostname))) {
|
||||||
Throw ("Node: '$(hostname)' failed to join the cluster; NODES: '`n $($nodes_list)'")
|
Throw ("Node: '$(hostname)' failed to join the cluster; NODES: '`n $($nodes_list)'")
|
||||||
|
|
||||||
}ELseIf (-Not $host_status.contains("Ready")) {
|
}ELseIf (-Not $host_status.contains("Ready")) {
|
||||||
Throw ("Node: '$(hostname)' is not in Ready state")
|
Throw ("Node: '$(hostname)' is not in Ready state")
|
||||||
}
|
}
|
||||||
|
|
||||||
Log-Output ("Node: $(hostname) successfully joined cluster `n NODES: `n $($nodes_list)")
|
Log-Output ("Node: $(hostname) successfully joined cluster `n NODES: `n $($nodes_list)")
|
||||||
Verify_GceMetadataServerRouteIsPresent
|
Verify_GceMetadataServerRouteIsPresent
|
||||||
|
|
||||||
@ -1543,10 +1543,21 @@ function DownloadAndInstall-NodeProblemDetector {
|
|||||||
# CA_CERT
|
# CA_CERT
|
||||||
# NODE_PROBLEM_DETECTOR_TOKEN
|
# NODE_PROBLEM_DETECTOR_TOKEN
|
||||||
function Create-NodeProblemDetectorKubeConfig {
|
function Create-NodeProblemDetectorKubeConfig {
|
||||||
if (-not [string]::IsNullOrEmpty(${env:NODEPROBLEMDETECTOR_KUBECONFIG_FILE})) {
|
if ("${env:ENABLE_NODE_PROBLEM_DETECTOR}" -eq "standalone") {
|
||||||
Create-Kubeconfig -Name 'node-problem-detector' `
|
if (-not [string]::IsNullOrEmpty(${kube_env]['NODE_PROBLEM_DETECTOR_TOKEN']})) {
|
||||||
-Path ${env:NODEPROBLEMDETECTOR_KUBECONFIG_FILE} `
|
Log-Output "Create-NodeProblemDetectorKubeConfig using Node Problem Detector token"
|
||||||
-Token ${kube_env}['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