Skip to content

Commit 03bb3c1

Browse files
eoinfennessybartoszmajsak
authored andcommitted
feat(api): introduces MeshFederation API
This PR extends `MeshFederation` Custom Resource with configuration for local Federation setup. This configuration that includes: - network name - trust domain - controlPlane's namespace - required to create certain mesh-wide resources - ingress configuration to be used for creating Federation Ingress Gateway - the default should be `istio` - support for `openshift-router` It also defines export rules based on selectors (both label matching as well as expressions) ### Current assumptions - there should be only one instance of `MeshFederation` per namespace - `metadata.name` is used instead of originally proposed `id` to uniquely identify the local instance ### Related Issues API for openshift-service-mesh#52 openshift-service-mesh#143 Fixes openshift-service-mesh#141
1 parent a00e2b3 commit 03bb3c1

3 files changed

+356
-23
lines changed

api/v1alpha1/meshfederation_types.go

+82-18
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,16 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
// Run "make build" to regenerate code after modifying this file
16+
1517
package v1alpha1
1618

1719
import (
1820
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1921
)
2022

21-
// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
22-
// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
23-
24-
// MeshFederationSpec defines the desired state of MeshFederation.
25-
type MeshFederationSpec struct {
26-
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
27-
// Important: Run "make" to regenerate code after modifying this file
28-
29-
// Foo is an example field of MeshFederation. Edit meshfederation_types.go to remove/update
30-
Foo string `json:"foo,omitempty"`
31-
}
32-
33-
// MeshFederationStatus defines the observed state of MeshFederation.
34-
type MeshFederationStatus struct {
35-
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
36-
// Important: Run "make" to regenerate code after modifying this file
23+
func init() {
24+
SchemeBuilder.Register(&MeshFederation{}, &MeshFederationList{})
3725
}
3826

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

61-
func init() {
62-
SchemeBuilder.Register(&MeshFederation{}, &MeshFederationList{})
49+
// MeshFederationSpec defines the desired state of MeshFederation.
50+
type MeshFederationSpec struct {
51+
// Network name used by Istio for load balancing
52+
// +kubebuilder:validation:Required
53+
Network string `json:"network"`
54+
55+
// +kubebuilder:default:=cluster.local
56+
TrustDomain string `json:"trustDomain"`
57+
58+
// Namespace used to create mesh-wide resources
59+
// +kubebuilder:default:=istio-system
60+
ControlPlaneNamespace string `json:"controlPlaneNamespace"`
61+
62+
// 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.
63+
// Config specifying ingress type and ingress gateway config
64+
// +kubebuilder:validation:Required
65+
IngressConfig IngressConfig `json:"ingress"`
66+
67+
// Selects the K8s Services to export to all remote meshes.
68+
// An empty export object matches all Services in all namespaces.
69+
// A null export rules object matches no Services.
70+
// +kubebuilder:validation:Optional
71+
ExportRules *ExportRules `json:"export,omitempty"`
72+
}
73+
74+
// MeshFederationStatus defines the observed state of MeshFederation.
75+
type MeshFederationStatus struct {
76+
// Conditions describes the state of the MeshFederation resource.
77+
// +optional
78+
Conditions []metav1.Condition `json:"conditions,omitempty"`
79+
}
80+
81+
type PortConfig struct {
82+
// TODO: Needs clarification: This was marked as optional in the CRD proposal, but the comment states it cannot be empty
83+
// Port name of the ingress gateway Service.
84+
// This is relevant only when the ingress type is openshift-router, but it cannot be empty
85+
// +kubebuilder:validation:Required
86+
Name string `json:"name"`
87+
88+
// Port of the ingress gateway Service
89+
// +kubebuilder:validation:Required
90+
Number uint32 `json:"number"`
91+
}
92+
93+
type GatewayConfig struct {
94+
// Ingress gateway selector specifies to which workloads Gateway configurations will be applied.
95+
// +kubebuilder:validation:MinProperties=1
96+
Selector map[string]string `json:"selector"`
97+
98+
// Specifies the port name and port number of the ingress gateway service
99+
// +kubebuilder:validation:Required
100+
PortConfig PortConfig `json:"portConfig"`
101+
}
102+
103+
type IngressConfig struct {
104+
// Local ingress type specifies how to expose exported services.
105+
// Currently, only two types are supported: istio and openshift-router.
106+
// If "istio" is set, then the controller assumes that the Service associated with federation ingress gateway
107+
// is LoadBalancer or NodePort and is directly accessible for remote peers, and then it only creates
108+
// an auto-passthrough Gateway to expose exported Services.
109+
// When "openshift-router" is enabled, then the controller creates also OpenShift Routes and applies EnvoyFilters
110+
// to customize the SNI filter in the auto-passthrough Gateway, because the default SNI DNAT format used by Istio
111+
// is not supported by OpenShift Router.
112+
// +kubebuilder:default:=istio
113+
// +kubebuilder:validation:Enum=istio;openshift-router
114+
Type string `json:"type"`
115+
116+
// Specifies the selector and port config of the ingress gateway
117+
// +kubebuilder:validation:Required
118+
GatewayConfig GatewayConfig `json:"gateway,omitempty"`
119+
}
120+
121+
type ExportRules struct {
122+
// ServiceSelectors is a label query over K8s Services in all namespaces.
123+
// The result of matchLabels and matchExpressions are ANDed.
124+
// An empty service selector matches all Services.
125+
// A null service selector matches no Services.
126+
ServiceSelectors *metav1.LabelSelector `json:"serviceSelectors,omitempty"`
63127
}

api/v1alpha1/zz_generated.deepcopy.go

+90-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)