Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unknown field "spec.volume.volumeClaimTemplates.name" #170

Open
nikolaiorda opened this issue Dec 22, 2023 · 6 comments
Open

unknown field "spec.volume.volumeClaimTemplates.name" #170

nikolaiorda opened this issue Dec 22, 2023 · 6 comments

Comments

@nikolaiorda
Copy link

Hello,

I'm trying to apply custom settings with volumeClaimTemplates option from this doc: https://www.kubegres.io/doc/properties-explained.html
However, it does not work even with the example from that link. The error below:

kubectl apply -f my-postgres.yaml
Error from server (BadRequest): error when creating "my-postgres.yaml": Kubegres in version "v1" cannot be handled as a Kubegres: strict decoding error: unknown field "spec.volume.volumeClaimTemplates.name", unknown field "spec.volume.volumeClaimTemplates.spec"

To test it, just follow steps from "Getting started" and add the volume section from the "All properties explained" article. All settings are default.
Is it a bug or the documentation is outdated?
Thank you in advance.

@alex-arica
Copy link
Member

Hi,
Let me help me with this.
Could you please share the contents of the YAML that you tried to apply with kubectl ?

@nikolaiorda
Copy link
Author

Sure! Here you go:

apiVersion: kubegres.reactive-tech.io/v1
kind: Kubegres
metadata:
  name: mypostgres
  namespace: default

spec:

   replicas: 3
   image: postgres:16.1

   database:
      size: 200Mi

   env:
      - name: POSTGRES_PASSWORD
        valueFrom:
           secretKeyRef:
              name: mypostgres-secret
              key: superUserPassword

      - name: POSTGRES_REPLICATION_PASSWORD
        valueFrom:
           secretKeyRef:
              name: mypostgres-secret
              key: replicationUserPassword

   volume:

      volumeClaimTemplates:
         name: anyMount
         spec:
            accessModes: [ "ReadWriteOnce" ]
            storageClassName: local-storage
            resources:
              requests:
                storage: 1Gi

I was trying it woth "volumes" and "volumeMounts" before as well as with different paths and replacing anyMount with any other value. The result was always the same.

@alex-arica
Copy link
Member

You find an issue in the documentation. Thank you :)

I updated the doc and released the changes: https://www.kubegres.io/doc/properties-explained.html

Try the following, by adding the field "name" under "metadata":

   volume:

      volumeClaimTemplates:
        - metadata:
            name: anyMount
         spec:
            accessModes: [ "ReadWriteOnce" ]
            storageClassName: local-storage
            resources:
              requests:
                storage: 1Gi

@nikolaiorda
Copy link
Author

Thank you for your reply! Let's try to apply it:

apiVersion: kubegres.reactive-tech.io/v1
kind: Kubegres
metadata:
  name: mypostgres
  namespace: default

spec:

   replicas: 3
   image: postgres:16.1

   database:
      size: 200Mi

   env:
      - name: POSTGRES_PASSWORD
        valueFrom:
           secretKeyRef:
              name: mypostgres-secret
              key: superUserPassword

      - name: POSTGRES_REPLICATION_PASSWORD
        valueFrom:
           secretKeyRef:
              name: mypostgres-secret
              key: replicationUserPassword

   volume:

      volumeClaimTemplates:
        - metadata:
            name: anyMount
          spec:
            accessModes: [ "ReadWriteOnce" ]
            storageClassName: local-storage
            resources:
              requests:
                storage: 1Gi

(The indentation from the example above may not be accurate due to copying and pasting. I formatted it in a correct way on my lab environment)
And the result is the following:

kubectl apply -f my-postgres.yaml
Error from server (BadRequest): error when creating "my-postgres.yaml": Kubegres in version "v1" cannot be handled as a Kubegres: strict decoding error: unknown field "spec.volume.volumeClaimTemplates[0].metadata"

@alex-arica
Copy link
Member

alex-arica commented Dec 22, 2023

Oh you know what, it seems like the initial example in the documentation was correct. I did not notice in your initial YAML example that "-" was missing. Because "volumeClaimTemplates" is an array.
Could you please try as below?

For us it works fine.

   volume:

      volumeClaimTemplates:
        - name: anyMount
          spec:
             accessModes: [ "ReadWriteOnce" ]
             storageClassName: local-storage
             resources:
               requests:
                 storage: 1Gi

@nikolaiorda
Copy link
Author

Oh, indeed! It turns out I missed this point. Thank you Alex. It works fine now.

One more question (if I shouldn't create a new issue): can I use this option to override the default pvc setting? For example, to specify "matchLabels" to bind the kubegres pvc's only to the specific pv's. Or it's intended to add an additional pvc?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants