Skip to content

feat(api): introduces MeshFederation API #166

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

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
7 changes: 6 additions & 1 deletion Makefile.tooling.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Versions
CONTROLLER_TOOLS_VERSION ?= v0.16.4

## Binaries
KIND := $(LOCALBIN)/kind
HELM := $(LOCALBIN)/helm
PROTOC := $(LOCALBIN)/protoc
Expand All @@ -9,6 +13,8 @@ GCI := $(LOCALBIN)/gci

$(shell mkdir -p $(LOCALBIN))

## Installation targets

$(GCI):
@GOBIN=$(LOCALBIN) go install github.com/daixiang0/[email protected]

Expand Down Expand Up @@ -37,7 +43,6 @@ $(PROTOC_GEN_DEEPCOPY):
$(KIND):
@GOBIN=$(LOCALBIN) go install -mod=readonly sigs.k8s.io/[email protected]

CONTROLLER_TOOLS_VERSION ?= v0.16.4
$(CONTROLLER_GEN):
GOBIN=$(LOCALBIN) go install -mod=readonly sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)

100 changes: 82 additions & 18 deletions api/v1alpha1/meshfederation_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,16 @@
// See the License for the specific language governing permissions and
// limitations under the License.

// Run "make build" to regenerate code after modifying this file

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.

// MeshFederationSpec defines the desired state of MeshFederation.
type MeshFederationSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// Foo is an example field of MeshFederation. Edit meshfederation_types.go to remove/update
Foo string `json:"foo,omitempty"`
}

// MeshFederationStatus defines the observed state of MeshFederation.
type MeshFederationStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
func init() {
SchemeBuilder.Register(&MeshFederation{}, &MeshFederationList{})
}

// +kubebuilder:object:root=true
Expand All @@ -58,6 +46,82 @@ type MeshFederationList struct {
Items []MeshFederation `json:"items"`
}

func init() {
SchemeBuilder.Register(&MeshFederation{}, &MeshFederationList{})
// MeshFederationSpec defines the desired state of MeshFederation.
type MeshFederationSpec struct {
// Network name used by Istio for load balancing
// +kubebuilder:validation:Required
Network string `json:"network"`

// +kubebuilder:default:=cluster.local
TrustDomain string `json:"trustDomain"`

// Namespace used to create mesh-wide resources
// +kubebuilder:default:=istio-system
ControlPlaneNamespace string `json:"controlPlaneNamespace"`

// TODO: CRD proposal states "If no ingress is specified, it means the controller supports only single network topology". However, some config, such as gateway/port config, seems to be required.
// Config specifying ingress type and ingress gateway config
// +kubebuilder:validation:Required
IngressConfig IngressConfig `json:"ingress"`

// Selects the K8s Services to export to all remote meshes.
// An empty export object matches all Services in all namespaces.
// A null export rules object matches no Services.
// +kubebuilder:validation:Optional
ExportRules *ExportRules `json:"export,omitempty"`
}

// MeshFederationStatus defines the observed state of MeshFederation.
type MeshFederationStatus struct {
// Conditions describes the state of the MeshFederation resource.
// +optional
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

type PortConfig struct {
// TODO: Needs clarification: This was marked as optional in the CRD proposal, but the comment states it cannot be empty
// Port name of the ingress gateway Service.
// This is relevant only when the ingress type is openshift-router, but it cannot be empty
// +kubebuilder:validation:Required
Name string `json:"name"`

// Port of the ingress gateway Service
// +kubebuilder:validation:Required
Number uint32 `json:"number"`
}

type GatewayConfig struct {
// Ingress gateway selector specifies to which workloads Gateway configurations will be applied.
// +kubebuilder:validation:MinProperties=1
Selector map[string]string `json:"selector"`

// Specifies the port name and port number of the ingress gateway service
// +kubebuilder:validation:Required
PortConfig PortConfig `json:"portConfig"`
}

type IngressConfig struct {
// Local ingress type specifies how to expose exported services.
// Currently, only two types are supported: istio and openshift-router.
// If "istio" is set, then the controller assumes that the Service associated with federation ingress gateway
// is LoadBalancer or NodePort and is directly accessible for remote peers, and then it only creates
// an auto-passthrough Gateway to expose exported Services.
// When "openshift-router" is enabled, then the controller creates also OpenShift Routes and applies EnvoyFilters
// to customize the SNI filter in the auto-passthrough Gateway, because the default SNI DNAT format used by Istio
// is not supported by OpenShift Router.
// +kubebuilder:default:=istio
// +kubebuilder:validation:Enum=istio;openshift-router
Type string `json:"type"`

// Specifies the selector and port config of the ingress gateway
// +kubebuilder:validation:Required
GatewayConfig GatewayConfig `json:"gateway,omitempty"`
}

type ExportRules struct {
// ServiceSelectors is a label query over K8s Services in all namespaces.
// The result of matchLabels and matchExpressions are ANDed.
// An empty service selector matches all Services.
// A null service selector matches no Services.
ServiceSelectors *metav1.LabelSelector `json:"serviceSelectors,omitempty"`
}
92 changes: 90 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.

Loading
Loading