Skip to content

Commit

Permalink
Add support for launch volumes (#361)
Browse files Browse the repository at this point in the history
* Add support for volume attachments during launch instance
  • Loading branch information
shyamradhakrishnan authored Mar 29, 2024
1 parent 5a4f2c9 commit a1ea85b
Show file tree
Hide file tree
Showing 17 changed files with 1,065 additions and 115 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ $(KUSTOMIZE): ## Download kustomize locally if necessary.
GOBIN=$(BIN_DIR)/ $(GO_INSTALL) sigs.k8s.io/kustomize/kustomize/v4 $(KUSTOMIZE_BIN) v4.5.2

$(GINKGO): ## Build ginkgo.
GOBIN=$(BIN_DIR)/ $(GO_INSTALL) github.com/onsi/ginkgo/v2/ginkgo $(GINKGO_BIN) v2.11.0
GOBIN=$(BIN_DIR)/ $(GO_INSTALL) github.com/onsi/ginkgo/v2/ginkgo $(GINKGO_BIN) v2.13.1

$(GOLANGCI_LINT): ## Build golanci-lint.
GOBIN=$(BIN_DIR)/ $(GO_INSTALL) github.com/golangci/golangci-lint/cmd/golangci-lint $(GOLANGCI_LINT_BIN) v1.44.0
Expand Down
11 changes: 11 additions & 0 deletions api/v1beta1/ocimachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ type OCIMachineSpec struct {
// DedicatedVmHostId defines the OCID of the dedicated VM host.
DedicatedVmHostId *string `json:"dedicatedVmHostId,omitempty"`

// Volume attachments to create as part of the launch instance operation.
LaunchVolumeAttachment []LaunchVolumeAttachment `json:"launchVolumeAttachments,omitempty"`

// Provider ID of the instance, this will be set by Cluster API provider itself,
// users should not set this parameter.
// +optional
Expand Down Expand Up @@ -134,6 +137,14 @@ type OCIMachineSpec struct {
// +optional
// Deprecated, please use NetworkDetails.NSGNames
NSGName string `json:"nsgName,omitempty"`

// Specifies whether to delete or preserve the boot volume when terminating an instance.
// When set to true, the boot volume is preserved. The default value is false.
PreserveBootVolume bool `json:"preserveBootVolume,omitempty"`

// Specifies whether to delete or preserve the data volumes created during launch when
//terminating an instance. When set to true, the data volumes are preserved. The default value is true.
PreserveDataVolumesCreatedAtLaunch bool `json:"preserveDataVolumesCreatedAtLaunch,omitempty"`
}

// OCIMachineStatus defines the observed state of OCIMachine.
Expand Down
87 changes: 87 additions & 0 deletions api/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,93 @@ type RemotePeeringConnection struct {
RPCConnectionId *string `json:"rpcConnectionId,omitempty"`
}

type VolumeType string

const (
IscsiType VolumeType = "iscsi"
)

// EncryptionInTransitTypeEnum Enum with underlying type: string
type EncryptionInTransitTypeEnum string

// Set of constants representing the allowable values for EncryptionInTransitTypeEnum
const (
EncryptionInTransitTypeNone EncryptionInTransitTypeEnum = "NONE"
EncryptionInTransitTypeBmEncryptionInTransit EncryptionInTransitTypeEnum = "BM_ENCRYPTION_IN_TRANSIT"
)

type LaunchVolumeAttachment struct {
// The type of volume. Valid value is iscsi.
Type VolumeType `json:"volumeType,omitempty"`

// The details of iscsi volume attachment.
IscsiAttachment LaunchIscsiVolumeAttachment `json:"launchIscsiVolumeAttachment,omitempty"`
}

// LaunchIscsiVolumeAttachment specifies the iscsi volume attachments to create as part of the launch instance operation.
type LaunchIscsiVolumeAttachment struct {
// The device name. To retrieve a list of devices for a given instance, see ListInstanceDevices.
Device *string `json:"device,omitempty"`

// A user-friendly name. Does not have to be unique, and it's changeable.
// Avoid entering confidential information.
DisplayName *string `json:"displayName,omitempty"`

// Whether the attachment was created in read-only mode.
IsReadOnly *bool `json:"isReadOnly,omitempty"`

// Whether the attachment should be created in shareable mode. If an attachment
// is created in shareable mode, then other instances can attach the same volume, provided
// that they also create their attachments in shareable mode. Only certain volume types can
// be attached in shareable mode. Defaults to false if not specified.
IsShareable *bool `json:"isShareable,omitempty"`

// The OCID of the volume. If CreateVolumeDetails is specified, this field must be omitted from the request.
VolumeId *string `json:"volumeId,omitempty"`

// LaunchCreateVolumeFromAttributes The details of the volume to create for CreateVolume operation.
LaunchCreateVolumeFromAttributes LaunchCreateVolumeFromAttributes `json:"launchCreateVolumeFromAttributes,omitempty"`

// Whether to use CHAP authentication for the volume attachment. Defaults to false.
UseChap *bool `json:"useChap,omitempty"`

// Whether to enable Oracle Cloud Agent to perform the iSCSI login and logout commands after the volume attach or detach operations for non multipath-enabled iSCSI attachments.
IsAgentAutoIscsiLoginEnabled *bool `json:"isAgentAutoIscsiLoginEnabled,omitempty"`

// Refer the top-level definition of encryptionInTransitType.
// The default value is NONE.
EncryptionInTransitType EncryptionInTransitTypeEnum `json:"encryptionInTransitType,omitempty"`
}

// LaunchCreateVolumeFromAttributes The details of the volume to create for CreateVolume operation.
type LaunchCreateVolumeFromAttributes struct {

// The size of the volume in GBs.
SizeInGBs *int64 `json:"sizeInGBs,omitempty"`

// The OCID of the compartment that contains the volume. If not provided,
// it will be inherited from the instance.
CompartmentId *string `json:"compartmentId,omitempty"`

// A user-friendly name. Does not have to be unique, and it's changeable.
// Avoid entering confidential information.
DisplayName *string `json:"displayName,omitempty"`

// The OCID of the Vault service key to assign as the master encryption key
// for the volume.
KmsKeyId *string `json:"kmsKeyId,omitempty"`

// The number of volume performance units (VPUs) that will be applied to this volume per GB,
// representing the Block Volume service's elastic performance options.
// See Block Volume Performance Levels (https://docs.cloud.oracle.com/iaas/Content/Block/Concepts/blockvolumeperformance.htm#perf_levels) for more information.
// Allowed values:
// * `0`: Represents Lower Cost option.
// * `10`: Represents Balanced option.
// * `20`: Represents Higher Performance option.
// * `30`-`120`: Represents the Ultra High Performance option.
VpusPerGB *int64 `json:"vpusPerGB,omitempty"`
}

const (
VCNNativeCNI CNIOptionEnum = "OCI_VCN_IP_NATIVE"
FlannelCNI CNIOptionEnum = "FLANNEL_OVERLAY"
Expand Down
130 changes: 130 additions & 0 deletions api/v1beta1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a1ea85b

Please sign in to comment.