Entangle CRDs
Note
This feature is crazy and experimental! Do not run in production servers. Feedback and bug reports are welcome, as we are improving the p2p aspects of Kairos.Kairos has two Kubernetes Native extensions ( entangle and entangle-proxy ) that allows to interconnect services between different clusters via P2P with a shared secret.
The clusters won’t need to do any specific setting in order to establish a connection, as it uses libp2p to establish a connection between the nodes.
Entangle can be used to connect services running on different clusters or can be used with entangle-proxy
to control another cluster remotely via P2P.
Prerequisites
To entangle
two or more clusters you need one or more Kubernetes cluster; entangle
depends on cert-manager
:
entangle
needs to run on all the clusters that you wish to interconnect. It provides capabilities to interconnect services between clustersentangle-proxy
only on the cluster that you wish to use as control cluster
Install the CRD and entangle
First, add the kairos helm repository:
Install the CRDs with:
Install entangle
:
Install entangle-proxy
Now install entangle-proxy
only on the cluster which is used to control, and which dispatches manifests to downstream clusters.
Controlling a remote cluster
To control a remote cluster, you need a cluster where to issue and apply manifest from (the control cluster, where entangle-proxy
is installed) and a cluster running entangle
which proxies kubectl
with a ServiceAccount
/Role
associated with it.
They both need to agree on a secret, which is the network_token
to be able to communicate, otherwise it won’t work. There is no other configuration needed in order for the two cluster to talk to each other.
Generating a network token
Generating a network token is described in the p2p section
Managed cluster
The cluster which is the target of our manifests, as specified needs to run a deployment which entangles kubectl
:
Note: replace YOUR_NETWORK_TOKEN_GOES_HERE with the token generated with the kairos-cli
.
Control
To control, from the cluster that has entangle-proxy
installed we can apply:
Note: replace YOUR_NETWORK_TOKEN_GOES_HERE with the token generated with the kairos-cli
and used in the step above.
Expose services
The entangle
CRD can be used to interconnect services of clusters, or create tunnels to cluster services.
- Can inject a sidecar container to access a remote services exposed
- Can create a deployment which exposes a remote service from another cluster
Deployment
entangle
can be used to tunnel a connection or a service available from one cluster to another.
In the image above, we can see how entangle can create a tunnel for a service running on Cluster A and mirror it to to Cluster B.
It can also expose services that are reachable from the host Network:
Consider the following example that tunnels a cluster 192.168.1.1:80
to another one using an Entanglement
:
Sidecar injection
The controller can inject a container which exposes a connection (in both directions):
Or we can combine them together: