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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ go.work.sum
.env

bin/
config/**/charts
7 changes: 6 additions & 1 deletion api/v1alpha/networkbinding_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,17 @@ const (
// +kubebuilder:subresource:status

// NetworkBinding is the Schema for the networkbindings API
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`
// +kubebuilder:printcolumn:name="Reason",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].reason`
type NetworkBinding struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

// +kubebuilder:validation:Required
Spec NetworkBindingSpec `json:"spec,omitempty"`
Spec NetworkBindingSpec `json:"spec,omitempty"`

// +kubebuilder:default={conditions:{{type:"Ready",status:"Unknown",reason:"Pending", message:"Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"}}}
Status NetworkBindingStatus `json:"status,omitempty"`
}

Expand Down
26 changes: 24 additions & 2 deletions api/v1alpha/networkcontext_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,41 @@ type NetworkContextStatus struct {
}

const (
// NetworkContextReady indicates that the network context is ready for use.
// NetworkContextReady indicates whether or not the network context is ready for use.
NetworkContextReady = "Ready"

// NetworkContextProgrammed indicates whether or not the network context has been programmed.
NetworkContextProgrammed = "Programmed"
)

const (
// NetworkContextProgrammedReasonNotProgrammed indicates that the network context is not ready because it has not been programmed.
NetworkContextProgrammedReasonNotProgrammed = "NotProgrammed"

// NetworkContextProgrammedReasonProgramming indicates that the network context is being programmed.
NetworkContextProgrammedReasonProgrammingInProgress = "ProgrammingInProgress"

// NetworkContextProgrammedReasonProgrammed indicates that the network context has been programmed.
NetworkContextProgrammedReasonProgrammed = "Programmed"

// NetworkContextReadyReasonReady indicates that the network context is ready for use.
NetworkContextReadyReasonReady = "Ready"
)

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status

// NetworkContext is the Schema for the networkcontexts API
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`
// +kubebuilder:printcolumn:name="Reason",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].reason`
type NetworkContext struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec NetworkContextSpec `json:"spec,omitempty"`
Spec NetworkContextSpec `json:"spec,omitempty"`

// +kubebuilder:default={conditions:{{type:"Programmed",status:"Unknown",reason:"Pending", message:"Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"},{type:"Ready",status:"Unknown",reason:"Pending", message:"Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"}}}
Status NetworkContextStatus `json:"status,omitempty"`
}

Expand Down
34 changes: 33 additions & 1 deletion api/v1alpha/subnet_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,47 @@ type SubnetStatus struct {
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

const (
// SubnetAllocated indicates that the subnet has been allocated a prefix
SubnetAllocated = "Allocated"

// SubnetProgrammed indicates that the subnet has been programmed
SubnetProgrammed = "Programmed"

// SubnetReady indicates that the subnet is ready to use
SubnetReady = "Ready"
)

const (
// SubnetProgrammedReasonNotProgrammed indicates that the subnet has not been programmed
SubnetProgrammedReasonNotProgrammed = "NotProgrammed"

// SubnetProgrammedReasonProgrammingInProgress indicates that the subnet is being programmed.
SubnetProgrammedReasonProgrammingInProgress = "ProgrammingInProgress"

// SubnetProgrammedReasonProgrammed indicates that the subnet has been programmed
SubnetProgrammedReasonProgrammed = "Programmed"

// SubnetReadyReasonReady indicates that the subnet is ready to use
SubnetReadyReasonReady = "Ready"
)

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status

// Subnet is the Schema for the subnets API
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`
// +kubebuilder:printcolumn:name="Reason",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].reason`
// +kubebuilder:printcolumn:name="Start Address",type=string,JSONPath=`.status.startAddress`
// +kubebuilder:printcolumn:name="Prefix Length",type=string,JSONPath=`.status.prefixLength`
type Subnet struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec SubnetSpec `json:"spec,omitempty"`
Spec SubnetSpec `json:"spec,omitempty"`

// +kubebuilder:default={conditions:{{type:"Allocated",status:"Unknown",reason:"Pending", message:"Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"},{type:"Programmed",status:"Unknown",reason:"Pending", message:"Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"},{type:"Ready",status:"Unknown",reason:"Pending", message:"Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"}}}
Status SubnetStatus `json:"status,omitempty"`
}

Expand Down
7 changes: 6 additions & 1 deletion api/v1alpha/subnetclaim_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,16 @@ type SubnetClaimStatus struct {
// +kubebuilder:subresource:status

// SubnetClaim is the Schema for the subnetclaims API
// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp"
// +kubebuilder:printcolumn:name="Ready",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].status`
// +kubebuilder:printcolumn:name="Reason",type=string,JSONPath=`.status.conditions[?(@.type=="Ready")].reason`
type SubnetClaim struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec SubnetClaimSpec `json:"spec,omitempty"`
Spec SubnetClaimSpec `json:"spec,omitempty"`

// +kubebuilder:default={conditions:{{type:"Allocated",status:"Unknown",reason:"Pending", message:"Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"},{type:"Programmed",status:"Unknown",reason:"Pending", message:"Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"},{type:"Ready",status:"Unknown",reason:"Pending", message:"Waiting for controller", lastTransitionTime: "1970-01-01T00:00:00Z"}}}
Status SubnetClaimStatus `json:"status,omitempty"`
}

Expand Down
5 changes: 5 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ func main() {
os.Exit(1)
}

if err = controller.AddIndexers(ctx, mgr); err != nil {
setupLog.Error(err, "unable to add indexers")
os.Exit(1)
}

validationOpts := validation.GatewayValidationOptions{
ControllerName: serverConfig.Gateway.ControllerName,
PermittedTLSOptions: serverConfig.Gateway.PermittedTLSOptions,
Expand Down
19 changes: 18 additions & 1 deletion config/crd/bases/networking.datumapis.com_networkbindings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,17 @@ spec:
singular: networkbinding
scope: Namespaced
versions:
- name: v1alpha
- additionalPrinterColumns:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
- jsonPath: .status.conditions[?(@.type=="Ready")].status
name: Ready
type: string
- jsonPath: .status.conditions[?(@.type=="Ready")].reason
name: Reason
type: string
name: v1alpha
schema:
openAPIV3Schema:
description: NetworkBinding is the Schema for the networkbindings API
Expand Down Expand Up @@ -72,6 +82,13 @@ spec:
- network
type: object
status:
default:
conditions:
- lastTransitionTime: "1970-01-01T00:00:00Z"
message: Waiting for controller
reason: Pending
status: Unknown
type: Ready
description: NetworkBindingStatus defines the observed state of NetworkBinding
properties:
conditions:
Expand Down
24 changes: 23 additions & 1 deletion config/crd/bases/networking.datumapis.com_networkcontexts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,17 @@ spec:
singular: networkcontext
scope: Namespaced
versions:
- name: v1alpha
- additionalPrinterColumns:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
- jsonPath: .status.conditions[?(@.type=="Ready")].status
name: Ready
type: string
- jsonPath: .status.conditions[?(@.type=="Ready")].reason
name: Reason
type: string
name: v1alpha
schema:
openAPIV3Schema:
description: NetworkContext is the Schema for the networkcontexts API
Expand Down Expand Up @@ -66,6 +76,18 @@ spec:
- network
type: object
status:
default:
conditions:
- lastTransitionTime: "1970-01-01T00:00:00Z"
message: Waiting for controller
reason: Pending
status: Unknown
type: Programmed
- lastTransitionTime: "1970-01-01T00:00:00Z"
message: Waiting for controller
reason: Pending
status: Unknown
type: Ready
description: NetworkContextStatus defines the observed state of NetworkContext
properties:
conditions:
Expand Down
29 changes: 28 additions & 1 deletion config/crd/bases/networking.datumapis.com_subnetclaims.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,17 @@ spec:
singular: subnetclaim
scope: Namespaced
versions:
- name: v1alpha
- additionalPrinterColumns:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
- jsonPath: .status.conditions[?(@.type=="Ready")].status
name: Ready
type: string
- jsonPath: .status.conditions[?(@.type=="Ready")].reason
name: Reason
type: string
name: v1alpha
schema:
openAPIV3Schema:
description: SubnetClaim is the Schema for the subnetclaims API
Expand Down Expand Up @@ -84,6 +94,23 @@ spec:
- subnetClass
type: object
status:
default:
conditions:
- lastTransitionTime: "1970-01-01T00:00:00Z"
message: Waiting for controller
reason: Pending
status: Unknown
type: Allocated
- lastTransitionTime: "1970-01-01T00:00:00Z"
message: Waiting for controller
reason: Pending
status: Unknown
type: Programmed
- lastTransitionTime: "1970-01-01T00:00:00Z"
message: Waiting for controller
reason: Pending
status: Unknown
type: Ready
description: SubnetClaimStatus defines the observed state of SubnetClaim
properties:
conditions:
Expand Down
35 changes: 34 additions & 1 deletion config/crd/bases/networking.datumapis.com_subnets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,23 @@ spec:
singular: subnet
scope: Namespaced
versions:
- name: v1alpha
- additionalPrinterColumns:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
- jsonPath: .status.conditions[?(@.type=="Ready")].status
name: Ready
type: string
- jsonPath: .status.conditions[?(@.type=="Ready")].reason
name: Reason
type: string
- jsonPath: .status.startAddress
name: Start Address
type: string
- jsonPath: .status.prefixLength
name: Prefix Length
type: string
name: v1alpha
schema:
openAPIV3Schema:
description: Subnet is the Schema for the subnets API
Expand Down Expand Up @@ -86,6 +102,23 @@ spec:
- subnetClass
type: object
status:
default:
conditions:
- lastTransitionTime: "1970-01-01T00:00:00Z"
message: Waiting for controller
reason: Pending
status: Unknown
type: Allocated
- lastTransitionTime: "1970-01-01T00:00:00Z"
message: Waiting for controller
reason: Pending
status: Unknown
type: Programmed
- lastTransitionTime: "1970-01-01T00:00:00Z"
message: Waiting for controller
reason: Pending
status: Unknown
type: Ready
description: SubnetStatus defines the observed state of a Subnet
properties:
conditions:
Expand Down
1 change: 1 addition & 0 deletions config/dev/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ metricsServer:
bindAddress: "0"

webhookServer:
port: 9444
tls:
secretRef:
name: network-services-operator-webhook-server-cert
Expand Down
2 changes: 1 addition & 1 deletion config/dev/webhook_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ apiVersion: builtin
kind: PrefixSuffixTransformer
metadata:
name: hostPrefix
prefix: "https://host.docker.internal:9443"
prefix: "https://host.docker.internal:9444"
fieldSpecs:
- kind: ValidatingWebhookConfiguration
path: webhooks/clientConfig/url
Expand Down
42 changes: 42 additions & 0 deletions internal/controller/indexers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package controller

import (
"context"
"errors"
"fmt"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
mcmanager "sigs.k8s.io/multicluster-runtime/pkg/manager"

networkingv1alpha "go.datum.net/network-services-operator/api/v1alpha"
)

const (
networkContextControllerNetworkUIDIndex = "networkContextControllerNetworkUIDIndex"
)

func AddIndexers(ctx context.Context, mgr mcmanager.Manager) error {
return errors.Join(
addNetworkContextControllerIndexers(ctx, mgr),
)
}

func addNetworkContextControllerIndexers(ctx context.Context, mgr mcmanager.Manager) error {
if err := mgr.GetFieldIndexer().IndexField(ctx, &networkingv1alpha.NetworkContext{}, networkContextControllerNetworkUIDIndex, networkContextControllerNetworkUIDIndexFunc); err != nil {
return fmt.Errorf("failed to add network context controller indexer %q: %w", networkContextControllerNetworkUIDIndex, err)
}

return nil
}

func networkContextControllerNetworkUIDIndexFunc(o client.Object) []string {

if networkRef := metav1.GetControllerOf(o); networkRef != nil {
return []string{
string(networkRef.UID),
}
}

return nil
}
Loading