Skip to content

Commit

Permalink
Fix join broker issue
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielXLee committed Jul 11, 2021
1 parent fd2f4d9 commit 6976986
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 14 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,48 +69,48 @@ The setup can be done by using `kustomize`.
1. Clone source code

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

1. Deploy broker

- Install knitnet operator

```shell
$ kubectl config use-context cluster-a
$ cd knitnet-operator
$ make deploy
kubectl config use-context cluster-a
cd knitnet-operator
make deploy
```

- Deploy broker on `cluster-a`

```shell
$ kubect -n knitnet-operator-system apply -f .config/samples/deploy_broker.yaml
kubect -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-k8s-broker.yaml
kubectl -n submariner-k8s-broker get cm submariner-broker-info -oyaml > submariner-k8s-broker.yaml
```

2. Join cluster to broker

- Install knitnet operator

```shell
$ kubectl config use-context cluster-b
$ make deploy
kubectl config use-context cluster-b
make deploy
```

- Create `submariner-broker-info` configmap

```shell
$ kubectl apply -f submariner-k8s-broker.yaml
kubectl apply -f submariner-k8s-broker.yaml
```

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

```shell
$ kubectl -n knitnet-operator-system apply -f .config/samples/join_broker.yaml
kubectl -n knitnet-operator-system apply -f .config/samples/join_broker.yaml
```
6 changes: 5 additions & 1 deletion api/v1alpha1/knitnet_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,13 @@ const (
type Phase string

type BrokerConfig struct {
// ServiceDiscoveryEnabled represents enable/disable multi-cluster service discovery.
// ConnectivityEnabled represents enable/disable multi-cluster pod connectivity.
// +optional
// +kubebuilder:default=true
ConnectivityEnabled bool `json:"connectivityEnabled,omitempty"`
// ServiceDiscoveryEnabled represents enable/disable multi-cluster service discovery.
// +optional
// +kubebuilder:default=false
ServiceDiscoveryEnabled bool `json:"serviceDiscoveryEnabled,omitempty"`
// GlobalnetEnable represents enable/disable overlapping CIDRs in connecting clusters (default disabled).
// +optional
Expand Down
7 changes: 6 additions & 1 deletion config/crd/bases/operator.tkestack.io_knitnets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ spec:
description: BrokerConfig represents the broker cluster configuration
of the Submariner.
properties:
connectivityEnabled:
default: true
description: ConnectivityEnabled represents enable/disable multi-cluster
pod connectivity.
type: boolean
defaultCustomDomains:
description: DefaultCustomDomains represents list of domains to
use for multicluster service discovery.
Expand All @@ -84,7 +89,7 @@ spec:
CIDRs in connecting clusters (default disabled).
type: boolean
serviceDiscoveryEnabled:
default: true
default: false
description: ServiceDiscoveryEnabled represents enable/disable
multi-cluster service discovery.
type: boolean
Expand Down
16 changes: 16 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ rules:
- '*'
verbs:
- '*'
- apiGroups:
- config.openshift.io
resources:
- networks
verbs:
- get
- list
- apiGroups:
- ""
resources:
Expand Down Expand Up @@ -74,6 +81,15 @@ rules:
- patch
- update
- watch
- apiGroups:
- operator.openshift.io
resources:
- dnses
verbs:
- get
- list
- update
- watch
- apiGroups:
- operator.tkestack.io
resources:
Expand Down
2 changes: 1 addition & 1 deletion config/samples/join_broker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ kind: Knitnet
metadata:
name: join-broker-sample
spec:
actioin: join
action: join
joinConfig:
clusterID: cluster-b
# forceUDPEncaps: false
Expand Down
12 changes: 11 additions & 1 deletion controllers/ensures/broker/brokerinfo_cm.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,17 @@ func CreateBrokerInfoConfigMap(c client.Client, restConfig *rest.Config, instanc
brokerConfig := instance.Spec.BrokerConfig
brokerInfo.GlobalnetCIDRRange = brokerConfig.GlobalnetCIDRRange
brokerInfo.DefaultGlobalnetClusterSize = brokerConfig.DefaultGlobalnetClusterSize

componentSet := stringset.New()
if brokerConfig.ConnectivityEnabled {
componentSet.Add(components.Connectivity)
}
if brokerConfig.GlobalnetEnable {
componentSet.Add(components.Globalnet)
}
if brokerConfig.ServiceDiscoveryEnabled {
componentSet.Add(components.ServiceDiscovery)
}
brokerInfo.SetComponents(componentSet)
if len(brokerConfig.DefaultCustomDomains) > 0 {
brokerInfo.CustomDomains = &brokerConfig.DefaultCustomDomains
}
Expand Down
4 changes: 4 additions & 0 deletions controllers/knitnet_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ const (
// +kubebuilder:rbac:groups=rbac.authorization.k8s.io,resources=roles;rolebindings;clusterroles;clusterrolebindings,verbs=get;list;watch;create;update;delete
// +kubebuilder:rbac:groups=apiextensions.k8s.io,resources=customresourcedefinitions,verbs=get;list;watch;create;update;patch;delete

// Only for join broker
// +kubebuilder:rbac:groups=config.openshift.io,resources=networks,verbs=get;list
// +kubebuilder:rbac:groups=operator.openshift.io,resources=dnses,verbs=get;list;watch;update

// +kubebuilder:rbac:groups=security.openshift.io,resources=securitycontextconstraints,verbs=get
// +kubebuilder:rbac:groups=monitoring.coreos.com,resources=servicemonitors,verbs=get;create

Expand Down

0 comments on commit 6976986

Please sign in to comment.