Merge pull request #125119 from mauriciopoppe/fix-npd-envvars

Create NPD kubeconfig conditionally if the installation mode is standalone
This commit is contained in:
Kubernetes Prow Robot 2024-06-12 03:39:50 -07:00 committed by GitHub
commit a06568062c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 8 deletions

View File

@ -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")

View File

@ -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
}
}
}