From 47a7fcb17b4461f44f298ff930e1c9f7286ff961 Mon Sep 17 00:00:00 2001 From: Jeremy Edwards Date: Wed, 2 Jun 2021 21:15:45 +0000 Subject: [PATCH] GCE Windows: Only create NPD kubeconfig when the file path is defined. --- cluster/gce/windows/k8s-node-setup.psm1 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cluster/gce/windows/k8s-node-setup.psm1 b/cluster/gce/windows/k8s-node-setup.psm1 index e4dc2ce3cb7..4cc42b44e87 100644 --- a/cluster/gce/windows/k8s-node-setup.psm1 +++ b/cluster/gce/windows/k8s-node-setup.psm1 @@ -1719,7 +1719,7 @@ function DownloadAndInstall-NodeProblemDetector { } # Creates the node-problem-detector user kubeconfig file at -# $env:NODEPROBLEMDETECTOR_KUBECONFIG_FILE. +# $env:NODEPROBLEMDETECTOR_KUBECONFIG_FILE (if defined). # # Create-NodePki() must be called first. # @@ -1727,9 +1727,11 @@ function DownloadAndInstall-NodeProblemDetector { # CA_CERT # NODE_PROBLEM_DETECTOR_TOKEN function Create-NodeProblemDetectorKubeConfig { - Create-Kubeconfig -Name 'node-problem-detector' ` - -Path ${env:NODEPROBLEMDETECTOR_KUBECONFIG_FILE} ` - -Token ${kube_env}['NODE_PROBLEM_DETECTOR_TOKEN'] + 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'] + } } # Configures NPD to run with the bundled monitor configs and report against the Kubernetes api server.