Skip to content

Commit ee2d22f

Browse files
authored
Merge branch 'kosmos-io:main' into main
2 parents adde84f + 8847a72 commit ee2d22f

File tree

1,449 files changed

+253032
-7438
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,449 files changed

+253032
-7438
lines changed

.github/workflows/ci.yml

+37-1
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,40 @@ jobs:
6565
uses: actions/setup-go@v4
6666
with:
6767
go-version: '1.20'
68-
- run: make test
68+
- run: make test
69+
e2e:
70+
name: E2e test
71+
needs: build
72+
runs-on: ubuntu-22.04
73+
steps:
74+
# Free up disk space on Ubuntu
75+
- name: Free Disk Space (Ubuntu)
76+
uses: jlumbroso/free-disk-space@main
77+
with:
78+
# this might remove tools that are actually needed, if set to "true" but frees about 6 GB
79+
tool-cache: false
80+
# all of these default to true, but feel free to set to "false" if necessary for your workflow
81+
android: true
82+
dotnet: true
83+
haskell: true
84+
large-packages: false
85+
docker-images: false
86+
swap-storage: false
87+
- name: Checkout code
88+
uses: actions/checkout@v3
89+
with:
90+
fetch-depth: 0
91+
- name: Install Go
92+
uses: actions/setup-go@v4
93+
with:
94+
go-version: '1.20'
95+
- name: Prepare e2e env
96+
run: ./hack/prepare-e2e.sh
97+
- name: Run e2e test
98+
run: ./hack/rune2e.sh
99+
- name: Upload logs
100+
uses: actions/upload-artifact@v3
101+
if: failure()
102+
with:
103+
name: kosmos-e2e-logs-${{ github.run_id }}
104+
path: ${{ github.workspace }}/e2e-test/logs-*

Makefile

+9-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ REGISTRY?="ghcr.io/kosmos-io"
77
REGISTRY_USER_NAME?=""
88
REGISTRY_PASSWORD?=""
99
REGISTRY_SERVER_ADDRESS?=""
10+
KIND_IMAGE_TAG?="v1.25.3"
1011

1112
TARGETS := clusterlink-controller-manager \
1213
kosmos-operator \
@@ -133,4 +134,11 @@ ifeq (, $(shell which golangci-lint))
133134
GOLANGLINT_BIN=$(shell go env GOPATH)/bin/golangci-lint
134135
else
135136
GOLANGLINT_BIN=$(shell which golangci-lint)
136-
endif
137+
endif
138+
139+
image-base-kind-builder:
140+
docker buildx build \
141+
-t $(REGISTRY)/node:$(KIND_IMAGE_TAG) \
142+
--platform=linux/amd64,linux/arm64 \
143+
--push \
144+
-f cluster/images/buildx.kind.Dockerfile .

cluster/images/buildx.kind.Dockerfile

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM kindest/node:v1.25.3
2+
RUN clean-install tcpdump && clean-install iputils-ping && clean-install iptables && clean-install net-tools

cmd/clusterlink/OWNERS

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
approvers:
2+
- wuyingjun-lucky
3+
- hanweisen
4+
- wangyizhi1
5+
- OrangeBao
6+
reviewers:
7+
- wuyingjun-lucky
8+
- hanweisen
9+
- wangyizhi1
10+
- OrangeBao

cmd/clusterlink/agent/app/agent.go

+12-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
ctrl "sigs.k8s.io/controller-runtime"
1616

1717
"github.com/kosmos.io/kosmos/cmd/clusterlink/agent/app/options"
18-
linkagent "github.com/kosmos.io/kosmos/pkg/clusterlink/agent"
18+
linkagent "github.com/kosmos.io/kosmos/pkg/clusterlink/agent-manager"
1919
"github.com/kosmos.io/kosmos/pkg/clusterlink/network"
2020
kosmosclientset "github.com/kosmos.io/kosmos/pkg/generated/clientset/versioned"
2121
kosmosinformer "github.com/kosmos.io/kosmos/pkg/generated/informers/externalversions"
@@ -116,6 +116,17 @@ func run(ctx context.Context, opts *options.Options) error {
116116
return err
117117
}
118118

119+
autoDetectController := linkagent.AutoDetectReconciler{
120+
Client: mgr.GetClient(),
121+
NodeName: os.Getenv(utils.EnvNodeName),
122+
ClusterName: os.Getenv(utils.EnvClusterName),
123+
}
124+
125+
if err = autoDetectController.SetupWithManager(mgr); err != nil {
126+
klog.Fatalf("Unable to create auto detect controller: %v", err)
127+
return err
128+
}
129+
119130
factory.Start(ctx.Done())
120131
factory.WaitForCacheSync(ctx.Done())
121132

cmd/clusterlink/floater/app/floater.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
"k8s.io/klog/v2"
1717

1818
"github.com/kosmos.io/kosmos/cmd/clusterlink/floater/app/options"
19-
networkmanager "github.com/kosmos.io/kosmos/pkg/clusterlink/agent/network-manager"
19+
networkmanager "github.com/kosmos.io/kosmos/pkg/clusterlink/agent-manager/network-manager"
2020
"github.com/kosmos.io/kosmos/pkg/clusterlink/network"
2121
"github.com/kosmos.io/kosmos/pkg/sharedcli"
2222
"github.com/kosmos.io/kosmos/pkg/sharedcli/klogflag"

cmd/clustertree/cluster-manager/app/manager.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,10 @@ func run(ctx context.Context, opts *options.Options) error {
178178
if opts.MultiClusterService {
179179
// add serviceExport controller
180180
ServiceExportController := mcs.ServiceExportController{
181-
RootClient: mgr.GetClient(),
182-
EventRecorder: mgr.GetEventRecorderFor(mcs.ServiceExportControllerName),
183-
Logger: mgr.GetLogger(),
181+
RootClient: mgr.GetClient(),
182+
EventRecorder: mgr.GetEventRecorderFor(mcs.ServiceExportControllerName),
183+
Logger: mgr.GetLogger(),
184+
ReservedNamespaces: opts.ReservedNamespaces,
184185
}
185186
if err = ServiceExportController.SetupWithManager(mgr); err != nil {
186187
return fmt.Errorf("error starting %s: %v", mcs.ServiceExportControllerName, err)
@@ -194,6 +195,7 @@ func run(ctx context.Context, opts *options.Options) error {
194195
AutoCreateMCSPrefix: opts.AutoCreateMCSPrefix,
195196
RootKosmosClient: rootKosmosClient,
196197
GlobalLeafManager: globalleafManager,
198+
ReservedNamespaces: opts.ReservedNamespaces,
197199
}
198200
if err = autoCreateMCSController.SetupWithManager(mgr); err != nil {
199201
return fmt.Errorf("error starting %s: %v", mcs.AutoCreateMCSControllerName, err)

cmd/clustertree/cluster-manager/app/options/options.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,11 @@ type Options struct {
3535
// Enable oneway storage controllers
3636
OnewayStorageControllers bool
3737

38-
// AutoCreateMCSPrefix is the prefix of the namespace for service to auto create in leaf cluster
38+
// AutoCreateMCSPrefix are the prefix of the namespace for service to auto create in leaf cluster
3939
AutoCreateMCSPrefix []string
40+
41+
// ReservedNamespaces are the protected namespaces to prevent Kosmos for deleting system resources
42+
ReservedNamespaces []string
4043
}
4144

4245
type KubernetesOptions struct {
@@ -78,5 +81,6 @@ func (o *Options) AddFlags(flags *pflag.FlagSet) {
7881
flags.StringVar(&o.RootCoreDNSServiceName, "root-coredns-service-name", CoreDNSServiceName, "The name of the CoreDNS service in the root cluster, used to locate the CoreDNS service when MultiClusterService is disabled.")
7982
flags.BoolVar(&o.OnewayStorageControllers, "oneway-storage-controllers", false, "Turn on or off oneway storage controllers.")
8083
flags.StringSliceVar(&o.AutoCreateMCSPrefix, "auto-mcs-prefix", []string{}, "The prefix of namespace for service to auto create mcs resources")
84+
flags.StringSliceVar(&o.ReservedNamespaces, "reserved-namespaces", []string{"kube-system"}, "The namespaces protected by Kosmos that the controller-manager will skip.")
8185
options.BindLeaderElectionFlags(&o.LeaderElection, flags)
8286
}

deploy/clusterlink-agent.yaml

+15
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ spec:
4646
- mountPath: /etc/clusterlink/kubeconfig
4747
name: proxy-config
4848
readOnly: true
49+
- mountPath: /run/xtables.lock
50+
name: iptableslock
51+
readOnly: false
52+
- mountPath: /lib/modules
53+
name: lib-modules
54+
readOnly: true
4955
terminationGracePeriodSeconds: 30
5056
securityContext:
5157
privileged: true
@@ -55,3 +61,12 @@ spec:
5561
configMap:
5662
defaultMode: 420
5763
name: proxy-config
64+
- hostPath:
65+
path: /run/xtables.lock
66+
type: FileOrCreate
67+
name: iptableslock
68+
- name: lib-modules
69+
hostPath:
70+
path: /lib/modules
71+
72+

deploy/clusterlink-elector.yml

+17
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,23 @@ spec:
2121
labels:
2222
app: elector
2323
spec:
24+
nodeAffinity:
25+
requiredDuringSchedulingIgnoredDuringExecution:
26+
nodeSelectorTerms:
27+
- matchExpressions:
28+
- key: kosmos.io/exclude
29+
operator: DoesNotExist
30+
podAntiAffinity:
31+
requiredDuringSchedulingIgnoredDuringExecution:
32+
- labelSelector:
33+
matchExpressions:
34+
- key: app
35+
operator: In
36+
values:
37+
- elector
38+
namespaces:
39+
- kosmos-system
40+
topologyKey: kubernetes.io/hostname
2441
containers:
2542
- command:
2643
- clusterlink-elector

deploy/clustertree-cluster-manager.yml

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ spec:
7979
command:
8080
- clustertree-cluster-manager
8181
- --multi-cluster-service=true
82+
- --auto-mcs-prefix=kosmos-e2e
8283
- --v=4
8384
volumes:
8485
- name: credentials

0 commit comments

Comments
 (0)