diff --git a/api/v1beta1/common_types.go b/api/v1beta1/common_types.go index 499eb4733..de110c4cc 100644 --- a/api/v1beta1/common_types.go +++ b/api/v1beta1/common_types.go @@ -56,6 +56,13 @@ type Storage struct { VolumeMount AdditionalVolume `json:"volumeMount,omitempty"` } +// Node-conf needs to be added only in redis cluster +type ClusterStorage struct { + VolumeClaimTemplate corev1.PersistentVolumeClaim `json:"volumeClaimTemplate,omitempty"` + NodeConfVolumeClaimTemplate corev1.PersistentVolumeClaim `json:"nodeConfVolumeClaimTemplate,omitempty"` + VolumeMount AdditionalVolume `json:"volumeMount,omitempty"` +} + // Additional Volume is provided by user that is mounted on the pods type AdditionalVolume struct { Volume []corev1.Volume `json:"volume,omitempty"` diff --git a/api/v1beta1/rediscluster_types.go b/api/v1beta1/rediscluster_types.go index 6ef6d6f7a..35cda96a6 100644 --- a/api/v1beta1/rediscluster_types.go +++ b/api/v1beta1/rediscluster_types.go @@ -32,7 +32,7 @@ type RedisClusterSpec struct { // +kubebuilder:default:={livenessProbe:{initialDelaySeconds: 1, timeoutSeconds: 1, periodSeconds: 10, successThreshold: 1, failureThreshold:3}, readinessProbe:{initialDelaySeconds: 1, timeoutSeconds: 1, periodSeconds: 10, successThreshold: 1, failureThreshold:3}} RedisFollower RedisFollower `json:"redisFollower,omitempty"` RedisExporter *RedisExporter `json:"redisExporter,omitempty"` - Storage *Storage `json:"storage,omitempty"` + Storage *ClusterStorage `json:"storage,omitempty"` PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"` PriorityClassName string `json:"priorityClassName,omitempty"` Resources *corev1.ResourceRequirements `json:"resources,omitempty"` diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 1b13370e5..22572ba70 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -75,6 +75,24 @@ func (in *AdditionalVolume) DeepCopy() *AdditionalVolume { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterStorage) DeepCopyInto(out *ClusterStorage) { + *out = *in + in.VolumeClaimTemplate.DeepCopyInto(&out.VolumeClaimTemplate) + in.NodeConfVolumeClaimTemplate.DeepCopyInto(&out.NodeConfVolumeClaimTemplate) + in.VolumeMount.DeepCopyInto(&out.VolumeMount) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterStorage. +func (in *ClusterStorage) DeepCopy() *ClusterStorage { + if in == nil { + return nil + } + out := new(ClusterStorage) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ExistingPasswordSecret) DeepCopyInto(out *ExistingPasswordSecret) { *out = *in @@ -310,7 +328,7 @@ func (in *RedisClusterSpec) DeepCopyInto(out *RedisClusterSpec) { } if in.Storage != nil { in, out := &in.Storage, &out.Storage - *out = new(Storage) + *out = new(ClusterStorage) (*in).DeepCopyInto(*out) } if in.PodSecurityContext != nil { @@ -450,6 +468,11 @@ func (in *RedisFollower) DeepCopyInto(out *RedisFollower) { *out = new(RedisConfig) (*in).DeepCopyInto(*out) } + if in.SecurityContext != nil { + in, out := &in.SecurityContext, &out.SecurityContext + *out = new(v1.SecurityContext) + (*in).DeepCopyInto(*out) + } if in.Affinity != nil { in, out := &in.Affinity, &out.Affinity *out = new(v1.Affinity) @@ -518,6 +541,11 @@ func (in *RedisLeader) DeepCopyInto(out *RedisLeader) { *out = new(RedisConfig) (*in).DeepCopyInto(*out) } + if in.SecurityContext != nil { + in, out := &in.SecurityContext, &out.SecurityContext + *out = new(v1.SecurityContext) + (*in).DeepCopyInto(*out) + } if in.Affinity != nil { in, out := &in.Affinity, &out.Affinity *out = new(v1.Affinity) diff --git a/config/crd/bases/redis.redis.opstreelabs.in_redisclusters.yaml b/config/crd/bases/redis.redis.opstreelabs.in_redisclusters.yaml index f7d234e78..281d85ba1 100644 --- a/config/crd/bases/redis.redis.opstreelabs.in_redisclusters.yaml +++ b/config/crd/bases/redis.redis.opstreelabs.in_redisclusters.yaml @@ -3429,9 +3429,286 @@ spec: type: object type: array storage: - description: Storage is the inteface to add pvc and pv support in - redis + description: Node-conf needs to be added only in redis cluster properties: + nodeConfVolumeClaimTemplate: + description: PersistentVolumeClaim is a user's request for and + claim to a persistent volume + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this + representation of an object. Servers should convert recognized + schemas to the latest internal value, and may reject unrecognized + values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST + resource this object represents. Servers may infer this + from the endpoint the client submits requests to. Cannot + be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + description: 'Standard object''s metadata. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata' + type: object + spec: + description: 'Spec defines the desired characteristics of + a volume requested by a pod author. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims' + properties: + accessModes: + description: 'AccessModes contains the desired access + modes the volume should have. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1' + items: + type: string + type: array + dataSource: + description: 'This field can be used to specify either: + * An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot) + * An existing PVC (PersistentVolumeClaim) If the provisioner + or an external controller can support the specified + data source, it will create a new volume based on the + contents of the specified data source. If the AnyVolumeDataSource + feature gate is enabled, this field will always have + the same contents as the DataSourceRef field.' + properties: + apiGroup: + description: APIGroup is the group for the resource + being referenced. If APIGroup is not specified, + the specified Kind must be in the core API group. + For any other third-party types, APIGroup is required. + type: string + kind: + description: Kind is the type of resource being referenced + type: string + name: + description: Name is the name of resource being referenced + type: string + required: + - kind + - name + type: object + dataSourceRef: + description: 'Specifies the object from which to populate + the volume with data, if a non-empty volume is desired. + This may be any local object from a non-empty API group + (non core object) or a PersistentVolumeClaim object. + When this field is specified, volume binding will only + succeed if the type of the specified object matches + some installed volume populator or dynamic provisioner. + This field will replace the functionality of the DataSource + field and as such if both fields are non-empty, they + must have the same value. For backwards compatibility, + both fields (DataSource and DataSourceRef) will be set + to the same value automatically if one of them is empty + and the other is non-empty. There are two important + differences between DataSource and DataSourceRef: * + While DataSource only allows two specific types of objects, + DataSourceRef allows any non-core object, as well + as PersistentVolumeClaim objects. * While DataSource + ignores disallowed values (dropping them), DataSourceRef preserves + all values, and generates an error if a disallowed value + is specified. (Alpha) Using this field requires the + AnyVolumeDataSource feature gate to be enabled.' + properties: + apiGroup: + description: APIGroup is the group for the resource + being referenced. If APIGroup is not specified, + the specified Kind must be in the core API group. + For any other third-party types, APIGroup is required. + type: string + kind: + description: Kind is the type of resource being referenced + type: string + name: + description: Name is the name of resource being referenced + type: string + required: + - kind + - name + type: object + resources: + description: 'Resources represents the minimum resources + the volume should have. If RecoverVolumeExpansionFailure + feature is enabled users are allowed to specify resource + requirements that are lower than previous value but + must still be higher than capacity recorded in the status + field of the claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources' + properties: + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Limits describes the maximum amount + of compute resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: 'Requests describes the minimum amount + of compute resources required. If Requests is omitted + for a container, it defaults to Limits if that is + explicitly specified, otherwise to an implementation-defined + value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' + type: object + type: object + selector: + description: A label query over volumes to consider for + binding. + properties: + matchExpressions: + description: matchExpressions is a list of label selector + requirements. The requirements are ANDed. + items: + description: A label selector requirement is a selector + that contains values, a key, and an operator that + relates the key and values. + properties: + key: + description: key is the label key that the selector + applies to. + type: string + operator: + description: operator represents a key's relationship + to a set of values. Valid operators are In, + NotIn, Exists and DoesNotExist. + type: string + values: + description: values is an array of string values. + If the operator is In or NotIn, the values + array must be non-empty. If the operator is + Exists or DoesNotExist, the values array must + be empty. This array is replaced during a + strategic merge patch. + items: + type: string + type: array + required: + - key + - operator + type: object + type: array + matchLabels: + additionalProperties: + type: string + description: matchLabels is a map of {key,value} pairs. + A single {key,value} in the matchLabels map is equivalent + to an element of matchExpressions, whose key field + is "key", the operator is "In", and the values array + contains only "value". The requirements are ANDed. + type: object + type: object + storageClassName: + description: 'Name of the StorageClass required by the + claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1' + type: string + volumeMode: + description: volumeMode defines what type of volume is + required by the claim. Value of Filesystem is implied + when not included in claim spec. + type: string + volumeName: + description: VolumeName is the binding reference to the + PersistentVolume backing this claim. + type: string + type: object + status: + description: 'Status represents the current information/status + of a persistent volume claim. Read-only. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#persistentvolumeclaims' + properties: + accessModes: + description: 'AccessModes contains the actual access modes + the volume backing the PVC has. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1' + items: + type: string + type: array + allocatedResources: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: The storage resource within AllocatedResources + tracks the capacity allocated to a PVC. It may be larger + than the actual capacity when a volume expansion operation + is requested. For storage quota, the larger value from + allocatedResources and PVC.spec.resources is used. If + allocatedResources is not set, PVC.spec.resources alone + is used for quota calculation. If a volume expansion + capacity request is lowered, allocatedResources is only + lowered if there are no expansion operations in progress + and if the actual volume capacity is equal or lower + than the requested capacity. This is an alpha field + and requires enabling RecoverVolumeExpansionFailure + feature. + type: object + capacity: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + description: Represents the actual resources of the underlying + volume. + type: object + conditions: + description: Current Condition of persistent volume claim. + If underlying persistent volume is being resized then + the Condition will be set to 'ResizeStarted'. + items: + description: PersistentVolumeClaimCondition contails + details about state of pvc + properties: + lastProbeTime: + description: Last time we probed the condition. + format: date-time + type: string + lastTransitionTime: + description: Last time the condition transitioned + from one status to another. + format: date-time + type: string + message: + description: Human-readable message indicating details + about last transition. + type: string + reason: + description: Unique, this should be a short, machine + understandable string that gives the reason for + condition's last transition. If it reports "ResizeStarted" + that means the underlying persistent volume is + being resized. + type: string + status: + type: string + type: + description: PersistentVolumeClaimConditionType + is a valid value of PersistentVolumeClaimCondition.Type + type: string + required: + - status + - type + type: object + type: array + phase: + description: Phase represents the current phase of PersistentVolumeClaim. + type: string + resizeStatus: + description: ResizeStatus stores status of resize operation. + ResizeStatus is not set by default but when expansion + is complete resizeStatus is set to empty string by resize + controller or kubelet. This is an alpha field and requires + enabling RecoverVolumeExpansionFailure feature. + type: string + type: object + type: object volumeClaimTemplate: description: PersistentVolumeClaim is a user's request for and claim to a persistent volume diff --git a/example/acl_config/cluster.yaml b/example/acl_config/cluster.yaml index 2bed225e2..5f025c9ae 100644 --- a/example/acl_config/cluster.yaml +++ b/example/acl_config/cluster.yaml @@ -48,3 +48,9 @@ spec: resources: requests: storage: 1Gi + nodeConfVolumeClaimTemplate: + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 1Gi diff --git a/example/additional_config/clusterd.yaml b/example/additional_config/clusterd.yaml index ab2369356..a02e2c6a4 100644 --- a/example/additional_config/clusterd.yaml +++ b/example/additional_config/clusterd.yaml @@ -30,3 +30,9 @@ spec: resources: requests: storage: 1Gi + nodeConfVolumeClaimTemplate: + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 1Gi diff --git a/example/advance_config/clusterd.yaml b/example/advance_config/clusterd.yaml index fba0dcb38..0bd59383a 100644 --- a/example/advance_config/clusterd.yaml +++ b/example/advance_config/clusterd.yaml @@ -32,6 +32,12 @@ spec: resources: requests: storage: 1Gi + nodeConfVolumeClaimTemplate: + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 1Gi # nodeSelector: {} # podSecurityContext: {} # priorityClassName: "" diff --git a/example/affinity/clusterd.yaml b/example/affinity/clusterd.yaml index 734e9a754..6b9bdd541 100644 --- a/example/affinity/clusterd.yaml +++ b/example/affinity/clusterd.yaml @@ -48,3 +48,9 @@ spec: resources: requests: storage: 1Gi + nodeConfVolumeClaimTemplate: + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 1Gi diff --git a/example/disruption_budget/clusterd.yaml b/example/disruption_budget/clusterd.yaml index 53bce8ae3..f1de2aeab 100644 --- a/example/disruption_budget/clusterd.yaml +++ b/example/disruption_budget/clusterd.yaml @@ -51,8 +51,14 @@ spec: storage: volumeClaimTemplate: spec: - accessModes: - - ReadWriteOnce + # storageClassName: standard + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 1Gi + nodeConfVolumeClaimTemplate: + spec: + accessModes: ["ReadWriteOnce"] resources: requests: storage: 1Gi diff --git a/example/external_service/clusterd.yaml b/example/external_service/clusterd.yaml index 185b88064..4bc986da5 100644 --- a/example/external_service/clusterd.yaml +++ b/example/external_service/clusterd.yaml @@ -24,3 +24,9 @@ spec: resources: requests: storage: 1Gi + nodeConfVolumeClaimTemplate: + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 1Gi diff --git a/example/node-selector/clusterd.yaml b/example/node-selector/clusterd.yaml index 6a6571cc3..82b4ccf7b 100644 --- a/example/node-selector/clusterd.yaml +++ b/example/node-selector/clusterd.yaml @@ -30,3 +30,9 @@ spec: resources: requests: storage: 1Gi + nodeConfVolumeClaimTemplate: + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 1Gi diff --git a/example/password_protected/clusterd.yaml b/example/password_protected/clusterd.yaml index 8ba43c4ff..18cbf4900 100644 --- a/example/password_protected/clusterd.yaml +++ b/example/password_protected/clusterd.yaml @@ -27,3 +27,9 @@ spec: resources: requests: storage: 1Gi + nodeConfVolumeClaimTemplate: + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 1Gi diff --git a/example/private_registry/clusterd.yaml b/example/private_registry/clusterd.yaml index 63b95e4fd..9202d2dd4 100644 --- a/example/private_registry/clusterd.yaml +++ b/example/private_registry/clusterd.yaml @@ -26,3 +26,9 @@ spec: resources: requests: storage: 1Gi + nodeConfVolumeClaimTemplate: + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 1Gi diff --git a/example/probes/clusterd.yaml b/example/probes/clusterd.yaml index d1890549e..981483c08 100644 --- a/example/probes/clusterd.yaml +++ b/example/probes/clusterd.yaml @@ -49,3 +49,9 @@ spec: resources: requests: storage: 1Gi + nodeConfVolumeClaimTemplate: + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 1Gi diff --git a/example/recreate-statefulset/clusterd.yaml b/example/recreate-statefulset/clusterd.yaml index 352bc3032..cf7098e15 100644 --- a/example/recreate-statefulset/clusterd.yaml +++ b/example/recreate-statefulset/clusterd.yaml @@ -26,4 +26,10 @@ spec: resources: requests: storage: 1Gi + nodeConfVolumeClaimTemplate: + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 1Gi priorityClassName: priority-100 diff --git a/example/redis-cluster.yaml b/example/redis-cluster.yaml index 32da85aca..cfde99863 100644 --- a/example/redis-cluster.yaml +++ b/example/redis-cluster.yaml @@ -6,7 +6,7 @@ metadata: spec: clusterSize: 3 clusterVersion: v7 - persistenceEnabled: false + persistenceEnabled: true podSecurityContext: runAsUser: 1000 fsGroup: 1000 @@ -64,6 +64,12 @@ spec: resources: requests: storage: 1Gi + nodeConfVolumeClaimTemplate: + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 1Gi # nodeSelector: # kubernetes.io/hostname: minikube # priorityClassName: diff --git a/example/redis_monitoring/clusterd.yaml b/example/redis_monitoring/clusterd.yaml index a87b6b899..617f9c3a2 100644 --- a/example/redis_monitoring/clusterd.yaml +++ b/example/redis_monitoring/clusterd.yaml @@ -21,6 +21,13 @@ spec: imagePullPolicy: Always storage: volumeClaimTemplate: + spec: + # storageClassName: standard + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 1Gi + nodeConfVolumeClaimTemplate: spec: accessModes: ["ReadWriteOnce"] resources: diff --git a/example/tls_enabled/redis-cluster.yaml b/example/tls_enabled/redis-cluster.yaml index c6a856552..af57922fe 100644 --- a/example/tls_enabled/redis-cluster.yaml +++ b/example/tls_enabled/redis-cluster.yaml @@ -45,7 +45,14 @@ spec: storage: volumeClaimTemplate: spec: + # storageClassName: standard accessModes: ["ReadWriteOnce"] resources: requests: storage: 1Gi + nodeConfVolumeClaimTemplate: + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 1Gi \ No newline at end of file diff --git a/example/tolerations/clusterd.yaml b/example/tolerations/clusterd.yaml index 840ded711..80fecb237 100644 --- a/example/tolerations/clusterd.yaml +++ b/example/tolerations/clusterd.yaml @@ -36,3 +36,9 @@ spec: resources: requests: storage: 1Gi + nodeConfVolumeClaimTemplate: + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 1Gi diff --git a/example/upgrade-strategy/clusterd.yaml b/example/upgrade-strategy/clusterd.yaml index d58fc9a79..8fdf0a545 100644 --- a/example/upgrade-strategy/clusterd.yaml +++ b/example/upgrade-strategy/clusterd.yaml @@ -27,3 +27,9 @@ spec: resources: requests: storage: 1Gi + nodeConfVolumeClaimTemplate: + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 1Gi diff --git a/example/volume_mount/redis-cluster.yaml b/example/volume_mount/redis-cluster.yaml index f453c8be2..c65ddfa6b 100644 --- a/example/volume_mount/redis-cluster.yaml +++ b/example/volume_mount/redis-cluster.yaml @@ -43,6 +43,12 @@ spec: resources: requests: storage: 1Gi + nodeConfVolumeClaimTemplate: + spec: + accessModes: ["ReadWriteOnce"] + resources: + requests: + storage: 1Gi volumemount: volume: - name: example-config diff --git a/k8sutils/redis-cluster.go b/k8sutils/redis-cluster.go index 2bd6e11ea..a99fe8b19 100644 --- a/k8sutils/redis-cluster.go +++ b/k8sutils/redis-cluster.go @@ -47,6 +47,7 @@ func generateRedisClusterParams(cr *redisv1beta1.RedisCluster, replicas int32, e } if cr.Spec.Storage != nil { res.PersistentVolumeClaim = cr.Spec.Storage.VolumeClaimTemplate + res.NodeConfPersistentVolumeClaim = cr.Spec.Storage.NodeConfVolumeClaimTemplate } if externalConfig != nil { res.ExternalConfig = externalConfig diff --git a/k8sutils/statefulset.go b/k8sutils/statefulset.go index 4e69adb3c..a07a83e05 100644 --- a/k8sutils/statefulset.go +++ b/k8sutils/statefulset.go @@ -17,7 +17,6 @@ import ( corev1 "k8s.io/api/core/v1" apiequality "k8s.io/apimachinery/pkg/api/equality" apierrors "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" ) @@ -38,6 +37,7 @@ type statefulSetParameters struct { Tolerations *[]corev1.Toleration EnableMetrics bool PersistentVolumeClaim corev1.PersistentVolumeClaim + NodeConfPersistentVolumeClaim corev1.PersistentVolumeClaim ImagePullSecrets *[]corev1.LocalObjectReference ExternalConfig *string ServiceAccountName *string @@ -252,10 +252,10 @@ func generateStatefulSetsDef(stsMeta metav1.ObjectMeta, params statefulSetParame statefulset.Spec.Template.Spec.ImagePullSecrets = *params.ImagePullSecrets } if containerParams.PersistenceEnabled != nil && params.ClusterMode { - statefulset.Spec.VolumeClaimTemplates = append(statefulset.Spec.VolumeClaimTemplates, createPVCTemplateNodeConf(stsMeta)) + statefulset.Spec.VolumeClaimTemplates = append(statefulset.Spec.VolumeClaimTemplates, createPVCTemplate("node-conf", stsMeta, params.NodeConfPersistentVolumeClaim)) } if containerParams.PersistenceEnabled != nil && *containerParams.PersistenceEnabled { - statefulset.Spec.VolumeClaimTemplates = append(statefulset.Spec.VolumeClaimTemplates, createPVCTemplate(stsMeta, params.PersistentVolumeClaim)) + statefulset.Spec.VolumeClaimTemplates = append(statefulset.Spec.VolumeClaimTemplates, createPVCTemplate(stsMeta.GetName(), stsMeta, params.PersistentVolumeClaim)) } if params.ExternalConfig != nil { statefulset.Spec.Template.Spec.Volumes = getExternalConfig(*params.ExternalConfig) @@ -308,40 +308,11 @@ func getExternalConfig(configMapName string) []corev1.Volume { } } -// createPVCTemplate to store node.conf in durable manner -func createPVCTemplateNodeConf(stsMeta metav1.ObjectMeta) corev1.PersistentVolumeClaim { - // 1Mb Resource requirement for the node.conf - pvcNodeConf := corev1.PersistentVolumeClaim{ - ObjectMeta: metav1.ObjectMeta{ - Name: "node-conf", - }, - Spec: corev1.PersistentVolumeClaimSpec{ - AccessModes: []corev1.PersistentVolumeAccessMode{ - corev1.ReadWriteOnce, - }, - Resources: corev1.ResourceRequirements{ - Requests: corev1.ResourceList{ - corev1.ResourceStorage: resource.MustParse("1Mi"), - }, - }, - VolumeMode: func() *corev1.PersistentVolumeMode { - volumeMode := corev1.PersistentVolumeFilesystem - return &volumeMode - }(), - }, - } - // Load the labels from the statefulset - pvcNodeConf.Labels = stsMeta.GetLabels() - // We want the same annoations as the StatefulSet here - pvcNodeConf.Annotations = generateStatefulSetsAnots(stsMeta) - return pvcNodeConf -} - // createPVCTemplate will create the persistent volume claim template -func createPVCTemplate(stsMeta metav1.ObjectMeta, storageSpec corev1.PersistentVolumeClaim) corev1.PersistentVolumeClaim { +func createPVCTemplate(volumeName string, stsMeta metav1.ObjectMeta, storageSpec corev1.PersistentVolumeClaim) corev1.PersistentVolumeClaim { pvcTemplate := storageSpec pvcTemplate.CreationTimestamp = metav1.Time{} - pvcTemplate.Name = stsMeta.GetName() + pvcTemplate.Name = volumeName pvcTemplate.Labels = stsMeta.GetLabels() // We want the same annoations as the StatefulSet here pvcTemplate.Annotations = generateStatefulSetsAnots(stsMeta)