From 182214629d2a8da11615cc111055e49f797e2681 Mon Sep 17 00:00:00 2001 From: Janki Chhatbar Date: Mon, 19 Jun 2023 21:09:38 +0530 Subject: [PATCH] Register OVN-IC APIs Epic: https://github.com/submariner-io/enhancements/issues/186 Signed-off-by: Janki Chhatbar --- pkg/embeddedyamls/generators/yamls2go.go | 2 + pkg/embeddedyamls/yamls.go | 112 +++++++++++++++++++++++ pkg/gateway/crds.go | 14 +++ 3 files changed, 128 insertions(+) diff --git a/pkg/embeddedyamls/generators/yamls2go.go b/pkg/embeddedyamls/generators/yamls2go.go index a66dd1e52..7e7f3926a 100644 --- a/pkg/embeddedyamls/generators/yamls2go.go +++ b/pkg/embeddedyamls/generators/yamls2go.go @@ -40,6 +40,8 @@ var files = []string{ "deploy/submariner/crds/submariner.io_clusterglobalegressips.yaml", "deploy/submariner/crds/submariner.io_globalegressips.yaml", "deploy/submariner/crds/submariner.io_globalingressips.yaml", + "deploy/submariner/crds/submariner.io_gatewayroutes.yaml", + "deploy/submariner/crds/submariner.io_nongatewayroutes.yaml", "deploy/mcsapi/crds/multicluster.x_k8s.io_serviceexports.yaml", "deploy/mcsapi/crds/multicluster.x_k8s.io_serviceimports.yaml", "config/broker/broker-admin/service_account.yaml", diff --git a/pkg/embeddedyamls/yamls.go b/pkg/embeddedyamls/yamls.go index 9eb292bfb..9ca87bf3c 100644 --- a/pkg/embeddedyamls/yamls.go +++ b/pkg/embeddedyamls/yamls.go @@ -1965,6 +1965,118 @@ spec: storage: true subresources: status: {} +` + Deploy_submariner_crds_submariner_io_gatewayroutes_yaml = `--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.12.0 + name: gatewayroutes.submariner.io +spec: + group: submariner.io + names: + kind: GatewayRoute + listKind: GatewayRouteList + plural: gatewayroutes + shortNames: + - gwrt + singular: gatewayroute + scope: Namespaced + versions: + - name: v1 + schema: + openAPIV3Schema: + 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: + properties: + nextHops: + description: Specifies the next hops to reach the remote CIDRs + items: + type: string + type: array + remoteCIDRs: + description: Specifies the remote CIDRs available via the next hop + items: + type: string + type: array + required: + - nextHops + - remoteCIDRs + type: object + required: + - spec + type: object + served: true + storage: true +` + Deploy_submariner_crds_submariner_io_nongatewayroutes_yaml = `--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.12.0 + name: nongatewayroutes.submariner.io +spec: + group: submariner.io + names: + kind: NonGatewayRoute + listKind: NonGatewayRouteList + plural: nongatewayroutes + shortNames: + - ngwrt + singular: nongatewayroute + scope: Namespaced + versions: + - name: v1 + schema: + openAPIV3Schema: + 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: + properties: + nextHops: + description: Specifies the next hops to reach the remote CIDRs + items: + type: string + type: array + remoteCIDRs: + description: Specifies the remote CIDRs available via the next hop + items: + type: string + type: array + required: + - nextHops + - remoteCIDRs + type: object + required: + - spec + type: object + served: true + storage: true ` Deploy_mcsapi_crds_multicluster_x_k8s_io_serviceexports_yaml = `apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition diff --git a/pkg/gateway/crds.go b/pkg/gateway/crds.go index da2bda8cd..3072732df 100644 --- a/pkg/gateway/crds.go +++ b/pkg/gateway/crds.go @@ -29,6 +29,8 @@ import ( // Ensure ensures that the required resources are deployed on the target system. // The resources handled here are the gateway CRDs: Cluster and Endpoint. +// +//nolint:gocyclo // No further refactors necessary func Ensure(ctx context.Context, crdUpdater crd.Updater) error { _, err := crdUpdater.CreateOrUpdateFromEmbedded(ctx, embeddedyamls.Deploy_submariner_crds_submariner_io_clusters_yaml) @@ -66,5 +68,17 @@ func Ensure(ctx context.Context, crdUpdater crd.Updater) error { return errors.Wrap(err, "error provisioning the GlobalIngressIP CRD") } + _, err = crdUpdater.CreateOrUpdateFromEmbedded(ctx, + embeddedyamls.Deploy_submariner_crds_submariner_io_gatewayroutes_yaml) + if err != nil && !apierrors.IsAlreadyExists(err) { + return errors.Wrap(err, "error getting Gateway routes") + } + + _, err = crdUpdater.CreateOrUpdateFromEmbedded(ctx, + embeddedyamls.Deploy_submariner_crds_submariner_io_nongatewayroutes_yaml) + if err != nil && !apierrors.IsAlreadyExists(err) { + return errors.Wrap(err, "error getting non-Gateway routes") + } + return nil }