-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented WgGatewayServers controller
- Loading branch information
Showing
8 changed files
with
575 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2019-2023 The Liqo Authors | ||
// | ||
// 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 consts | ||
|
||
const ( | ||
// // LocalKeyLabel is used to indicate if the key is local to the cluster. | ||
// LocalKeyLabel = "liqo.io/local-key" | ||
// // LocalKeyLabelValue indicates the key is local to the cluster. | ||
// LocalKeyLabelValue = "true" | ||
// // WgServerLabel is the label used to indicate if the object is created by a WireGuard server. | ||
// WgServerLabel = "liqo.io/wg-server" | ||
// // WgServerLabelValue indicates the object is created by a WireGuard server. | ||
// WgServerLabelValue = "true" | ||
// // WgClientLabel is the label used to indicate if the object is created by a WireGuard client. | ||
// WgClientLabel = "liqo.io/wg-client" | ||
// // WgClientLabelValue indicates the object is created by a WireGuard client. | ||
// WgClientLabelValue = "true" | ||
// WgServerNameLabel is the label used to indicate the name of the WireGuard server. | ||
WgServerNameLabel = "liqo.io/wg-server-name" | ||
// WgClientNameLabel is the label used to indicate the name of the WireGuard client. | ||
WgClientNameLabel = "liqo.io/wg-client-name" | ||
// ExternalNetworkLabel is the label added to all components that belong to the external network. | ||
ExternalNetworkLabel = "liqo.io/external-network" | ||
// ExternalNetworkLabelValue is the value of the label added to components that belong to the external network. | ||
ExternalNetworkLabelValue = "true" | ||
) |
16 changes: 16 additions & 0 deletions
16
pkg/liqo-controller-manager/external-network/wireguard/docs.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// Copyright 2019-2023 The Liqo Authors | ||
// | ||
// 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 wireguard contains the logic to manage WireGuard gateway servers and clients. | ||
package wireguard |
70 changes: 70 additions & 0 deletions
70
pkg/liqo-controller-manager/external-network/wireguard/wggatewayclient_controller.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright 2019-2023 The Liqo Authors | ||
// | ||
// 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 wireguard | ||
|
||
import ( | ||
"context" | ||
|
||
appsv1 "k8s.io/api/apps/v1" | ||
apierrors "k8s.io/apimachinery/pkg/api/errors" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/klog/v2" | ||
ctrl "sigs.k8s.io/controller-runtime" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
|
||
networkingv1alpha1 "github.com/liqotech/liqo/apis/networking/v1alpha1" | ||
) | ||
|
||
// WgGatewayClientReconciler manage WgGatewayClient lifecycle. | ||
type WgGatewayClientReconciler struct { | ||
client.Client | ||
Scheme *runtime.Scheme | ||
} | ||
|
||
// NewWgGatewayClientReconciler returns a new WgGatewayClientReconciler. | ||
func NewWgGatewayClientReconciler(cl client.Client, s *runtime.Scheme) *WgGatewayClientReconciler { | ||
return &WgGatewayClientReconciler{ | ||
Client: cl, | ||
Scheme: s, | ||
} | ||
} | ||
|
||
// cluster-role | ||
// +kubebuilder:rbac:groups=networking.liqo.io,resources=wggatewayclients,verbs=get;list;watch;delete;create;update;patch | ||
// +kubebuilder:rbac:groups=networking.liqo.io,resources=wggatewayclients/status,verbs=get;update;patch | ||
// +kubebuilder:rbac:groups=apps,resources=deployments,verbs=get;list;watch;delete;create;update;patch | ||
|
||
// Reconcile manage GatewayClient lifecycle. | ||
func (r *WgGatewayClientReconciler) Reconcile(ctx context.Context, req ctrl.Request) (res ctrl.Result, err error) { | ||
wgClient := &networkingv1alpha1.WgGatewayClient{} | ||
if err = r.Get(ctx, req.NamespacedName, wgClient); err != nil { | ||
if apierrors.IsNotFound(err) { | ||
klog.Infof("WireGuard gateway client %q not found", req.NamespacedName) | ||
return ctrl.Result{}, nil | ||
} | ||
klog.Errorf("Unable to get the WireGuard gateway client %q: %v", req.NamespacedName, err) | ||
return ctrl.Result{}, err | ||
} | ||
|
||
return ctrl.Result{}, nil | ||
} | ||
|
||
// SetupWithManager register the WgGatewayClientReconciler to the manager. | ||
func (r *WgGatewayClientReconciler) SetupWithManager(mgr ctrl.Manager) error { | ||
return ctrl.NewControllerManagedBy(mgr). | ||
For(&networkingv1alpha1.WgGatewayClient{}). | ||
Owns(&appsv1.Deployment{}). | ||
Complete(r) | ||
} |
Oops, something went wrong.