@@ -54,6 +54,9 @@ type AttachedDiskSpec struct {
54
54
// Defaults to 30GB. For "local-ssd" size is always 375GB.
55
55
// +optional
56
56
Size * int64 `json:"size,omitempty"`
57
+ // EncryptionKey defines the KMS key to be used to encrypt the disk.
58
+ // +optional
59
+ EncryptionKey * CustomerEncryptionKey `json:"encryptionKey,omitempty"`
57
60
}
58
61
59
62
// IPForwarding represents the IP forwarding configuration for the GCP machine.
@@ -146,6 +149,70 @@ const (
146
149
HostMaintenancePolicyTerminate HostMaintenancePolicy = "Terminate"
147
150
)
148
151
152
+ // KeyType is a type for disk encryption.
153
+ type KeyType string
154
+
155
+ const (
156
+ // CustomerManagedKey (CMEK) references an encryption key stored in Google Cloud KMS.
157
+ CustomerManagedKey KeyType = "Managed"
158
+ // CustomerSuppliedKey (CSEK) specifies an encryption key to use.
159
+ CustomerSuppliedKey KeyType = "Supplied"
160
+ )
161
+
162
+ // ManagedKey is a reference to a key managed by the Cloud Key Management Service.
163
+ type ManagedKey struct {
164
+ // KMSKeyName is the name of the encryption key that is stored in Google Cloud KMS. For example:
165
+ // "kmsKeyName": "projects/kms_project_id/locations/region/keyRings/key_region/cryptoKeys/key
166
+ // +kubebuilder:validation:Required
167
+ // +kubebuilder:validation:Pattern=`projects\/[-_[A-Za-z0-9]+\/locations\/[-_[A-Za-z0-9]+\/keyRings\/[-_[A-Za-z0-9]+\/cryptoKeys\/[-_[A-Za-z0-9]+`
168
+ KMSKeyName string `json:"kmsKeyName,omitempty"`
169
+ }
170
+
171
+ // SuppliedKey contains a key for disk encryption. Either RawKey or RSAEncryptedKey must be provided.
172
+ // +kubebuilder:validation:MinProperties=1
173
+ type SuppliedKey struct {
174
+ // RawKey specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
175
+ // base64 to either encrypt or decrypt this resource. You can provide either the rawKey or the rsaEncryptedKey.
176
+ // For example: "rawKey": "SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0="
177
+ // +optional
178
+ RawKey []byte `json:"rawKey,omitempty"`
179
+ // RSAEncryptedKey specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied encryption
180
+ // key to either encrypt or decrypt this resource. You can provide either the rawKey or the
181
+ // rsaEncryptedKey.
182
+ // For example: "rsaEncryptedKey": "ieCx/NcW06PcT7Ep1X6LUTc/hLvUDYyzSZPPVCVPTVEohpeHASqC8uw5TzyO9U+Fka9JFHi
183
+ // z0mBibXUInrC/jEk014kCK/NPjYgEMOyssZ4ZINPKxlUh2zn1bV+MCaTICrdmuSBTWlUUiFoDi
184
+ // D6PYznLwh8ZNdaheCeZ8ewEXgFQ8V+sDroLaN3Xs3MDTXQEMMoNUXMCZEIpg9Vtp9x2oe=="
185
+ // The key must meet the following requirements before you can provide it to Compute Engine:
186
+ // 1. The key is wrapped using a RSA public key certificate provided by Google.
187
+ // 2. After being wrapped, the key must be encoded in RFC 4648 base64 encoding.
188
+ // Gets the RSA public key certificate provided by Google at: https://cloud-certs.storage.googleapis.com/google-cloud-csek-ingress.pem
189
+ // +optional
190
+ RSAEncryptedKey []byte `json:"rsaEncryptedKey,omitempty"`
191
+ }
192
+
193
+ // CustomerEncryptionKey supports both Customer-Managed or Customer-Supplied encryption keys .
194
+ type CustomerEncryptionKey struct {
195
+ // KeyType is the type of encryption key. Must be either Managed, aka Customer-Managed Encryption Key (CMEK) or
196
+ // Supplied, aka Customer-Supplied EncryptionKey (CSEK).
197
+ // +kubebuilder:validation:Enum=Managed;Supplied
198
+ KeyType KeyType `json:"keyType"`
199
+ // KMSKeyServiceAccount is the service account being used for the encryption request for the given KMS key.
200
+ // If absent, the Compute Engine default service account is used. For example:
201
+ // "kmsKeyServiceAccount": "name@project_id.iam.gserviceaccount.com.
202
+ // The maximum length is based on the Service Account ID (max 30), Project (max 30), and a valid gcloud email
203
+ // suffix ("iam.gserviceaccount.com").
204
+ // +kubebuilder:validation:MaxLength=85
205
+ // +kubebuilder:validation:XValidation:rule=`self.endsWith('.iam.gserviceaccount.com')`,message=`kmsKeyServiceAccount must be a valid gcloud service account. Must end with '.iam.gserviceaccount.com'.`
206
+ // +optional
207
+ KMSKeyServiceAccount * string `json:"kmsKeyServiceAccount,omitempty"`
208
+ // ManagedKey references keys managed by the Cloud Key Management Service. This should be set when KeyType is Managed.
209
+ // +optional
210
+ ManagedKey * ManagedKey `json:"managedKey,omitempty"`
211
+ // SuppliedKey provides the key used to create or manage a disk. This should be set when KeyType is Managed.
212
+ // +optional
213
+ SuppliedKey * SuppliedKey `json:"suppliedKey,omitempty"`
214
+ }
215
+
149
216
// GCPMachineSpec defines the desired state of GCPMachine.
150
217
type GCPMachineSpec struct {
151
218
// InstanceType is the type of instance to create. Example: n1.standard-2
@@ -252,6 +319,10 @@ type GCPMachineSpec struct {
252
319
// +kubebuilder:validation:Enum=Enabled;Disabled
253
320
// +optional
254
321
ConfidentialCompute * ConfidentialComputePolicy `json:"confidentialCompute,omitempty"`
322
+
323
+ // RootDiskEncryptionKey defines the KMS key to be used to encrypt the root disk.
324
+ // +optional
325
+ RootDiskEncryptionKey * CustomerEncryptionKey `json:"rootDiskEncryptionKey,omitempty"`
255
326
}
256
327
257
328
// MetadataItem defines a single piece of metadata associated with an instance.
0 commit comments