OT-CONTAINER-KIT / redis-operator

A golang based redis operator that will make/oversee Redis standalone/cluster/replication/sentinel mode setup on top of the Kubernetes.
https://ot-redis-operator.netlify.app/
Apache License 2.0
772 stars 214 forks source link

Incorrect PVC labels used when trying to resize #425

Open artificial-aidan opened 1 year ago

artificial-aidan commented 1 year ago

What version of redis operator are you using?

redis-operator version: 0.13.1

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (kubectl version)?

kubectl version Output
$ kubectl version

Client Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.2", GitCommit:"8b5a19147530eaac9476b0ab82980b4088bbc1b2", GitTreeState:"clean", BuildDate:"2021-09-15T21:31:32Z", GoVersion:"go1.16.8", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"23+", GitVersion:"v1.23.14-eks-ffeb93d", GitCommit:"96e7d52c98a32f2b296ca7f19dc9346cf79915ba", GitTreeState:"clean", BuildDate:"2022-11-29T18:43:31Z", GoVersion:"go1.17.13", Compiler:"gc", Platform:"linux/amd64"}

When a PVC is resized, the operator looks for it based on a set of labels that are not guaranteed to be attached to the volume.

                        listOpt := metav1.ListOptions{
                            LabelSelector: labels.FormatLabels(
                                map[string]string{
                                    "app":                         storedStateful.Name,
                                    "app.kubernetes.io/component": "redis",
                                    "app.kubernetes.io/name":      storedStateful.Name,
                                },
                            ),
                        }
                        pvcs, err := generateK8sClient().CoreV1().PersistentVolumeClaims(storedStateful.Namespace).List(context.Background(), listOpt)

But the labels that are attached to the pvc are as follows

    lbls := map[string]string{
        "app":              name,
        "redis_setup_type": setupType,
        "role":             role,
    }

This leads to pvcs not being resized by default.

You can workaround it by setting the labels of the whole redis deployment to match. But it would make more sense to set the proper label on creation time.

ardole commented 1 year ago

Same on operator version 0.14.0

Using the HelmChart we need to specify manually the three labels in values:

redis-replication:
  enabled: true

  storageSpec:
    volumeClaimTemplate:
      spec:
        accessModes: ["ReadWriteOnce"]
        resources:
          requests:
            storage: 1Gi

  labels:
    app: "redis-replication"
    app.kubernetes.io/component: "redis"
    app.kubernetes.io/name: "redis-replication"
Prudhvi0717 commented 11 months ago

still facing issue.. not able to resize PVC. When will this bug gets fixed.. @shubham-cmyk ?