diff --git a/main.go b/main.go index 16b949a24..c3a56456f 100644 --- a/main.go +++ b/main.go @@ -45,13 +45,13 @@ import ( const ( // K8sMinimumSupportedVersion is the minimum supported version for k8s - K8sMinimumSupportedVersion = "1.19" + K8sMinimumSupportedVersion = "1.21" // K8sMaximumSupportedVersion is the maximum supported version for k8s K8sMaximumSupportedVersion = "1.23" // OpenshiftMinimumSupportedVersion is the minimum supported version for openshift - OpenshiftMinimumSupportedVersion = "4.6" + OpenshiftMinimumSupportedVersion = "4.8" // OpenshiftMaximumSupportedVersion is the maximum supported version for openshift - OpenshiftMaximumSupportedVersion = "4.7" + OpenshiftMaximumSupportedVersion = "4.9" ) var ( @@ -113,34 +113,38 @@ func getOperatorConfig() utils.OperatorConfig { if err != nil { log.Info(fmt.Sprintf("kubeVersion %s", kubeVersion)) } + // intialise variable + k8sPath := "" if currentVersion < minVersion { - log.Info(fmt.Sprintf("version %s is less than minimum supported version of %f", kubeVersion, minVersion)) - } - if currentVersion > maxVersion { - log.Info(fmt.Sprintf("version %s is greater than maximum supported version of %f", kubeVersion, maxVersion)) - + log.Info(fmt.Sprintf("Installed k8s version %s is less than the minimum supported k8s version %f , hence using the default configurations", kubeVersion, minVersion)) + k8sPath = fmt.Sprintf("/driverconfig/common/default.yaml") + } else if currentVersion > maxVersion { + log.Info(fmt.Sprintf("Installed k8s version %s is greater than the maximum supported k8s version %f , hence using the latest available configurations", kubeVersion, maxVersion)) + k8sPath = fmt.Sprintf("/driverconfig/common/k8s-%s-values.yaml", K8sMaximumSupportedVersion) + } else { + k8sPath = fmt.Sprintf("/driverconfig/common/k8s-%s-values.yaml", kubeVersion) } - // Get the environment variSable config dir + // Get the environment variable config dir configDir := os.Getenv("X_CSM_OPERATOR_CONFIG_DIR") if configDir == "" { // Set the config dir to the folder pkg/config - configDir = "operatorconfig/" + configDir = "operatorconfig" + k8sPath = fmt.Sprintf("%s%s", configDir, k8sPath) } else { - k8sPath := fmt.Sprintf("%s/driverconfig/common/k8s-%s-values.yaml", configDir, kubeVersion) + k8sPath = fmt.Sprintf("%s%s", configDir, k8sPath) _, err := ioutil.ReadFile(k8sPath) if err != nil { // This means that the configmap is not mounted // fall back to the local copy log.Error(err, "Error reading file from the configmap mount") log.Info("Falling back to local copy of config files") - configDir = "/etc/config/local/dell-csm-operator" + k8sPath = fmt.Sprintf("%s%s", configDir, k8sPath) } + } cfg.ConfigDirectory = configDir - - k8sPath := fmt.Sprintf("%s/driverconfig/common/k8s-%s-values.yaml", cfg.ConfigDirectory, kubeVersion) buf, err := ioutil.ReadFile(k8sPath) if err != nil { panic(fmt.Sprintf("reading file, %s, from the configmap mount: %v", k8sPath, err)) diff --git a/operatorconfig/driverconfig/common/k8s-1.20-values.yaml b/operatorconfig/driverconfig/common/default.yaml similarity index 91% rename from operatorconfig/driverconfig/common/k8s-1.20-values.yaml rename to operatorconfig/driverconfig/common/default.yaml index 114fa3fd6..bcb57deec 100644 --- a/operatorconfig/driverconfig/common/k8s-1.20-values.yaml +++ b/operatorconfig/driverconfig/common/default.yaml @@ -1,6 +1,3 @@ - -kubeversion: "v1.20" - # IT IS RECOMMENDED YOU DO NOT CHANGE THE IMAGES TO BE DOWNLOADED. images: # "images.attacher" defines the container images used for the csi attacher @@ -20,4 +17,4 @@ images: # "images.resizer" defines the container images used for the csi resizer # container. - resizer: k8s.gcr.io/sig-storage/csi-resizer:v1.2.0 \ No newline at end of file + resizer: k8s.gcr.io/sig-storage/csi-resizer:v1.2.0 diff --git a/operatorconfig/driverconfig/common/k8s-1.19-values.yaml b/operatorconfig/driverconfig/common/k8s-1.19-values.yaml deleted file mode 100644 index 10e0bec92..000000000 --- a/operatorconfig/driverconfig/common/k8s-1.19-values.yaml +++ /dev/null @@ -1,22 +0,0 @@ -kubeversion: "v1.19" - -# IT IS RECOMMENDED YOU DO NOT CHANGE THE IMAGES TO BE DOWNLOADED. -images: - # "images.attacher" defines the container images used for the csi attacher - # container. - attacher: k8s.gcr.io/sig-storage/csi-attacher:v3.1.0 - - # "images.provisioner" defines the container images used for the csi provisioner - # container. - provisioner: k8s.gcr.io/sig-storage/csi-provisioner:v2.1.0 - - # "images.snapshotter" defines the container image used for the csi snapshotter - snapshotter: k8s.gcr.io/sig-storage/csi-snapshotter:v3.0.3 - - # "images.registrar" defines the container images used for the csi registrar - # container. - registrar: k8s.gcr.io/sig-storage/csi-node-driver-registrar:v2.1.0 - - # "images.resizer" defines the container images used for the csi resizer - # container. - resizer: k8s.gcr.io/sig-storage/csi-resizer:v1.1.0 diff --git a/operatorconfig/driverconfig/common/k8s-1.21-values.yaml b/operatorconfig/driverconfig/common/k8s-1.21-values.yaml index 6b43401ef..bcb57deec 100644 --- a/operatorconfig/driverconfig/common/k8s-1.21-values.yaml +++ b/operatorconfig/driverconfig/common/k8s-1.21-values.yaml @@ -1,6 +1,3 @@ - -kubeversion: "v1.21" - # IT IS RECOMMENDED YOU DO NOT CHANGE THE IMAGES TO BE DOWNLOADED. images: # "images.attacher" defines the container images used for the csi attacher @@ -20,4 +17,4 @@ images: # "images.resizer" defines the container images used for the csi resizer # container. - resizer: k8s.gcr.io/sig-storage/csi-resizer:v1.2.0 + resizer: k8s.gcr.io/sig-storage/csi-resizer:v1.2.0 diff --git a/operatorconfig/driverconfig/common/k8s-1.22-values.yaml b/operatorconfig/driverconfig/common/k8s-1.22-values.yaml index 943c25433..06c7eae85 100644 --- a/operatorconfig/driverconfig/common/k8s-1.22-values.yaml +++ b/operatorconfig/driverconfig/common/k8s-1.22-values.yaml @@ -1,6 +1,3 @@ - -kubeversion: "v1.22" - # IT IS RECOMMENDED YOU DO NOT CHANGE THE IMAGES TO BE DOWNLOADED. images: # "images.attacher" defines the container images used for the csi attacher diff --git a/operatorconfig/driverconfig/common/k8s-1.23-values.yaml b/operatorconfig/driverconfig/common/k8s-1.23-values.yaml index a6ef3d359..923013c01 100644 --- a/operatorconfig/driverconfig/common/k8s-1.23-values.yaml +++ b/operatorconfig/driverconfig/common/k8s-1.23-values.yaml @@ -1,6 +1,3 @@ - -kubeversion: "v1.23" - # IT IS RECOMMENDED YOU DO NOT CHANGE THE IMAGES TO BE DOWNLOADED. images: # "images.attacher" defines the container images used for the csi attacher