Skip to content

Commit

Permalink
Add gateway api for binding (#95)
Browse files Browse the repository at this point in the history
Signed-off-by: Arnob kumar saha <[email protected]>
  • Loading branch information
ArnobKumarSaha authored Sep 12, 2024
1 parent 96d56e9 commit de15985
Show file tree
Hide file tree
Showing 4 changed files with 302 additions and 19 deletions.
78 changes: 78 additions & 0 deletions api/v1/gateway_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
Copyright AppsCode Inc. and Contributors
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1

import (
core "k8s.io/api/core/v1"
)

type Gateway struct {
Name string `json:"name"`
Namespace string `json:"namespace"`
// +optional
IP string `json:"ip,omitempty"`
// +optional
Hostname string `json:"hostname,omitempty"`
// Services is an optional configuration for services used to expose database
// +optional
Services []NamedServiceStatus `json:"services,omitempty"`
// UI is an optional list of database web uis
// +optional
UI []NamedURL `json:"ui,omitempty"`
}

type NamedServiceStatus struct {
// Alias represents the identifier of the service.
Alias string `json:"alias"`

Ports []GatewayPort `json:"ports"`
}

type NamedURL struct {
// Alias represents the identifier of the service.
// This should match the db ui chart name
Alias string `json:"alias"`

// URL of the database ui
URL string `json:"url"`

Port GatewayPort `json:"port"`

// HelmRelease is the name of the helm release used to deploy this ui
// The name format is typically <alias>-<db-name>
// +optional
HelmRelease *core.LocalObjectReference `json:"helmRelease,omitempty"`
}

// GatewayPort contains information on Gateway service's port.
type GatewayPort struct {
// The name of this port within the gateway service.
// +optional
Name string `json:"name,omitempty"`

// The port that will be exposed by the gateway service.
Port int32 `json:"port"`

// Number of the port to access the backend service.
// +optional
BackendServicePort int32 `json:"backendServicePort,omitempty"`

// The port on each node on which this gateway service is exposed when type is
// NodePort or LoadBalancer.
// +optional
NodePort int32 `json:"nodePort,omitempty"`
}
151 changes: 151 additions & 0 deletions api/v1/openapi_generated.go

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

19 changes: 0 additions & 19 deletions api/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,25 +392,6 @@ type ServicePort struct {
NodePort int32 `json:"nodePort,omitempty"`
}

// GatewayPort contains information on Gateway service's port.
type GatewayPort struct {
// The name of this port within the gateway service.
// +optional
Name string `json:"name,omitempty"`

// The port that will be exposed by the gateway service.
Port int32 `json:"port"`

// Number of the port to access the backend service.
// +optional
BackendServicePort int32 `json:"backendServicePort,omitempty"`

// The port on each node on which this gateway service is exposed when type is
// NodePort or LoadBalancer.
// +optional
NodePort int32 `json:"nodePort,omitempty"`
}

// Beware of MergeServicePorts
// ref: https://github.com/kmodules/client-go/blob/03dac1aea5084354127990a10d0b0e7529460dd5/core/v1/service.go#L103-L136
func PatchServicePorts(cur []core.ServicePort, desired []ServicePort) []core.ServicePort {
Expand Down
73 changes: 73 additions & 0 deletions api/v1/zz_generated.deepcopy.go

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

0 comments on commit de15985

Please sign in to comment.