An open API service indexing awesome lists of open source software.

https://github.com/tkestack/knitnet-operator

Operator for support direct networking between Pods and Services in different Kubernetes clusters
https://github.com/tkestack/knitnet-operator

Last synced: 12 months ago
JSON representation

Operator for support direct networking between Pods and Services in different Kubernetes clusters

Awesome Lists containing this project

README

          



Github CI


GoReportCard


Docker


License

**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*

- [Knitnet Operator](#knitnet-operator)
- [Architecture](#architecture)
- [Purpose](#purpose)
- [Supported Features](#supported-features)
- [Getting Started](#getting-started)
- [Demo](#demo)
- [Example](#example)
- [Prerequisites](#prerequisites)
- [Quickstart](#quickstart)
- [Verify](#verify)
- [Quickstart with Ansible](#quickstart-with-ansible)

# Knitnet Operator

A Golang based knitnet operator that will make/oversee Submariner components on top of the Kubernetes.

## Architecture



### Purpose

The purpose of creating this operator was to provide an easy and production-grade setup of Submariner components on Kubernetes. It doesn't care if you have a plain on-prem Kubernetes or cloud-based.

### Supported Features

Here the features which are supported by this operator:-

- Deploy submariner broker
- Join cluster to broker
- Check k8s server version
- Support cloud prepare (aws, gcp)
- Support lighthouse, globalnet enable/disable

## Getting Started

### Demo

A simple demo for deploy broker cluster, join other clusters to the broker cluster, verify service discovery

### Example

The configuration of Knitnet setup should be described in Knitnet CRD. You will find all the examples manifests in [example](./config/samples) folder.

### Prerequisites

Knitnet operator requires a Kubernetes cluster of version `>=1.15.0`. If you have just started with Operators, its highly recommended to use latest version of Kubernetes. And the prepare 2 cluster, example `cluster-a` and `cluster-b`

### Quickstart

The setup can be done by using `kustomize`.

1. Clone source code

```shell
git clone https://github.com/tkestack/knitnet-operator.git
cd knitnet-operator
```

1. Setup goproxy (optional)

If you cannot access `GOPROXY="https://proxy.golang.org,direct"`, try `goproxy.cn`

```shell
go env -w GOPROXY=https://goproxy.cn,direct
```

1. Deploy broker

- Install knitnet operator

Switch to `cluster-a`

```shell
kubectl config use-context cluster-a
```

Deploy operator

```shell
make deploy
```

- Setup `publicAPIServerURL`

Add `publicAPIServerURL` in `./config/samples/deploy_broker.yaml`, `https://xxx.xxx.xxx.xxx:pppp` must be a public apiserver address, this address should be access by joined cluster.
Find the public apiserver URL with command: `kubectl config view | grep server | cut -f 2- -d ":" | tr -d " "`

```yaml
apiVersion: operator.tkestack.io/v1alpha1
kind: Knitnet
metadata:
name: deploy-broker-sample
spec:
brokerConfig:
publicAPIServerURL: https://xxx.xxx.xxx.xxx:pppp
# defaultGlobalnetClusterSize: 65336
serviceDiscoveryEnabled: true
```

- Deploy broker on `cluster-a`

```shell
kubectl -n knitnet-operator-system apply -f ./config/samples/deploy_broker.yaml
```

- Export `submariner-broker-info` configmap to a yaml file

```shell
kubectl -n submariner-k8s-broker get cm submariner-broker-info -oyaml > submariner-broker-info.yaml
```

1. Join cluster to broker

- Install knitnet operator

Switch to `cluster-b`

```shell
kubectl config use-context cluster-b
```

Deploy operator

```shell
make deploy
```

- Create `submariner-broker-info` configmap

```shell
kubectl create ns submariner-k8s-broker
kubectl apply -f submariner-broker-info.yaml
```

- Join `cluster-b` to `cluster-a`

```shell
kubectl -n knitnet-operator-system apply -f ./config/samples/join_broker.yaml
```

### Verify

1. Deploy ClusterIP service on `cluster-b`

Switch to `cluster-b`

```shell
kubectl config use-context cluster-b
```

Deploy `nginx` service

```shell
kubectl -n default create deployment nginx --image=nginx
kubectl -n default expose deployment nginx --port=80
```

1. Export service

Create following resource on `cluster-b`:

```shell
kubectl apply -f - < 1.18

```shell
kubectl run --rm -it --image=quay.io/submariner/nettest nettest -- /bin/bash
```

Try to curl nginx service created in `cluster-b`

```shell
curl nginx.default.svc.clusterset.local
```

### Quickstart with Ansible

I don't have any kubernetes cluster, I want a one-click deployment, he came [deploy submariner with ansible](https://github.com/DanielXLee/deploy-submariner/blob/main/README.md)