Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pkg/azurefile/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func getCloudProvider(ctx context.Context, kubeconfig, nodeID, secretName, secre
}
}

if kubeClient != nil {
if kubeClient != nil && secretName != "" && secretNamespace != "" {
klog.V(2).Infof("reading cloud config from secret %s/%s", secretNamespace, secretName)
config, err = configloader.Load[azureconfig.Config](ctx, &configloader.K8sSecretLoaderConfig{
K8sSecretConfig: configloader.K8sSecretConfig{
Expand All @@ -118,7 +118,11 @@ func getCloudProvider(ctx context.Context, kubeconfig, nodeID, secretName, secre
}

if config == nil {
klog.V(2).Infof("could not read cloud config from secret %s/%s", secretNamespace, secretName)
if secretName == "" || secretNamespace == "" {
klog.V(2).Infof("reading cloud config from a Kubernetes secret is disabled")
} else {
klog.V(2).Infof("could not read cloud config from secret %s/%s", secretNamespace, secretName)
}
credFile, ok := os.LookupEnv(DefaultAzureCredentialFileEnv)
if ok && strings.TrimSpace(credFile) != "" {
klog.V(2).Infof("%s env var set as %v", DefaultAzureCredentialFileEnv, credFile)
Expand Down
2 changes: 1 addition & 1 deletion pkg/azurefile/azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ users:
t.Setenv("AZURE_FEDERATED_TOKEN_FILE", test.aadFederatedTokenFile)
}

cloud, _, err := getCloudProvider(context.Background(), test.kubeconfig, "", "", "", test.userAgent, test.allowEmptyCloudConfig, false, 5, 10)
cloud, _, err := getCloudProvider(context.Background(), test.kubeconfig, "", "azure-cloud-provider", "kube-system", test.userAgent, test.allowEmptyCloudConfig, false, 5, 10)
if test.expectedErr.DefaultError != nil && test.expectedErr.WindowsError != nil {
if !testutil.AssertError(err, &test.expectedErr) && !strings.Contains(err.Error(), test.expectedErr.DefaultError.Error()) {
t.Errorf("desc: %s,\n input: %q, getCloudProvider err: %v, expectedErr: %v", test.desc, test.kubeconfig, err, test.expectedErr)
Expand Down
4 changes: 2 additions & 2 deletions pkg/azurefile/azurefile_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ func (o *DriverOptions) AddFlags() *flag.FlagSet {
fs.StringVar(&o.DriverName, "drivername", DefaultDriverName, "name of the driver")
fs.BoolVar(&o.EnableAzurefileProxy, "enable-azurefile-proxy", false, "enable azurefile proxy")
fs.StringVar(&o.AzureFileProxyEndpoint, "azurefile-proxy-endpoint", "unix://tmp/azurefile-proxy.sock", "azurefile-proxy endpoint")
fs.StringVar(&o.CloudConfigSecretName, "cloud-config-secret-name", "azure-cloud-provider", "secret name of cloud config")
fs.StringVar(&o.CloudConfigSecretNamespace, "cloud-config-secret-namespace", "kube-system", "secret namespace of cloud config")
fs.StringVar(&o.CloudConfigSecretName, "cloud-config-secret-name", "azure-cloud-provider", "secret name of cloud config. If set to an empty string, the driver will not read cloud config from a Kubernetes secret.")
fs.StringVar(&o.CloudConfigSecretNamespace, "cloud-config-secret-namespace", "kube-system", "secret namespace of cloud config. If set to an empty string, the driver will not read cloud config from a Kubernetes secret.")
fs.StringVar(&o.CustomUserAgent, "custom-user-agent", "", "custom userAgent")
fs.StringVar(&o.UserAgentSuffix, "user-agent-suffix", "", "userAgent suffix")
fs.BoolVar(&o.AllowEmptyCloudConfig, "allow-empty-cloud-config", true, "allow running driver without cloud config")
Expand Down
Loading