Skip to content

Commit

Permalink
fix: Change apiversion to canonical one (#93)
Browse files Browse the repository at this point in the history
BREAKING CHANGE
  • Loading branch information
achetronic authored and jodevsa committed Sep 2, 2023
1 parent 762d87d commit 35173e0
Show file tree
Hide file tree
Showing 36 changed files with 126 additions and 241 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ BUNDLE_METADATA_OPTS ?= $(BUNDLE_CHANNELS) $(BUNDLE_DEFAULT_CHANNEL)
# This variable is used to construct full image tags for bundle and catalog images.
#
# For example, running 'make bundle-build bundle-push catalog-build catalog-push' will build and push both
# example.com/manager-bundle:$VERSION and example.com/manager-catalog:$VERSION.
# wireguard-operator.io/manager-bundle:$VERSION and wireguard-operator.io/manager-catalog:$VERSION.
IMAGE_TAG_BASE ?= ghcr.io/jodevsa/wireguard-operator

# BUNDLE_IMG defines the image:tag used for the bundle.
Expand Down
6 changes: 3 additions & 3 deletions PROJECT
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
domain: example.com
domain: wireguard-operator.io
layout:
- go.kubebuilder.io/v3
plugins:
Expand All @@ -11,7 +11,7 @@ resources:
crdVersion: v1
namespaced: true
controller: true
domain: example.com
domain: wireguard-operator.io
group: vpn
kind: Wireguard
path: github.com/jodevsa/wireguard-operator/api/v1alpha1
Expand All @@ -20,7 +20,7 @@ resources:
crdVersion: v1
namespaced: true
controller: true
domain: example.com
domain: wireguard-operator.io
group: vpn
kind: WireguardPeer
path: github.com/jodevsa/wireguard-operator/api/v1alpha1
Expand Down
63 changes: 35 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@


# Wireguard operator
# Wireguard Operator
<img width="1394" alt="Screenshot 2022-02-26 at 02 05 29" src="https://user-images.githubusercontent.com/14154314/177223431-445fbbb1-ff5b-4fd5-86b3-850b81f0a98f.png">

painless deployment of wireguard on kubernetes
Painless deployment of wireguard on kubernetes

## Support and discussions

# Support and discussions
If you are facing any problems please open an [issue](https://github.com/jodevsa/wireguard-operator/issues) or start a
[discussion](https://github.com/jodevsa/wireguard-operator/discussions)

If you are facing any problems please open an [issue](https://github.com/jodevsa/wireguard-operator/issues) or start a [discussion](https://github.com/jodevsa/wireguard-operator/discussions)
# Tested with
## Tested with
- [x] IBM Cloud Kubernetes Service
- [x] Gcore Labs KMP
* requires `spec.enableIpForwardOnPodInit: true`
Expand All @@ -22,52 +22,53 @@ If you are facing any problems please open an [issue](https://github.com/jodevsa
- [ ] Azure Kubernetes Service
- [ ] ...?

# Architecture
## Architecture

![alt text](./readme/main.png)
# Features

## Features
* Falls back to userspace implementation of wireguard [wireguard-go](https://github.com/WireGuard/wireguard-go) if wireguard kernal module is missing
* Automatic key generation
* Automatic IP allocation
* Does not need persistance. peer/server keys are stored as k8s secrets and loaded into the wireguard pod
* Exposes a metrics endpoint by utilizing [prometheus_wireguard_exporter](https://github.com/MindFlavor/prometheus_wireguard_exporter)

# Example
## Example

### Server

## server
```
apiVersion: vpn.example.com/v1alpha1
apiVersion: vpn.wireguard-operator.io/v1alpha1
kind: Wireguard
metadata:
name: "my-cool-vpn"
spec:
mtu: "1380"
```


## peer
### Peer

```
apiVersion: vpn.example.com/v1alpha1
apiVersion: vpn.wireguard-operator.io/v1alpha1
kind: WireguardPeer
metadata:
name: peer1
spec:
wireguardRef: "my-cool-vpn"
```

#### Peer configuration

Peer configuration can be retrieved using the following command:

### Peer configuration

Peer configuration can be retreived using the following command
#### command:
```
```console
kubectl get wireguardpeer peer1 --template={{.status.config}} | bash
```
#### output:
```

After executing it, something similar to the following will be shown. Use this config snippet to configure your
preferred Wireguard client:

```console
[Interface]
PrivateKey = WOhR7uTMAqmZamc1umzfwm8o4ZxLdR5LjDcUYaW/PH8=
Address = 10.8.0.3
Expand All @@ -80,15 +81,21 @@ AllowedIPs = 0.0.0.0/0
Endpoint = 32.121.45.102:51820
```


# installation:
## How to deploy
```
kubectl apply -f https://github.com/jodevsa/wireguard-operator/releases/download/v1.2.20/release.yaml
```



# uninstall
## How to remove
```
kubectl delete -f https://github.com/jodevsa/wireguard-operator/releases/download/v1.2.20/release.yaml
```

## How to collaborate

This project is done on top of [Kubebuilder](https://github.com/kubernetes-sigs/kubebuilder), so read about that project
before collaborating. Of course, we are open to external collaborations for this project. For doing it you must fork the
repository, make your changes to the code and open a PR. The code will be reviewed and tested (always)

> We are developers and hate bad code. For that reason we ask you the highest quality on each line of code to improve
> this project on each iteration.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.7.0
creationTimestamp: null
name: wireguardpeers.vpn.example.com
name: wireguardpeers.vpn.wireguard-operator.io
spec:
group: vpn.example.com
group: vpn.wireguard-operator.io
names:
kind: WireguardPeer
listKind: WireguardPeerList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.7.0
creationTimestamp: null
name: wireguards.vpn.example.com
name: wireguards.vpn.wireguard-operator.io
spec:
group: vpn.example.com
group: vpn.wireguard-operator.io
names:
kind: Wireguard
listKind: WireguardList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ data:
port: 9443
leaderElection:
leaderElect: true
resourceName: a6d3bffc.example.com
resourceName: a6d3bffc.wireguard-operator.io
kind: ConfigMap
metadata:
name: wireguard-manager-config
20 changes: 10 additions & 10 deletions bundle/manifests/wireguard-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ metadata:
alm-examples: |-
[
{
"apiVersion": "vpn.example.com/v1alpha1",
"apiVersion": "vpn.wireguard-operator.io/v1alpha1",
"kind": "Wireguard",
"metadata": {
"name": "wireguard-sample"
},
"spec": null
},
{
"apiVersion": "vpn.example.com/v1alpha1",
"apiVersion": "vpn.wireguard-operator.io/v1alpha1",
"kind": "WireguardPeer",
"metadata": {
"name": "wireguardpeer-sample"
Expand All @@ -33,12 +33,12 @@ spec:
- description: WireguardPeer is the Schema for the wireguardpeers API
displayName: Wireguard Peer
kind: WireguardPeer
name: wireguardpeers.vpn.example.com
name: wireguardpeers.vpn.wireguard-operator.io
version: v1alpha1
- description: Wireguard is the Schema for the wireguards API
displayName: Wireguard
kind: Wireguard
name: wireguards.vpn.example.com
name: wireguards.vpn.wireguard-operator.io
version: v1alpha1
description: op
displayName: wireguard
Expand Down Expand Up @@ -122,7 +122,7 @@ spec:
- update
- watch
- apiGroups:
- vpn.example.com
- vpn.wireguard-operator.io
resources:
- wireguardpeers
verbs:
Expand All @@ -134,21 +134,21 @@ spec:
- update
- watch
- apiGroups:
- vpn.example.com
- vpn.wireguard-operator.io
resources:
- wireguardpeers/finalizers
verbs:
- update
- apiGroups:
- vpn.example.com
- vpn.wireguard-operator.io
resources:
- wireguardpeers/status
verbs:
- get
- patch
- update
- apiGroups:
- vpn.example.com
- vpn.wireguard-operator.io
resources:
- wireguards
verbs:
Expand All @@ -160,13 +160,13 @@ spec:
- update
- watch
- apiGroups:
- vpn.example.com
- vpn.wireguard-operator.io
resources:
- wireguards/finalizers
verbs:
- update
- apiGroups:
- vpn.example.com
- vpn.wireguard-operator.io
resources:
- wireguards/status
verbs:
Expand Down
2 changes: 1 addition & 1 deletion cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func main() {
Port: 9443,
HealthProbeBindAddress: probeAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "a6d3bffc.example.com",
LeaderElectionID: "a6d3bffc.wireguard-operator.io",
})
if err != nil {
setupLog.Error(err, "unable to start manager")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: wireguardpeers.vpn.example.com
name: wireguardpeers.vpn.wireguard-operator.io
spec:
group: vpn.example.com
group: vpn.wireguard-operator.io
names:
kind: WireguardPeer
listKind: WireguardPeerList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.8.0
creationTimestamp: null
name: wireguards.vpn.example.com
name: wireguards.vpn.wireguard-operator.io
spec:
group: vpn.example.com
group: vpn.wireguard-operator.io
names:
kind: Wireguard
listKind: WireguardList
Expand Down
4 changes: 2 additions & 2 deletions config/crd/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# since it depends on service name and namespace that are out of this kustomize package.
# It should be run by config/default
resources:
- bases/vpn.example.com_wireguardpeers.yaml
- bases/vpn.example.com_wireguards.yaml
- bases/vpn.wireguard-operator.io_wireguardpeers.yaml
- bases/vpn.wireguard-operator.io_wireguards.yaml
#+kubebuilder:scaffold:crdkustomizeresource

patchesStrategicMerge:
Expand Down
2 changes: 1 addition & 1 deletion config/crd/patches/cainjection_in_wireguardpeers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
name: wireguardpeers.vpn.example.com
name: wireguardpeers.vpn.wireguard-operator.io
2 changes: 1 addition & 1 deletion config/crd/patches/cainjection_in_wireguards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ kind: CustomResourceDefinition
metadata:
annotations:
cert-manager.io/inject-ca-from: $(CERTIFICATE_NAMESPACE)/$(CERTIFICATE_NAME)
name: wireguards.vpn.example.com
name: wireguards.vpn.wireguard-operator.io
2 changes: 1 addition & 1 deletion config/crd/patches/webhook_in_wireguardpeers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: wireguardpeers.vpn.example.com
name: wireguardpeers.vpn.wireguard-operator.io
spec:
conversion:
strategy: Webhook
Expand Down
2 changes: 1 addition & 1 deletion config/crd/patches/webhook_in_wireguards.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: wireguards.vpn.example.com
name: wireguards.vpn.wireguard-operator.io
spec:
conversion:
strategy: Webhook
Expand Down
2 changes: 1 addition & 1 deletion config/manager/controller_manager_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ webhook:
port: 9443
leaderElection:
leaderElect: true
resourceName: a6d3bffc.example.com
resourceName: a6d3bffc.wireguard-operator.io
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ spec:
- description: WireguardPeer is the Schema for the wireguardpeers API
displayName: Wireguard Peer
kind: WireguardPeer
name: wireguardpeers.vpn.example.com
name: wireguardpeers.vpn.wireguard-operator.io
version: v1alpha1
- description: Wireguard is the Schema for the wireguards API
displayName: Wireguard
kind: Wireguard
name: wireguards.vpn.example.com
name: wireguards.vpn.wireguard-operator.io
version: v1alpha1
description: op
displayName: wireguard
Expand Down
Loading

0 comments on commit 35173e0

Please sign in to comment.