@@ -20,39 +20,164 @@ import (
2020 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2121)
2222
23+ // BucketAccessAuthenticationType specifies what authentication mechanism is used for provisioning
24+ // bucket access.
25+ // +enum
26+ // +kubebuilder:validation:Enum:="";Key;ServiceAccount
27+ type BucketAccessAuthenticationType string
28+
29+ const (
30+ // The driver should generate a protocol-appropriate access key that clients can use to
31+ // authenticate to the backend object store.
32+ BucketAccessAuthenticationTypeKey = "Key"
33+
34+ // The driver should configure the system such that Pods using the given ServiceAccount
35+ // authenticate to the backend object store automatically.
36+ BucketAccessAuthenticationTypeServiceAccount = "ServiceAccount"
37+ )
38+
39+ // BucketAccessMode describes the Read/Write mode an access should have for a bucket.
40+ // +enum
41+ // +kubebuilder:validation:Enum:=ReadWrite;ReadOnly;WriteOnly
42+ type BucketAccessMode string
43+
44+ const (
45+ // BucketAccessModeReadWrite represents read-write access mode.
46+ BucketAccessModeReadWrite BucketAccessMode = "ReadWrite"
47+
48+ // BucketAccessModeReadOnly represents read-only access mode.
49+ BucketAccessModeReadOnly BucketAccessMode = "ReadOnly"
50+
51+ // BucketAccessModeWriteOnly represents write-only access mode.
52+ BucketAccessModeWriteOnly BucketAccessMode = "WriteOnly"
53+ )
54+
2355// BucketAccessSpec defines the desired state of BucketAccess
56+ // +kubebuilder:validation:XValidation:message="serviceAccountName is immutable",rule="has(oldSelf.serviceAccountName) == has(self.serviceAccountName)"
2457type BucketAccessSpec struct {
25- // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
26- // Important: Run "make" to regenerate code after modifying this file
27- // The following markers will use OpenAPI v3 schema to validate the value
28- // More info: https://book.kubebuilder.io/reference/markers/crd-validation.html
58+ // bucketClaims is a list of BucketClaims the provisioned access must have permissions for,
59+ // along with per-BucketClaim access parameters and system output definitions.
60+ // At least one BucketClaim must be referenced.
61+ // Multiple references to the same BucketClaim are not permitted.
62+ // +required
63+ // +listType=map
64+ // +listMapKey=bucketClaimName
65+ // +kubebuilder:validation:MinItems=1
66+ // +kubebuilder:validation:XValidation:message="bucketClaims list is immutable",rule="self == oldSelf"
67+ BucketClaims []BucketClaimAccess `json:"bucketClaims"`
2968
30- // foo is an example field of BucketAccess. Edit bucketaccess_types.go to remove/update
69+ // bucketAccessClassName selects the BucketAccessClass for provisioning the access.
70+ // +required
71+ // +kubebuilder:validation:MinLength=1
72+ // +kubebuilder:validation:MaxLength=253
73+ // +kubebuilder:validation:XValidation:message="bucketAccessClassName is immutable",rule="self == oldSelf"
74+ BucketAccessClassName string `json:"bucketAccessClassName"`
75+
76+ // protocol is the object storage protocol that the provisioned access must use.
77+ // +required
78+ // +kubebuilder:validation:XValidation:message="protocol is immutable",rule="self == oldSelf"
79+ Protocol ObjectProtocol `json:"protocol"`
80+
81+ // serviceAccountName is the name of the Kubernetes ServiceAccount that user application Pods
82+ // intend to use for access to referenced BucketClaims.
83+ // This has different behavior based on the BucketAccessClass's defined AuthenticationType:
84+ // - Key: This field is ignored.
85+ // - ServiceAccount: This field is required. The driver should configure the system so that Pods
86+ // using the ServiceAccount authenticate to the object storage backend automatically.
3187 // +optional
32- Foo * string `json:"foo,omitempty"`
88+ // +kubebuilder:validation:MaxLength=253
89+ // +kubebuilder:validation:XValidation:message="serviceAccountName is immutable",rule="self == oldSelf"
90+ ServiceAccountName string `json:"serviceAccountName,omitempty"`
3391}
3492
3593// BucketAccessStatus defines the observed state of BucketAccess.
94+ // +kubebuilder:validation:XValidation:message="accountID is immutable once set",rule="!has(oldSelf.accountID) || has(self.accountID)"
95+ // +kubebuilder:validation:XValidation:message="accessedBuckets is immutable once set",rule="!has(oldSelf.accessedBuckets) || has(self.accessedBuckets)"
96+ // +kubebuilder:validation:XValidation:message="driverName is immutable once set",rule="!has(oldSelf.driverName) || has(self.driverName)"
97+ // +kubebuilder:validation:XValidation:message="authenticationType is immutable once set",rule="!has(oldSelf.authenticationType) || has(self.authenticationType)"
98+ // +kubebuilder:validation:XValidation:message="parameters is immutable once set",rule="!has(oldSelf.parameters) || has(self.parameters)"
3699type BucketAccessStatus struct {
37- // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
38- // Important: Run "make" to regenerate code after modifying this file
39-
40- // For Kubernetes API conventions, see:
41- // https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#typical-status-properties
42-
43- // conditions represent the current state of the BucketAccess resource.
44- // Each condition has a unique type and reflects the status of a specific aspect of the resource.
45- //
46- // Standard condition types include:
47- // - "Available": the resource is fully functional
48- // - "Progressing": the resource is being created or updated
49- // - "Degraded": the resource failed to reach or maintain its desired state
50- //
51- // The status of each condition is one of True, False, or Unknown.
100+ // readyToUse indicates that the BucketAccess is ready for consumption by workloads.
101+ ReadyToUse bool `json:"readyToUse"`
102+
103+ // accountID is the unique identifier for the backend access known to the driver.
104+ // This field is populated by the COSI Sidecar once access has been successfully granted.
105+ // +optional
106+ // +kubebuilder:validation:XValidation:message="accountId is immutable once set",rule="oldSelf == '' || self == oldSelf"
107+ AccountID string `json:"accountID"`
108+
109+ // accessedBuckets is a list of Buckets the provisioned access must have permissions for, along
110+ // with per-Bucket access options. This field is populated by the COSI Controller based on the
111+ // referenced BucketClaims in the spec.
112+ // +optional
52113 // +listType=map
53- // +listMapKey=type
114+ // +listMapKey=bucketName
115+ // +kubebuilder:validation:XValidation:message="accessedBuckets is immutable once set",rule="oldSelf.size() == 0 || self == oldSelf"
116+ AccessedBuckets []AccessedBucket `json:"accessedBuckets"`
117+
118+ // driverName holds a copy of the BucketAccessClass driver name from the time of BucketAccess
119+ // provisioning. This field is populated by the COSI Controller.
54120 // +optional
55- Conditions []metav1.Condition `json:"conditions,omitempty"`
121+ // +kubebuilder:validation:XValidation:message="driverName is immutable once set",rule="oldSelf == '' || self == oldSelf"
122+ DriverName string `json:"driverName"`
123+
124+ // authenticationType holds a copy of the BucketAccessClass authentication type from the time of
125+ // BucketAccess provisioning. This field is populated by the COSI Controller.
126+ // +optional
127+ // +kubebuilder:validation:XValidation:message="authenticationType is immutable once set",rule="oldSelf == '' || self == oldSelf"
128+ AuthenticationType BucketAccessAuthenticationType `json:"authenticationType"`
129+
130+ // parameters holds a copy of the BucketAccessClass parameters from the time of BucketAccess
131+ // provisioning. This field is populated by the COSI Controller.
132+ // +optional
133+ // +kubebuilder:validation:XValidation:message="accessedBuckets is immutable once set",rule="oldSelf.size() == 0 || self == oldSelf"
134+ Parameters map [string ]string `json:"parameters,omitempty"`
135+
136+ // error holds the most recent error message, with a timestamp.
137+ // This is cleared when provisioning is successful.
138+ // +optional
139+ Error * TimestampedError `json:"error,omitempty"`
140+ }
141+
142+ // BucketClaimAccess selects a BucketClaim for access, defines access parameters for the
143+ // corresponding bucket, and specifies where user-consumable bucket information and access
144+ // credentials for the accessed bucket will be stored.
145+ type BucketClaimAccess struct {
146+ // bucketClaimName is the name of a BucketClaim the access should have permissions for.
147+ // The BucketClaim must be in the same Namespace as the BucketAccess.
148+ // +required
149+ // +kubebuilder:validation:MinLength=1
150+ // +kubebuilder:validation:MaxLength=253
151+ BucketClaimName string `json:"bucketClaimName"`
152+
153+ // accessMode is the Read/Write access mode that the access should have for the bucket.
154+ // Possible values: ReadWrite, ReadOnly, WriteOnly.
155+ // +required
156+ AccessMode BucketAccessMode `json:"accessMode"`
157+
158+ // accessSecretName is the name of a Kubernetes Secret that COSI should create and populate with
159+ // bucket info and access credentials for the bucket.
160+ // The Secret is created in the same Namespace as the BucketAccess and is deleted when the
161+ // BucketAccess is deleted and deprovisioned.
162+ // The Secret name must be unique across all bucketClaimRefs for all BucketAccesses in the same
163+ // Namespace.
164+ // +required
165+ // +kubebuilder:validation:MinLength=1
166+ // +kubebuilder:validation:MaxLength=253
167+ AccessSecretName string `json:"accessSecretName"`
168+ }
169+
170+ // AccessedBucket identifies a Bucket and corresponding access parameters.
171+ type AccessedBucket struct {
172+ // bucketName is the name of a Bucket the access should have permissions for.
173+ // +required
174+ // +kubebuilder:validation:MinLength=1
175+ // +kubebuilder:validation:MaxLength=253
176+ BucketName string `json:"bucketName"`
177+
178+ // accessMode is the Read/Write access mode that the access should have for the bucket.
179+ // +required
180+ AccessMode BucketAccessMode `json:"accessMode"`
56181}
57182
58183// +kubebuilder:object:root=true
0 commit comments