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

Add Nutanix CSI snapshot controller addon #1734

Merged
merged 5 commits into from
Jan 14, 2022
Merged

Conversation

xmudrii
Copy link
Member

@xmudrii xmudrii commented Jan 14, 2022

What this PR does / why we need it:

This PR extends the Nutanix CSI driver addon to add the snapshot controller. The rest of the description explains how to test the snapshot controller.

Once the cluster is provisioned, create a VolumeSnapshotClass:

apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotClass
metadata:
  name: vsc
driver: csi.nutanix.com
parameters:
  storageType: NutanixVolumes
  csi.storage.k8s.io/snapshotter-secret-name: ntnx-secret
  csi.storage.k8s.io/snapshotter-secret-namespace: kube-system
deletionPolicy: Delete

After that, create a PVC and a pod that will use it:

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: csi-pvc-ntnx
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
  storageClassName: ntnx-csi
---
apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
  - image: nginx
    imagePullPolicy: IfNotPresent
    name: nginx
    ports:
    - containerPort: 80
      protocol: TCP
    volumeMounts:
      - mountPath: /var/lib/www/html
        name: csi-data-ntnx
  volumes:
  - name: csi-data-ntnx
    persistentVolumeClaim:
      claimName: csi-pvc-ntnx
      readOnly: false

Exec to the nginx pod and write some files in the /var/lib/www/html directory. After that, snapshot the volume:

apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshot
metadata:
  name: snapshot1
spec:
  volumeSnapshotClassName: vsc
  source:
    persistentVolumeClaimName: csi-pvc-ntnx

Wait for the snapshot to be complete, and then remove the PVC and the pod. Wait a while, and then create a new PVC that uses the snapshot:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: csi-pvc-ntnx-restored
spec:
  storageClassName: ntnx-csi
  dataSource:
    name: snapshot1
    kind: VolumeSnapshot
    apiGroup: snapshot.storage.k8s.io
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
---
apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
  - image: nginx
    imagePullPolicy: IfNotPresent
    name: nginx
    ports:
    - containerPort: 80
      protocol: TCP
    volumeMounts:
      - mountPath: /var/lib/www/html
        name: csi-data-ntnx
  volumes:
  - name: csi-data-ntnx
    persistentVolumeClaim:
      claimName: csi-pvc-ntnx-restored
      readOnly: false

Exec to the pod and check are the files you created earlier present.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #1726

Does this PR introduce a user-facing change?:

Extend the Nutanix CSI driver addon with the snapshot controller (see the PR description for more details)

/assign @kron4eg

Signed-off-by: Marko Mudrinić <mudrinic.mare@gmail.com>
Signed-off-by: Marko Mudrinić <mudrinic.mare@gmail.com>
Signed-off-by: Marko Mudrinić <mudrinic.mare@gmail.com>
@xmudrii xmudrii requested review from kron4eg and embik January 14, 2022 13:12
@kubermatic-bot kubermatic-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. labels Jan 14, 2022
@kubermatic-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: xmudrii

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubermatic-bot kubermatic-bot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Jan 14, 2022
@embik
Copy link
Member

embik commented Jan 14, 2022

We do not deploy the snapshot controller for other CSI addons (Azure, AWS) as separate addons but embed it into the CSI driver addon, why is this handled differently?

@kubermatic-bot kubermatic-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 14, 2022
@kubermatic-bot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 2947767199b03d9deff039bd684213566f135348

Signed-off-by: Marko Mudrinić <mudrinic.mare@gmail.com>
@xmudrii
Copy link
Member Author

xmudrii commented Jan 14, 2022

We do not deploy the snapshot controller for other CSI addons (Azure, AWS) as separate addons but embed it into the CSI driver addon, why is this handled differently?

We tend to organize addons in the same way as the vendor. In this concrete case, Nutanix provides the CSI driver and the snapshot controller as two separate Helm charts, therefore we have two addons. This makes maintaining, upgrading, and keeping addons in sync easier. Technically, it doesn't matter much, besides the fact that users will have to enable two addons if they want to use both.

@xmudrii
Copy link
Member Author

xmudrii commented Jan 14, 2022

/hold
Let's merge those two addons.

@kubermatic-bot kubermatic-bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 14, 2022
Signed-off-by: Marko Mudrinić <mudrinic.mare@gmail.com>
@kubermatic-bot kubermatic-bot removed the lgtm Indicates that a PR is ready to be merged. label Jan 14, 2022
@xmudrii
Copy link
Member Author

xmudrii commented Jan 14, 2022

/hold cancel

@kubermatic-bot kubermatic-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 14, 2022
@xmudrii xmudrii requested a review from kron4eg January 14, 2022 13:49
@kubermatic-bot kubermatic-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 14, 2022
@kubermatic-bot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 500d626825ddfe5303e7b2a9a645812ee8b40f46

@kubermatic-bot kubermatic-bot merged commit c46a69f into master Jan 14, 2022
@kubermatic-bot kubermatic-bot added this to the KubeOne 1.4 milestone Jan 14, 2022
@kubermatic-bot kubermatic-bot deleted the csi-snapshot-nutanix branch January 14, 2022 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Denotes that all commits in the pull request have the valid DCO signoff message. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Nutanix CSI driver
4 participants