Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove mounting vsphere-config-secret in vsphere-csi-node daemonset #181

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
19 changes: 11 additions & 8 deletions manifests/vsphere-67u3/vanilla/deploy/vsphere-csi-node-ds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ spec:
value: "node"
- name: X_CSI_SPEC_REQ_VALIDATION
value: "false"
- name: VSPHERE_CSI_CONFIG
value: "/etc/cloud/csi-vsphere.conf" # here csi-vsphere.conf is the name of the file used for creating secret using "--from-file" flag
# needed only for topology aware setups
#- name: VSPHERE_CSI_CONFIG
# value: "/etc/cloud/csi-vsphere.conf" # here csi-vsphere.conf is the name of the file used for creating secret using "--from-file" flag
- name: X_CSI_DEBUG
value: "true"
- name: LOGGER_LEVEL
Expand All @@ -67,9 +68,10 @@ spec:
add: ["SYS_ADMIN"]
allowPrivilegeEscalation: true
volumeMounts:
- name: vsphere-config-volume
mountPath: /etc/cloud
readOnly: true
# needed only for topology aware setups
#- name: vsphere-config-volume
# mountPath: /etc/cloud
# readOnly: true
- name: plugin-dir
mountPath: /csi
- name: pods-mount-dir
Expand Down Expand Up @@ -102,9 +104,10 @@ spec:
- name: plugin-dir
mountPath: /csi
volumes:
- name: vsphere-config-volume
secret:
secretName: vsphere-config-secret
# needed only for topology aware setups
#- name: vsphere-config-volume
# secret:
# secretName: vsphere-config-secret
- name: registration-dir
hostPath:
path: /var/lib/kubelet/plugins_registry
Expand Down
19 changes: 11 additions & 8 deletions manifests/vsphere-7.0/vanilla/deploy/vsphere-csi-node-ds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,9 @@ spec:
value: "node"
- name: X_CSI_SPEC_REQ_VALIDATION
value: "false"
- name: VSPHERE_CSI_CONFIG
value: "/etc/cloud/csi-vsphere.conf" # here csi-vsphere.conf is the name of the file used for creating secret using "--from-file" flag
# needed only for topology aware setups
#- name: VSPHERE_CSI_CONFIG
# value: "/etc/cloud/csi-vsphere.conf" # here csi-vsphere.conf is the name of the file used for creating secret using "--from-file" flag
- name: X_CSI_DEBUG
value: "true"
- name: LOGGER_LEVEL
Expand All @@ -67,9 +68,10 @@ spec:
add: ["SYS_ADMIN"]
allowPrivilegeEscalation: true
volumeMounts:
- name: vsphere-config-volume
mountPath: /etc/cloud
readOnly: true
# needed only for topology aware setups
#- name: vsphere-config-volume
# mountPath: /etc/cloud
# readOnly: true
- name: plugin-dir
mountPath: /csi
- name: pods-mount-dir
Expand Down Expand Up @@ -102,9 +104,10 @@ spec:
- name: plugin-dir
mountPath: /csi
volumes:
- name: vsphere-config-volume
secret:
secretName: vsphere-config-secret
# needed only for topology aware setups
#- name: vsphere-config-volume
# secret:
# secretName: vsphere-config-secret
- name: registration-dir
hostPath:
path: /var/lib/kubelet/plugins_registry
Expand Down
5 changes: 3 additions & 2 deletions pkg/common/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,11 @@ func GetCnsconfig(ctx context.Context, cfgPath string) (*Config, error) {
var cfg *Config
//Read in the vsphere.conf if it exists
if _, err := os.Stat(cfgPath); os.IsNotExist(err) {
log.Infof("Could not stat %s, reading config params from env", cfgPath)
// config from Env var only
cfg = &Config{}
if err := FromEnv(ctx, cfg); err != nil {
log.Errorf("Error reading vsphere.conf\n")
if fromEnvErr := FromEnv(ctx, cfg); fromEnvErr != nil {
log.Errorf("Failed to get config params from env. Err: %v", fromEnvErr)
return cfg, err
}
} else {
Expand Down
8 changes: 8 additions & 0 deletions pkg/csi/service/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import (
"k8s.io/kubernetes/pkg/util/mount"
"k8s.io/kubernetes/pkg/util/resizefs"
"k8s.io/kubernetes/pkg/volume/util/fs"

cnsvsphere "sigs.k8s.io/vsphere-csi-driver/pkg/common/cns-lib/vsphere"
cnsconfig "sigs.k8s.io/vsphere-csi-driver/pkg/common/config"
"sigs.k8s.io/vsphere-csi-driver/pkg/csi/service/common"
Expand Down Expand Up @@ -652,13 +653,20 @@ func (s *service) NodeGetInfo(
}
cfg, err := cnsconfig.GetCnsconfig(ctx, cfgPath)
if err != nil {
if os.IsNotExist(err) {
log.Infof("Config file not provided to node daemonset. Assuming non-topology aware cluster.")
return &csi.NodeGetInfoResponse{
NodeId: nodeID,
}, nil
}
log.Errorf("failed to read cnsconfig. Error: %v", err)
return nil, status.Errorf(codes.Internal, err.Error())
}
var accessibleTopology map[string]string
topology := &csi.Topology{}

if cfg.Labels.Zone != "" && cfg.Labels.Region != "" {
log.Infof("Config file provided to node daemonset with zones and regions. Assuming topology aware cluster.")
vcenterconfig, err := cnsvsphere.GetVirtualCenterConfig(cfg)
if err != nil {
log.Errorf("failed to get VirtualCenterConfig from cns config. err=%v", err)
Expand Down