pkg/k8s/apis: support for preshared keys in peers

This commit adds support for defining preshared keys when declaring a
new Peer CRD. This preshared key will be used whenever the nodes in the
Kilo mesh communicate with that peer.

Signed-off-by: Lucas Servén Marín <lserven@gmail.com>
This commit is contained in:
Lucas Servén Marín
2020-05-05 11:36:39 +02:00
parent e4829832c5
commit 0a10dc921c
9 changed files with 64 additions and 9 deletions

View File

@@ -299,6 +299,10 @@ func translatePeer(peer *wireguard.Peer) *v1alpha1.Peer {
if len(peer.PublicKey) > 0 {
key = string(peer.PublicKey)
}
var psk string
if len(peer.PresharedKey) > 0 {
psk = string(peer.PresharedKey)
}
var pka int
if peer.PersistentKeepalive > 0 {
pka = peer.PersistentKeepalive
@@ -311,8 +315,9 @@ func translatePeer(peer *wireguard.Peer) *v1alpha1.Peer {
Spec: v1alpha1.PeerSpec{
AllowedIPs: aips,
Endpoint: endpoint,
PublicKey: key,
PersistentKeepalive: pka,
PresharedKey: psk,
PublicKey: key,
},
}
}