Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add api types for external load balancer #102

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
66 changes: 66 additions & 0 deletions api/v1alpha1/externalloadbalancer_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright 2022 Weaveworks or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: MPL-2.0

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

// ExternalLoadBalancerSpec defines the desired state for a ExternalLoadBalancer.
type ExternalLoadBalancerSpec struct {
// Endpoint represents the endpoint for the load balancer. This endpoint will
// best tested to see if its available.
Endpoint clusterv1.APIEndpoint `json:"endpoint"`
}

type ExternalLoadBalancerStatus struct {
// Ready indicates that the load balancer is ready.
// +optional
// +kubebuilder:default=false
Ready bool `json:"ready"`
// Conditions defines current state of the ExternalLoadBalancer.
// +optional
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
}

// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:storageversion
// +kubebuilder:resource:path=externalloadbalancers,scope=Namespaced,categories=cluster-api,shortName=extlb
// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="Load balancer is ready"
// +kubebuilder:printcolumn:name="ControlPlaneEndpoint",type="string",JSONPath=".spec.controlPlaneEndpoint[0]",description="API Endpoint",priority=1

// ExternalLoadBalancer is the schema for a external load balancer.
type ExternalLoadBalancer struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ExternalLoadBalancerSpec `json:"spec,omitempty"`
Status ExternalLoadBalancerStatus `json:"status,omitempty"`
}

// GetConditions returns the observations of the operational state of the ExternalLoadBalancer resource.
func (r *ExternalLoadBalancer) GetConditions() clusterv1.Conditions {
return r.Status.Conditions
}

// SetConditions sets the underlying service state of the ExternalLoadBalancer to the predescribed clusterv1.Conditions.
func (r *ExternalLoadBalancer) SetConditions(conditions clusterv1.Conditions) {
r.Status.Conditions = conditions
}

//+kubebuilder:object:root=true

// ExternalLoadBalancerList contains a list of ExternalLoadBalancers.
// +k8s:defaulter-gen=true
type ExternalLoadBalancerList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []MicrovmCluster `json:"items"`
}

func init() {
SchemeBuilder.Register(&ExternalLoadBalancer{}, &ExternalLoadBalancerList{})
}
97 changes: 97 additions & 0 deletions api/v1alpha1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.7.1-0.20211110210727-ab52f76cc7d1
creationTimestamp: null
name: externalloadbalancers.infrastructure.cluster.x-k8s.io
spec:
group: infrastructure.cluster.x-k8s.io
names:
categories:
- cluster-api
kind: ExternalLoadBalancer
listKind: ExternalLoadBalancerList
plural: externalloadbalancers
shortNames:
- extlb
singular: externalloadbalancer
scope: Namespaced
versions:
- additionalPrinterColumns:
- description: Load balancer is ready
jsonPath: .status.ready
name: Ready
type: string
- description: API Endpoint
jsonPath: .spec.controlPlaneEndpoint[0]
name: ControlPlaneEndpoint
priority: 1
type: string
name: v1alpha1
schema:
openAPIV3Schema:
description: ExternalLoadBalancer is the schema for a external load balancer.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: ExternalLoadBalancerSpec defines the desired state for a
ExternalLoadBalancer.
properties:
endpoint:
description: Endpoint represents the endpoint for the load balancer.
This endpoint will best tested to see if its available.
properties:
host:
description: The hostname on which the API server is serving.
type: string
port:
description: The port on which the API server is serving.
format: int32
type: integer
required:
- host
- port
type: object
required:
- endpoint
type: object
status:
properties:
conditions:
description: Conditions defines current state of the ExternalLoadBalancer.
items:
description: Condition defines an observation of a Cluster API resource
operational state.
properties:
lastTransitionTime:
description: 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: A human readable message indicating details about
the transition. This field may be empty.
type: string
reason:
description: The reason for the condition's last transition
in CamelCase. The specific API may choose whether or not this
field is considered a guaranteed API. This field may not be
empty.
type: string
severity:
description: Severity provides an explicit classification of
Reason code, so the users or machines can immediately understand
the current situation and act accordingly. The Severity field
MUST be set only when Status=False.
type: string
status:
description: Status of the condition, one of True, False, Unknown.
type: string
type:
description: Type of condition in CamelCase or in foo.example.com/CamelCase.
Many .condition.type values are consistent across resources
like Available, but because arbitrary conditions can be useful
(see .node.status.conditions), the ability to deconflict is
important.
type: string
required:
- lastTransitionTime
- status
- type
type: object
type: array
ready:
default: false
description: Ready indicates that the load balancer is ready.
type: boolean
type: object
type: object
served: true
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []