Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions manifests/supervisorcluster/1.33/cns-csi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ rules:
- apiGroups: ["cns.vmware.com"]
resources: ["cnsvolumeinfoes/status"]
verbs: ["patch"]
- apiGroups: ["cns.vmware.com"]
resources: ["csivolumeinfos"]
verbs: ["create", "get", "list", "watch", "delete", "patch", "update"]
- apiGroups: ["cns.vmware.com"]
resources: ["csivolumeinfos/status"]
verbs: ["update", "patch"]
- apiGroups: ["crd.nsx.vmware.com"]
resources: ["networkinfos"]
verbs: ["get", "watch", "list"]
Expand Down Expand Up @@ -791,6 +797,9 @@ rules:
- apiGroups: ["vmoperator.vmware.com"]
resources: ["virtualmachines"]
verbs: ["get", "list"]
- apiGroups: ["cns.vmware.com"]
resources: ["csivolumeinfos"]
verbs: ["get", "list"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
9 changes: 9 additions & 0 deletions manifests/supervisorcluster/1.34/cns-csi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ rules:
- apiGroups: ["cns.vmware.com"]
resources: ["cnsvolumeinfoes/status"]
verbs: ["patch"]
- apiGroups: ["cns.vmware.com"]
resources: ["csivolumeinfos"]
verbs: ["create", "get", "list", "watch", "delete", "patch", "update"]
- apiGroups: ["cns.vmware.com"]
resources: ["csivolumeinfos/status"]
verbs: ["update", "patch"]
- apiGroups: ["crd.nsx.vmware.com"]
resources: ["networkinfos"]
verbs: ["get", "watch", "list"]
Expand Down Expand Up @@ -791,6 +797,9 @@ rules:
- apiGroups: ["vmoperator.vmware.com"]
resources: ["virtualmachines"]
verbs: ["get", "list"]
- apiGroups: ["cns.vmware.com"]
resources: ["csivolumeinfos"]
verbs: ["get", "list"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
9 changes: 9 additions & 0 deletions manifests/supervisorcluster/1.35/cns-csi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ rules:
- apiGroups: ["cns.vmware.com"]
resources: ["cnsvolumeinfoes/status"]
verbs: ["patch"]
- apiGroups: ["cns.vmware.com"]
resources: ["csivolumeinfos"]
verbs: ["create", "get", "list", "watch", "delete", "patch", "update"]
- apiGroups: ["cns.vmware.com"]
resources: ["csivolumeinfos/status"]
verbs: ["update", "patch"]
- apiGroups: ["crd.nsx.vmware.com"]
resources: ["networkinfos"]
verbs: ["get", "watch", "list"]
Expand Down Expand Up @@ -791,6 +797,9 @@ rules:
- apiGroups: ["vmoperator.vmware.com"]
resources: ["virtualmachines"]
verbs: ["get", "list"]
- apiGroups: ["cns.vmware.com"]
resources: ["csivolumeinfos"]
verbs: ["get", "list"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ const (
ReasonDetachFailed = "DetachFailed"
// ReasonFailed reflects that the CR instance is not yet ready.
ReasonFailed = "Failed"
// ReasonDroppedBySnapshotRevert reflects that the volume was removed from the VM
// as part of a snapshot revert operation. vSphere has already removed the disk;
// no ReconfigVM call is needed.
ReasonDroppedBySnapshotRevert = "DroppedBySnapshotRevert"
// ReasonDetachBlocked reflects that a ReconfigVM remove was blocked, typically
// because a vSphere snapshot still retains the disk.
ReasonDetachBlocked = "DetachBlocked"
)

// SharingMode is the sharing mode of the virtual disk.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
creationTimestamp: null
name: csivolumeinfos.cns.vmware.com
spec:
group: cns.vmware.com
names:
kind: CsiVolumeInfo
listKind: CsiVolumeInfoList
plural: csivolumeinfos
shortNames:
- cvi
singular: csivolumeinfo
scope: Namespaced
versions:
- additionalPrinterColumns:
- jsonPath: .status.ownershipState
name: OwnershipState
type: string
- jsonPath: .status.vmName
name: VMName
type: string
- jsonPath: .status.diskUUID
name: diskUUID
type: string
- jsonPath: .status.diskPath
name: diskPath
type: string
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
name: v1alpha1
schema:
openAPIV3Schema:
description: CsiVolumeInfo tracks the per-volume ownership lifecycle for
the VM-owned volume attach/detach model. One CR exists per PVC (in the
PVC's namespace) from the moment it is provisioned (while VMOwnedVolumes
FSS is enabled) until its owning PV is deleted.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: CsiVolumeInfoSpec defines the desired (immutable) state
of CsiVolumeInfo. All fields are set at creation time and must not change
except pvcName on Retain-reclaim rebind.
properties:
pvName:
description: PVName is the bound PV name. The CVI carries a PV ownerReference
so PV deletion cascades CVI deletion via K8s GC.
type: string
pvcName:
description: PVCName is the bound PVC name at CVI creation (or last
bind update on Retain-reclaim rebind). Together with metadata.namespace,
uniquely identifies the PVC.
type: string
volumeID:
description: VolumeID is the CNS volume ID. Immutable after creation.
Matches PV.spec.csi.volumeHandle.
minLength: 1
type: string
required:
- pvName
- pvcName
- volumeID
type: object
status:
description: CsiVolumeInfoStatus defines the observed state of CsiVolumeInfo.
All writes go through the /status subresource endpoint.
properties:
conditions:
description: Conditions is a standard K8s condition array for extensible
status.
items:
description: "Condition contains details for one aspect of the current
state of this API Resource."
properties:
lastTransitionTime:
description: lastTransitionTime is the last time the condition
transitioned from one status to another.
format: date-time
type: string
message:
description: message is a human readable message indicating
details about the transition.
maxLength: 32768
type: string
observedGeneration:
description: observedGeneration represents the .metadata.generation
that the condition was set based upon.
format: int64
minimum: 0
type: integer
reason:
description: reason contains a programmatic identifier indicating
the reason for the condition's last transition.
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: status of the condition, one of True, False, Unknown.
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: type of condition in CamelCase.
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- lastTransitionTime
- message
- reason
- status
- type
type: object
maxItems: 8
type: array
x-kubernetes-list-map-keys:
- type
x-kubernetes-list-type: map
diskPath:
description: DiskPath is the datastore path to the VMDK file. An
informational JIT cache — may be stale at rest. Refreshed at each
consumption point (attach, detach, snapshot-delete, revert).
type: string
diskUUID:
description: DiskUUID is the stable identifier for the virtual disk
(VirtualDisk.Backing.Uuid). Populated at CVI creation from the FCD's
backing VMDK. Immutable after creation.
type: string
ownershipState:
description: OwnershipState is the current ownership lifecycle state
of the volume. One of CSI_MANAGED, TRANSFERRING_TO_VM, VM_MANAGED,
TRANSFERRING_TO_CSI.
enum:
- CSI_MANAGED
- TRANSFERRING_TO_VM
- VM_MANAGED
- TRANSFERRING_TO_CSI
type: string
vmInstanceUUID:
description: VMInstanceUUID is the instance UUID of the VM identified
by VMName. Empty when CSI-owned or snapshot-retained.
type: string
vmName:
description: VMName is the name of the VirtualMachine CR this volume
is attached to. Empty when CSI-owned or snapshot-retained.
type: string
required:
- diskUUID
- ownershipState
type: object
required:
- spec
type: object
served: true
storage: true
subresources:
status: {}
24 changes: 24 additions & 0 deletions pkg/apis/cnsoperator/csivolumeinfo/config/config.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
Copyright 2026 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package config

import "embed"

//go:embed cns.vmware.com_csivolumeinfos.yaml
var EmbedCsiVolumeInfoFile embed.FS

const EmbedCsiVolumeInfoFileName = "cns.vmware.com_csivolumeinfos.yaml"
Loading