Skip to content

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

License

Notifications You must be signed in to change notification settings

tkestack/knitnet-operator

Repository files navigation

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

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 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

    git clone https://github.com/tkestack/knitnet-operator.git
    cd knitnet-operator
  2. Setup goproxy (optional)

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

    go env -w GOPROXY=https://goproxy.cn,direct
  3. Deploy broker

    • Install knitnet operator

      Switch to cluster-a

      kubectl config use-context cluster-a

      Deploy operator

      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 " "

      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

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

      kubectl -n submariner-k8s-broker get cm submariner-broker-info -oyaml > submariner-broker-info.yaml
  4. Join cluster to broker

    • Install knitnet operator

      Switch to cluster-b

      kubectl config use-context cluster-b

      Deploy operator

      make deploy
    • Create submariner-broker-info configmap

      kubectl create ns submariner-k8s-broker
      kubectl apply -f submariner-broker-info.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

    Switch to cluster-b

    kubectl config use-context cluster-b

    Deploy nginx service

    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:

    Switch to cluster-a

    kubectl config use-context cluster-a

    Start nettest pod for test

    kubectl -n default  run --generator=run-pod/v1 tmp-shell --rm -i --tty --image quay.io/submariner/nettest -- /bin/bash

    For kubectl version > 1.18

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

    Try to curl nginx service created in cluster-b

    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

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published