sai3010 / Typesense-Kubernetes-Operator

An operator to manage Typesense clusters on Kubernetes
Apache License 2.0
43 stars 11 forks source link

Error when updating via config-operator. #20

Open PavelNen opened 2 months ago

PavelNen commented 2 months ago

Describe the bug Attempting to apply a new configuration via config-operator.yaml for the Typesense StatefulSet results in an error. The Kubernetes API returns a 422 Unprocessable Entity status with the message that updates to fields other than 'replicas', 'ordinals', 'template', 'updateStrategy', 'persistentVolumeClaimRetentionPolicy', and 'minReadySeconds' in the StatefulSet spec are forbidden.

To Reproduce Steps to reproduce the behavior:

  1. Create or update a config-operator.yaml with the following StatefulSet configuration:
    
    # Configuration of Typesense fed to the operator goes here
    apiVersion: typesenseproject.org/v1
    kind: TypesenseOperator
    metadata:
    name: type-operator
    spec:
    replicas: 1
    namespace: typesense
    image: typesense/typesense:27.0.rc35
    env:
    - name: APIKEY
      valueFrom:
        secretKeyRef:
          name: typesense-apikey
          key: apikey
    resources:
    requests:
      memory: 2Gi
      cpu: "200m"
    limits:
      memory: 3Gi
      cpu: "500m"
    nodeSelector:
    kubernetes.io/os: linux
    # storageClass:
    #   name: yc-network-hdd
    #   size: "100Mi"
    startupProbe:
    failureThreshold: 10
    periodSeconds: 10
    livenessProbe:
    failureThreshold: 2
    periodSeconds: 10
    config:
    secret: "typesense-apikey"

apiVersion: v1 kind: Service metadata: name: typesense-external-service namespace: typesense spec: type: LoadBalancer selector: app: typesense ports:

Expected behavior The StatefulSet configuration should be updated successfully without any errors, allowing changes to the specified fields.

Please complete the following information:

Additional context The error appears to be related to restrictions on updating specific fields in the StatefulSet spec. Full error message from the logs:

Exception: Kubernetes API Exception - StatefulSet: {"kind":"Status","apiVersion":"v1","metadata":{},"status":"Failure","message":"StatefulSet.apps \"typesense\" is invalid: spec: Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordinals', 'template', 'updateStrategy', 'persistentVolumeClaimRetentionPolicy' and 'minReadySeconds' are forbidden","reason":"Invalid","details":{"name":"typesense","group":"apps","kind":"StatefulSet","causes":[{"reason":"FieldValueForbidden","message":"Forbidden: updates to statefulset spec for fields other than 'replicas', 'ordinals', 'template', 'updateStrategy', 'persistentVolumeClaimRetentionPolicy' and 'minReadySeconds' are forbidden","field":"spec"}]},"code":422}

If I want to update the settings, I just do kubectl delete-f operator-config.yaml and kubectl delete -f deploy/operator. yaml and apply them again with new properties. In addition it is easier to manually configure StatefulSet and build your own container for installation

sai3010 commented 2 months ago

Hi @PavelNen , Thanks for raising this, will check this out. Meanwhile please join our community here: https://join.slack.com/t/typesensekube-uma7122/shared_invite/zt-2psm6rw7l-2kzi2oR3~GLAUhaHw381mA

sai3010 commented 1 month ago

Hi @PavelNen , the support for supplying env is part of the new release, otherwise, the fields mentioned should get applied when you execute kubectl apply -f <>. ` could you confirm?

PavelNen commented 1 month ago

@sai3010 I spent some time with the new configuration, the configuration is updated correctly. /health returns OK

but it seems that the apikey key is now used incorrectly when creating an instance, the key did not change. "Forbidden - a valid x-typesense-api-key header must be sent."

PavelNen commented 1 month ago

@sai3010 you forgot to update the version of the operator image in operator.yaml