@@ -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,72 @@ 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
+ // +kubebuilder:validation:MaxLength=160
169
+ KMSKeyName string `json:"kmsKeyName,omitempty"`
170
+ }
171
+
172
+ // SuppliedKey contains a key for disk encryption. Either RawKey or RSAEncryptedKey must be provided.
173
+ // +kubebuilder:validation:MinProperties=1
174
+ // +kubebuilder:validation:MaxProperties=1
175
+ type SuppliedKey struct {
176
+ // RawKey specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
177
+ // base64 to either encrypt or decrypt this resource. You can provide either the rawKey or the rsaEncryptedKey.
178
+ // For example: "rawKey": "SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0="
179
+ // +optional
180
+ RawKey []byte `json:"rawKey,omitempty"`
181
+ // RSAEncryptedKey specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied encryption
182
+ // key to either encrypt or decrypt this resource. You can provide either the rawKey or the
183
+ // rsaEncryptedKey.
184
+ // For example: "rsaEncryptedKey": "ieCx/NcW06PcT7Ep1X6LUTc/hLvUDYyzSZPPVCVPTVEohpeHASqC8uw5TzyO9U+Fka9JFHi
185
+ // z0mBibXUInrC/jEk014kCK/NPjYgEMOyssZ4ZINPKxlUh2zn1bV+MCaTICrdmuSBTWlUUiFoDi
186
+ // D6PYznLwh8ZNdaheCeZ8ewEXgFQ8V+sDroLaN3Xs3MDTXQEMMoNUXMCZEIpg9Vtp9x2oe=="
187
+ // The key must meet the following requirements before you can provide it to Compute Engine:
188
+ // 1. The key is wrapped using a RSA public key certificate provided by Google.
189
+ // 2. After being wrapped, the key must be encoded in RFC 4648 base64 encoding.
190
+ // Gets the RSA public key certificate provided by Google at: https://cloud-certs.storage.googleapis.com/google-cloud-csek-ingress.pem
191
+ // +optional
192
+ RSAEncryptedKey []byte `json:"rsaEncryptedKey,omitempty"`
193
+ }
194
+
195
+ // CustomerEncryptionKey supports both Customer-Managed or Customer-Supplied encryption keys .
196
+ type CustomerEncryptionKey struct {
197
+ // KeyType is the type of encryption key. Must be either Managed, aka Customer-Managed Encryption Key (CMEK) or
198
+ // Supplied, aka Customer-Supplied EncryptionKey (CSEK).
199
+ // +kubebuilder:validation:Enum=Managed;Supplied
200
+ KeyType KeyType `json:"keyType"`
201
+ // KMSKeyServiceAccount is the service account being used for the encryption request for the given KMS key.
202
+ // If absent, the Compute Engine default service account is used. For example:
203
+ // "kmsKeyServiceAccount": "name@project_id.iam.gserviceaccount.com.
204
+ // The maximum length is based on the Service Account ID (max 30), Project (max 30), and a valid gcloud email
205
+ // suffix ("iam.gserviceaccount.com").
206
+ // +kubebuilder:validation:MaxLength=85
207
+ // +kubebuilder:validation:Pattern=`[-_[A-Za-z0-9]+@[-_[A-Za-z0-9]+.iam.gserviceaccount.com`
208
+ // +optional
209
+ KMSKeyServiceAccount * string `json:"kmsKeyServiceAccount,omitempty"`
210
+ // ManagedKey references keys managed by the Cloud Key Management Service. This should be set when KeyType is Managed.
211
+ // +optional
212
+ ManagedKey * ManagedKey `json:"managedKey,omitempty"`
213
+ // SuppliedKey provides the key used to create or manage a disk. This should be set when KeyType is Managed.
214
+ // +optional
215
+ SuppliedKey * SuppliedKey `json:"suppliedKey,omitempty"`
216
+ }
217
+
149
218
// GCPMachineSpec defines the desired state of GCPMachine.
150
219
type GCPMachineSpec struct {
151
220
// InstanceType is the type of instance to create. Example: n1.standard-2
@@ -252,6 +321,10 @@ type GCPMachineSpec struct {
252
321
// +kubebuilder:validation:Enum=Enabled;Disabled
253
322
// +optional
254
323
ConfidentialCompute * ConfidentialComputePolicy `json:"confidentialCompute,omitempty"`
324
+
325
+ // RootDiskEncryptionKey defines the KMS key to be used to encrypt the root disk.
326
+ // +optional
327
+ RootDiskEncryptionKey * CustomerEncryptionKey `json:"rootDiskEncryptionKey,omitempty"`
255
328
}
256
329
257
330
// MetadataItem defines a single piece of metadata associated with an instance.
0 commit comments