Skip to content

Commit

Permalink
fix apis
Browse files Browse the repository at this point in the history
  • Loading branch information
aleoli authored and cheina97 committed Oct 12, 2023
1 parent 1cc7443 commit 0a8b619
Show file tree
Hide file tree
Showing 20 changed files with 2,796 additions and 37 deletions.
2 changes: 1 addition & 1 deletion apis/networking/v1alpha1/gatewayclient_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ type GatewayClientSpec struct {
// MTU specifies the MTU of the tunnel.
MTU int `json:"mtu,omitempty"`
// Endpoint specifies the endpoint of the tunnel.
Endpoint Endpoint `json:"endpoint,omitempty"`
Endpoint EndpointStatus `json:"endpoint,omitempty"`
}

// GatewayClientStatus defines the observed state of GatewayClient.
Expand Down
2 changes: 2 additions & 0 deletions apis/networking/v1alpha1/wggatewayclient_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ var WgGatewayClientGroupVersionResource = GroupVersion.WithResource(WgGatewayCli
type WgGatewayClientSpec struct {
// Deployment specifies the deployment template for the client.
Deployment DeploymentTemplate `json:"deployment"`
// Metrics specifies the metrics configuration for the client.
Metrics *Metrics `json:"metrics,omitempty"`
}

// WgGatewayClientStatus defines the observed state of WgGatewayClient.
Expand Down
21 changes: 21 additions & 0 deletions apis/networking/v1alpha1/wggatewayserver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package v1alpha1

import (
monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -52,12 +53,32 @@ type DeploymentTemplate struct {
Spec appsv1.DeploymentSpec `json:"spec,omitempty"`
}

// ServiceMonitorTemplate defines the template of a service monitor.
type ServiceMonitorTemplate struct {
// Metadata of the service monitor.
Metadata metav1.ObjectMeta `json:"metadata,omitempty"`
// Spec of the service monitor.
Spec monitoringv1.ServiceMonitorSpec `json:"spec,omitempty"`
}

// Metrics defines the metrics configuration.
type Metrics struct {
// Enabled specifies whether the metrics are enabled.
Enabled bool `json:"enabled"`
// Service specifies the service template for the metrics.
Service *ServiceTemplate `json:"service,omitempty"`
// ServiceMonitor specifies the service monitor template for the metrics.
ServiceMonitor *ServiceMonitorTemplate `json:"serviceMonitor,omitempty"`
}

// WgGatewayServerSpec defines the desired state of WgGatewayServer.
type WgGatewayServerSpec struct {
// Service specifies the service template for the server.
Service ServiceTemplate `json:"service"`
// Deployment specifies the deployment template for the server.
Deployment DeploymentTemplate `json:"deployment"`
// Metrics specifies the metrics configuration for the server.
Metrics *Metrics `json:"metrics,omitempty"`
}

// WgGatewayServerStatus defines the observed state of WgGatewayServer.
Expand Down
56 changes: 54 additions & 2 deletions apis/networking/v1alpha1/zz_generated.deepcopy.go

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

12 changes: 10 additions & 2 deletions cmd/liqo-controller-manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"sync"
"time"

monitoringv1 "github.com/prometheus-operator/prometheus-operator/pkg/apis/monitoring/v1"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
certificates "k8s.io/api/certificates/v1"
Expand Down Expand Up @@ -109,6 +110,8 @@ var (
func init() {
_ = clientgoscheme.AddToScheme(scheme)

_ = monitoringv1.AddToScheme(scheme)

_ = sharingv1alpha1.AddToScheme(scheme)
_ = netv1alpha1.AddToScheme(scheme)
_ = discoveryv1alpha1.AddToScheme(scheme)
Expand All @@ -132,6 +135,7 @@ func main() {
var ipamClient ipam.IpamClient
var gatewayServerResources argsutils.StringList
var gatewayClientResources argsutils.StringList
var wgGatewayServerClusterRoleName, wgGatewayClientClusterRoleName string

webhookPort := flag.Uint("webhook-port", 9443, "The port the webhook server binds to")
metricsAddr := flag.String("metrics-address", ":8080", "The address the metric endpoint binds to")
Expand Down Expand Up @@ -217,6 +221,10 @@ func main() {
// External network parameters
flag.Var(&gatewayServerResources, "gateway-server-resources", "The list of resource types that implements the gateway server. They must be in the form <group>/<version>/<resource>")
flag.Var(&gatewayClientResources, "gateway-client-resources", "The list of resource types that implements the gateway client. They must be in the form <group>/<version>/<resource>")
flag.StringVar(&wgGatewayServerClusterRoleName, "wg-gateway-server-cluster-role-name", "liqo-gateway",
"The name of the cluster role used by the wireguard gateway servers")
flag.StringVar(&wgGatewayClientClusterRoleName, "wg-gateway-client-cluster-role-name", "liqo-gateway",
"The name of the cluster role used by the wireguard gateway clients")

liqoerrors.InitFlags(nil)
restcfg.InitFlags(nil)
Expand Down Expand Up @@ -664,13 +672,13 @@ func main() {
}

wgServerRec := wggatewaycontrollers.NewWgGatewayServerReconciler(
mgr.GetClient(), mgr.GetScheme(), auxmgrExtNetworkPods.GetClient())
mgr.GetClient(), mgr.GetScheme(), auxmgrExtNetworkPods.GetClient(), wgGatewayServerClusterRoleName)
if err = wgServerRec.SetupWithManager(mgr); err != nil {
klog.Errorf("Unable to start the WgGatewayServerReconciler", err)
os.Exit(1)
}

wgClientRec := wggatewaycontrollers.NewWgGatewayClientReconciler(mgr.GetClient(), mgr.GetScheme())
wgClientRec := wggatewaycontrollers.NewWgGatewayClientReconciler(mgr.GetClient(), mgr.GetScheme(), wgGatewayClientClusterRoleName)
if err = wgClientRec.SetupWithManager(mgr); err != nil {
klog.Errorf("Unable to start the WgGatewayClientReconciler", err)
os.Exit(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,21 @@ spec:
endpoint:
description: Endpoint specifies the endpoint of the tunnel.
properties:
addresses:
description: Addresses specifies the addresses of the endpoint.
items:
type: string
type: array
port:
description: Port specifies the port of the endpoint.
format: int32
type: integer
serviceType:
default: ClusterIP
description: ServiceType specifies the type of the service.
protocol:
default: TCP
description: Protocol specifies the protocol of the endpoint.
enum:
- ClusterIP
- NodePort
- LoadBalancer
- ExternalName
- TCP
- UDP
type: string
type: object
mtu:
Expand Down
Loading

0 comments on commit 0a8b619

Please sign in to comment.