Table of Contents generated with DocToc
A Golang based knitnet operator that will make/oversee Submariner components on top of the Kubernetes.
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.
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
A simple demo for deploy broker cluster, join other clusters to the broker cluster, verify service discovery
The configuration of Knitnet setup should be described in Knitnet CRD. You will find all the examples manifests in example folder.
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
The setup can be done by using kustomize
.
-
Clone source code
git clone https://github.com/tkestack/knitnet-operator.git cd knitnet-operator
-
Setup goproxy (optional)
If you cannot access
GOPROXY="https://proxy.golang.org,direct"
, trygoproxy.cn
go env -w GOPROXY=https://goproxy.cn,direct
-
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 filekubectl -n submariner-k8s-broker get cm submariner-broker-info -oyaml > submariner-broker-info.yaml
-
-
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
configmapkubectl create ns submariner-k8s-broker kubectl apply -f submariner-broker-info.yaml
-
Join
cluster-b
tocluster-a
kubectl -n knitnet-operator-system apply -f ./config/samples/join_broker.yaml
-
-
Deploy ClusterIP service on
cluster-b
Switch to
cluster-b
kubectl config use-context cluster-b
Deploy
nginx
servicekubectl -n default create deployment nginx --image=nginx kubectl -n default expose deployment nginx --port=80
-
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
-
Run
nettest
fromcluster-a
to access the nginx service:Switch to
cluster-a
kubectl config use-context cluster-a
Start
nettest
pod for testkubectl -n default run --generator=run-pod/v1 tmp-shell --rm -i --tty --image quay.io/submariner/nettest -- /bin/bash
For
kubectl
version > 1.18kubectl 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
I don't have any kubernetes cluster, I want a one-click deployment, he came deploy submariner with ansible