Skip to content

Commit

Permalink
Merge pull request #181 from divyenpatel/commented-mouting-vsphere-se…
Browse files Browse the repository at this point in the history
…cret-on-all-nodes

remove mounting vsphere-config-secret in vsphere-csi-node daemonset
  • Loading branch information
k8s-ci-robot authored Apr 16, 2020
2 parents e9cfd60 + 4e1714d commit 3acd0e0
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 18 deletions.
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

0 comments on commit 3acd0e0

Please sign in to comment.