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

namePrefix ignores storageClassName reference in volumeClaimTemplates #1347

Closed
trajakovic opened this issue Jul 13, 2019 · 5 comments
Closed

Comments

@trajakovic
Copy link

trajakovic commented Jul 13, 2019

Adding a namePrefix or nameSuffix ignores storageClassName inside StatefulSet spec.volumeClaimTemplates.

Version

Version: {KustomizeVersion:3.0.2 GitCommit:aa2313c2825a7712b12309c1cd7798f371a0bb18 BuildDate:2019-07-12T20:43:56Z GoOs:darwin GoArch:amd64}

Input

base/demo.yaml

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: storage
  labels:
    k8s-addon: storage-aws.addons.k8s.io
provisioner: kubernetes.io/aws-ebs
reclaimPolicy: Retain
allowVolumeExpansion: true
parameters:
  type: gp2
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: demo
  namespace: demo
spec:
  selector:
    matchLabels:
      app: demo
  replicas: 3
  updateStrategy:
    type: RollingUpdate
  podManagementPolicy: Parallel
  template:
    metadata:
      labels:
        app: demo
      annotations:
    spec:
      containers:
        - name: demo
          image: alpine:3.9
          volumeMounts:
            - name: data
              mountPath: /data
  volumeClaimTemplates:
    - metadata:
        name: data
      spec:
        accessModes: [ "ReadWriteOnce" ]
        storageClassName: storage
        resources:
          requests:
            storage: 10Gi

kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
bases:
  - ./base/demo.yaml
namespace: demo1
namePrefix: prefix-
nameSuffix: -suffix

Result

allowVolumeExpansion: true
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  labels:
    k8s-addon: storage-aws.addons.k8s.io
  name: prefix-storage-suffix
parameters:
  type: gp2
provisioner: kubernetes.io/aws-ebs
reclaimPolicy: Retain
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: prefix-demo-suffix
  namespace: demo1
spec:
  podManagementPolicy: Parallel
  replicas: 3
  selector:
    matchLabels:
      app: demo
  template:
    metadata:
      annotations: null
      labels:
        app: demo
    spec:
      containers:
      - image: alpine:3.9
        name: demo
        volumeMounts:
        - mountPath: /data
          name: data
  updateStrategy:
    type: RollingUpdate
  volumeClaimTemplates:
  - metadata:
      name: data
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 10Gi
      storageClassName: storage

Expectation

storageClassName in spec.volumeClaimTemplates with correct prefix- -suffix name.

@jbrette
Copy link
Contributor

jbrette commented Aug 28, 2019

@trajakovic It looks like @yujunz fixed the issue last month. We did reproduce your environment here and the bug seems to be fixed.

@trajakovic
Copy link
Author

@jbrette ok, will try it again with feedback. and thx guys for excellent work

@thiagoalvessilva
Copy link

Is there any workaround for this? I am using kubectl 1.1.14

@jbrette
Copy link
Contributor

jbrette commented Aug 31, 2019

@thiagoalvessilva Just download kustomize 3.1.0here and run:

kustomize build <myapp> | kubectl apply -f -

instead of

kubectl apply -k <myapp>

@trajakovic
Copy link
Author

trajakovic commented Sep 22, 2019

@jbrette I can confirm that latest released version Version: {KustomizeVersion:3.2.0 GitCommit:a3103f1e62ddb5b696daa3fd359bb6f2e8333b49 BuildDate:2019-09-18T16:26:36Z GoOs:darwin GoArch:amd64} doesn't have this issue anymore.

Thank you once again

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

3 participants