/knitnet-operator

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

Primary LanguageGoApache License 2.0Apache-2.0

Github CI GoReportCard Docker License

Table of Contents generated with DocToc

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

Example

The configuration of Knitnet setup should be described in Knitnet CRD. You will find all the examples manifests in example folder.

Prerequisites

Knitnet operator requires a Kubernetes cluster of version >=1.5.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

    git clone https://github.com/tkestack/knitnet-operator.git
  2. Deploy broker

    • Install knitnet operator

      kubectl config use-context cluster-a
      cd knitnet-operator
      make deploy
    • Deploy broker on cluster-a

      Add publicAPIServerURL in ./config/samples/deploy_broker.yaml, find the public apiserver URL with command: kubectl config view | grep server | cut -f 2- -d ":" | tr -d " "

      kubectl -n knitnet-operator-system apply -f ./config/samples/deploy_broker.yaml
    • Export submariner-broker-info configmap to a yaml file

      kubectl -n knitnet-operator-system get cm submariner-broker-info -oyaml > submariner-k8s-broker.yaml
  3. Join cluster to broker

    • Install knitnet operator

      kubectl config use-context cluster-b
      make deploy
    • Create submariner-broker-info configmap

      kubectl apply -f submariner-k8s-broker.yaml
    • Join cluster-b to cluster-a

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

Verify

  1. Deploy ClusterIP service on cluster-b

    kubectl config use-context cluster-b
    kubectl -n default create deployment nginx --image=nginx
    kubectl -n default expose deployment nginx --port=80
  2. Export service

    Create following resource on cluster-b:

    kubectl apply -f - <<EOF
    apiVersion: multicluster.x-k8s.io/v1alpha1
    kind: ServiceExport
    metadata:
      name: nginx
      namespace: default
    EOF
  3. Run nettest from cluster-a to access the nginx service:

    kubectl config use-context cluster-a
    kubectl -n default  run --generator=run-pod/v1 tmp-shell --rm -i --tty --image quay.io/submariner/nettest -- /bin/bash
    curl nginx.default.svc.clusterset.local:80