Pass actual cluster name to cinder-csi-plugin

This passes the acutal cluster name to the cinder-csi-plugin, so that
the plugin will add the name as metadata to the backing volume in
OpenStack.

Effectively, the change will help to better identify which volume in
OpenStack belongs to which cluster, which is especially helpful when
running multiple clusters in one OpenStack tenant/project.

Setting the cluster name in both - the controller and the nodeserver -
will ensure that dynamic and ephemeral volumes will receive the correct
metadata.
This commit is contained in:
ederst 2023-02-13 17:31:28 +01:00
parent b899bf6440
commit cd50ee00ac
5 changed files with 17 additions and 3 deletions

View File

@ -790,6 +790,8 @@ type OpenstackBlockStorageConfig struct {
CreateStorageClass *bool `json:"createStorageClass,omitempty"`
CSIPluginImage string `json:"csiPluginImage,omitempty"`
CSITopologySupport *bool `json:"csiTopologySupport,omitempty"`
// ClusterName sets the --cluster flag for the cinder-csi-plugin to the provided name
ClusterName string `json:"clusterName,omitempty"`
}
// OpenstackMonitor defines the config for a health monitor

View File

@ -796,6 +796,8 @@ type OpenstackBlockStorageConfig struct {
CreateStorageClass *bool `json:"createStorageClass,omitempty"`
CSIPluginImage string `json:"csiPluginImage,omitempty"`
CSITopologySupport *bool `json:"csiTopologySupport,omitempty"`
// ClusterName sets the --cluster flag for the cinder-csi-plugin to the provided name
ClusterName string `json:"clusterName,omitempty"`
}
// OpenstackMonitor defines the config for a health monitor

View File

@ -787,6 +787,8 @@ type OpenstackBlockStorageConfig struct {
CreateStorageClass *bool `json:"createStorageClass,omitempty"`
CSIPluginImage string `json:"csiPluginImage,omitempty"`
CSITopologySupport *bool `json:"csiTopologySupport,omitempty"`
// ClusterName sets the --cluster flag for the cinder-csi-plugin to the provided name
ClusterName string `json:"clusterName,omitempty"`
}
// OpenstackMonitor defines the config for a health monitor

View File

@ -333,7 +333,7 @@ spec:
- name: CLOUD_CONFIG
value: /etc/kubernetes/cloud.config
- name: CLUSTER_NAME
value: kubernetes
value: "{{- if .CloudProvider.Openstack.BlockStorage.ClusterName -}} {{ .CloudProvider.Openstack.BlockStorage.ClusterName }} {{- else -}} kubernetes {{- end -}}"
imagePullPolicy: "IfNotPresent"
ports:
- containerPort: 9808
@ -465,11 +465,18 @@ spec:
- /bin/cinder-csi-plugin
- "--endpoint=$(CSI_ENDPOINT)"
- "--cloud-config=$(CLOUD_CONFIG)"
{{- if .CloudProvider.Openstack.BlockStorage.ClusterName }}
- "--cluster=$(CLUSTER_NAME)"
{{- end }}
env:
- name: CSI_ENDPOINT
value: unix://csi/csi.sock
- name: CLOUD_CONFIG
value: /etc/kubernetes/cloud.config
{{- if .CloudProvider.Openstack.BlockStorage.ClusterName }}
- name: CLUSTER_NAME
value: {{ .CloudProvider.Openstack.BlockStorage.ClusterName }}
{{- end }}
imagePullPolicy: "IfNotPresent"
ports:
- containerPort: 9808

View File

@ -324,8 +324,9 @@ func NewCluster(opt *NewClusterOptions, clientset simple.Clientset) (*NewCluster
ExternalNetwork: fi.PtrTo(opt.OpenstackExternalNet),
},
BlockStorage: &api.OpenstackBlockStorageConfig{
Version: fi.PtrTo("v3"),
IgnoreAZ: fi.PtrTo(opt.OpenstackStorageIgnoreAZ),
Version: fi.PtrTo("v3"),
IgnoreAZ: fi.PtrTo(opt.OpenstackStorageIgnoreAZ),
ClusterName: opt.ClusterName,
},
Monitor: &api.OpenstackMonitor{
Delay: fi.PtrTo("15s"),