Skip to content
Merged
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
22 changes: 16 additions & 6 deletions api/v1alpha1/vpc_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,17 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// VPCFinalizer is the finalizer applied to VPCs to ensure graceful cleanup.
const VPCFinalizer = "cloud.datumapis.com/finalizer"

// Network is an IPv4 or IPv6 CIDR block (e.g., "10.0.0.0/24").
// +kubebuilder:validation:MaxLength=64
type Network string

// VPCSpec defines the desired state of a VPC. It specifies the CIDR address space.
//
// +kubebuilder:validation:XValidation:rule="self.networks.all(n, isCIDR(n))",message="each network must be a valid IPv4 or IPv6 CIDR"
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="spec is immutable"
type VPCSpec struct {
// CIDR blocks that form the VPC address space.
// +kubebuilder:validation:MinItems=1
Expand All @@ -37,19 +41,25 @@ type VPCSpec struct {

// VPCStatus defines the observed state of a VPC, populated by the controller.
type VPCStatus struct {
// True when the VPC is provisioned and ready for attachments.
// +required
// +default:value=false
Ready bool `json:"ready,omitempty"`
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

// Opaque controller-assigned identifier for this VPC.
// +listType=map
// +listMapKey=type
// +optional
Identifier string `json:"identifier,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`

// Base62-encoded VPC identifier.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=16
VPC string `json:"vpc"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
// +kubebuilder:printcolumn:name="VPC",type="string",JSONPath=".status.vpc",description="Base62 VPC identifier"
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",description="Ready status"

// VPC represents a virtual private cloud — an isolated Layer 2 domain backed
// by one or more CIDR blocks.
Expand Down
55 changes: 49 additions & 6 deletions api/v1alpha1/vpcattachment_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
const VPCAttachmentAnnotation = "k8s.v1alpha1.cloud.datumapis.com/vpc-attachment"

// VPCAttachmentSpec defines the desired state of VPCAttachment
//
// +kubebuilder:validation:XValidation:rule="has(self.vpc) && self.vpc.name != ”",message="vpc reference is required"
type VPCAttachmentSpec struct {
// VPC this attachment belongs to.
// +required
Expand Down Expand Up @@ -63,14 +65,55 @@ type VPCAttachmentInterface struct {

// VPCAttachmentStatus defines the observed state of VPCAttachment.
type VPCAttachmentStatus struct {
// Indicates whether the VPCAttachment is ready for use
// +required
// +default:value=false
Ready bool `json:"ready,omitempty"`
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

// A unique identifier assigned to this VPCAttachment
// +listType=map
// +listMapKey=type
// +optional
Identifier string `json:"identifier,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`

// Base62-encoded VPC identifier.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=16
VPC string `json:"vpc"`

// Base62-encoded VPCAttachment identifier.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:validation:MaxLength=16
VPCAttachment string `json:"vpcAttachment"`

// Kubernetes node name where the attachment lives.
// +kubebuilder:validation:MinLength=1
Node string `json:"node"`

// Full container ID (46 hex characters).
// +kubebuilder:validation:MinLength=46
// +kubebuilder:validation:MaxLength=46
ContainerID string `json:"containerID"`

// Pod name.
// +kubebuilder:validation:MinLength=1
PodName string `json:"podName"`

// Host-side veth device name (e.g., "G000000010010H").
// +kubebuilder:validation:MinLength=1
HostInterface string `json:"hostInterface"`

// VRF device name (e.g., "G000000010010V").
// +kubebuilder:validation:MinLength=1
VRFInterface string `json:"vrfInterface"`

// Guest-side veth device name (e.g., "G000000010010G").
// +kubebuilder:validation:MinLength=1
// +optional
GuestInterface string `json:"guestInterface,omitempty"`

// Allocated /80 subnet in CIDR notation (e.g., "fd00:10:ff01:0:1::/80").
// +kubebuilder:validation:MinLength=1
//
// +kubebuilder:validation:XValidation:rule="isCIDR(self)",message="podSubnet must be a valid IPv6 CIDR"
PodSubnet string `json:"podSubnet"`
}

// +kubebuilder:object:root=true
Expand Down
19 changes: 17 additions & 2 deletions api/v1alpha1/zz_generated.deepcopy.go

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

121 changes: 114 additions & 7 deletions config/crd/cloud.datumapis.com_vpcattachments.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,125 @@ spec:
- interface
- vpc
type: object
x-kubernetes-validations:
- message: vpc reference is required
rule: has(self.vpc) && self.vpc.name != ''
status:
description: status defines the observed state of VPCAttachment
properties:
identifier:
description: A unique identifier assigned to this VPCAttachment
conditions:
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.
This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable.
format: date-time
type: string
message:
description: |-
message is a human readable message indicating details about the transition.
This may be an empty string.
maxLength: 32768
type: string
observedGeneration:
description: |-
observedGeneration represents the .metadata.generation that the condition was set based upon.
For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date
with respect to the current state of the instance.
format: int64
minimum: 0
type: integer
reason:
description: |-
reason contains a programmatic identifier indicating the reason for the condition's last transition.
Producers of specific condition types may define expected values and meanings for this field,
and whether the values are considered a guaranteed API.
The value should be a CamelCase string.
This field may not be empty.
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 or in foo.example.com/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
type: array
x-kubernetes-list-map-keys:
- type
x-kubernetes-list-type: map
containerID:
description: Full container ID (46 hex characters).
maxLength: 46
minLength: 46
type: string
guestInterface:
description: Guest-side veth device name (e.g., "G000000010010G").
minLength: 1
type: string
hostInterface:
description: Host-side veth device name (e.g., "G000000010010H").
minLength: 1
type: string
node:
description: Kubernetes node name where the attachment lives.
minLength: 1
type: string
observedGeneration:
format: int64
type: integer
podName:
description: Pod name.
minLength: 1
type: string
podSubnet:
description: Allocated /80 subnet in CIDR notation (e.g., "fd00:10:ff01:0:1::/80").
minLength: 1
type: string
x-kubernetes-validations:
- message: podSubnet must be a valid IPv6 CIDR
rule: isCIDR(self)
vpc:
description: Base62-encoded VPC identifier.
maxLength: 16
minLength: 1
type: string
vpcAttachment:
description: Base62-encoded VPCAttachment identifier.
maxLength: 16
minLength: 1
type: string
vrfInterface:
description: VRF device name (e.g., "G000000010010V").
minLength: 1
type: string
ready:
default: false
description: Indicates whether the VPCAttachment is ready for use
type: boolean
required:
- ready
- containerID
- hostInterface
- node
- podName
- podSubnet
- vpc
- vpcAttachment
- vrfInterface
type: object
required:
- spec
Expand Down
Loading
Loading