Skip to content

Commit 99112f7

Browse files
authored
Merge pull request #786 from l1b0k/main
fix hubble usage
2 parents 58849ba + 5872cce commit 99112f7

File tree

44 files changed

+209
-758
lines changed

Some content is hidden

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

44 files changed

+209
-758
lines changed

cmd/terway-cli/policy.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ type PolicyConfig struct {
3030
}
3131

3232
type CNIConfig struct {
33-
HubbleEnabled bool `json:"cilium_enable_hubble,omitempty"`
33+
HubbleEnabled string `json:"cilium_enable_hubble,omitempty"`
3434
HubbleMetrics string `json:"cilium_hubble_metrics,omitempty"`
3535
HubbleListenAddress string `json:"cilium_hubble_listen_address,omitempty"`
3636
HubbleMetricServer string `json:"cilium_hubble_metrics_server,omitempty"`
@@ -272,7 +272,7 @@ func policyConfig(container *gabs.Container) ([]string, error) {
272272
return nil, fmt.Errorf("failed to unmarshal args: %w", err)
273273
}
274274

275-
if h.HubbleEnabled {
275+
if h.HubbleEnabled == "true" {
276276
if h.HubbleMetrics == "" {
277277
h.HubbleMetrics = "drop"
278278
}

cmd/terway-cli/policy_test.go

+40
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,46 @@ func Test_policyConfig(t *testing.T) {
150150
assert.Contains(t, strings, "--other=false")
151151
},
152152
},
153+
{
154+
name: "test hubble",
155+
args: args{container: func() *gabs.Container {
156+
cniJSON, _ := gabs.ParseJSON([]byte(`{
157+
"cniVersion": "0.4.0",
158+
"name": "terway-chainer",
159+
"plugins": [
160+
{
161+
"bandwidth_mode": "edt",
162+
"capabilities": {
163+
"bandwidth": true
164+
},
165+
"cilium_args": "disable-per-package-lb=true",
166+
"eniip_virtual_type": "datapathv2",
167+
"network_policy_provider": "ebpf",
168+
"cilium_enable_hubble": "true",
169+
"cilium_hubble_listen_address": ":4244",
170+
"cilium_hubble_metrics_server": ":9091",
171+
"cilium_hubble_metrics": "drop,tcp,flow,port-distribution,icmp",
172+
"type": "terway"
173+
},
174+
{
175+
"data-path": "datapathv2",
176+
"enable-debug": false,
177+
"log-file": "/var/run/cilium/cilium-cni.log",
178+
"type": "cilium-cni"
179+
}
180+
]
181+
}`))
182+
return cniJSON
183+
}()},
184+
readFunc: func(name string) ([]byte, error) {
185+
return []byte("#define DIRECT_ROUTING_DEV_IFINDEX 0\n#define DISABLE_PER_PACKET_LB 1\n"), nil
186+
},
187+
checkFunc: func(t *testing.T, strings []string, err error) {
188+
assert.NoError(t, err)
189+
assert.Contains(t, strings, "--disable-per-package-lb=true")
190+
assert.Contains(t, strings, "--enable-hubble=true")
191+
},
192+
},
153193
}
154194
for _, tt := range tests {
155195
t.Run(tt.name, func(t *testing.T) {

deploy/images/terway-controlplane/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# syntax=docker/dockerfile:1-labs
2-
ARG TERWAY_POLICY_IMAGE=registry-cn-zhangjiakou.ack.aliyuncs.com/acs/terway:policy-ff12ae92@sha256:f53c1aee4a58f1c7ed7b5d580674cad94050f38188a214cc8ccdef33ae690c61
2+
ARG TERWAY_POLICY_IMAGE=registry-cn-zhangjiakou.ack.aliyuncs.com/acs/terway:policy-04728dad@sha256:819a778edd3a9a3693482ff424b3686481bfb3089adee5aeeb43af57d225d4c9
33

44
FROM --platform=$TARGETPLATFORM ${TERWAY_POLICY_IMAGE} AS policy-dist
55

deploy/images/terway/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# syntax=docker/dockerfile:1-labs
2-
ARG TERWAY_POLICY_IMAGE=registry-cn-zhangjiakou.ack.aliyuncs.com/acs/terway:policy-ff12ae92@sha256:f53c1aee4a58f1c7ed7b5d580674cad94050f38188a214cc8ccdef33ae690c61
2+
ARG TERWAY_POLICY_IMAGE=registry-cn-zhangjiakou.ack.aliyuncs.com/acs/terway:policy-04728dad@sha256:819a778edd3a9a3693482ff424b3686481bfb3089adee5aeeb43af57d225d4c9
33
ARG UBUNTU_IMAGE=registry.cn-hangzhou.aliyuncs.com/acs/ubuntu:22.04-update
44
ARG CILIUM_LLVM_IMAGE=quay.io/cilium/cilium-llvm:547db7ec9a750b8f888a506709adb41f135b952e@sha256:4d6fa0aede3556c5fb5a9c71bc6b9585475ac9b1064f516d4c45c8fb691c9d9e
55
ARG CILIUM_BPFTOOL_IMAGE=quay.io/cilium/cilium-bpftool:78448c1a37ff2b790d5e25c3d8b8ec3e96e6405f@sha256:99a9453a921a8de99899ef82e0822f0c03f65d97005c064e231c06247ad8597d

policy/cilium/0001-cilium-terway-datapath.patch

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
22
From: l1b0k <[email protected]>
33
Date: Wed, 9 Jun 2021 16:55:20 +0800
4-
Subject: [PATCH] cilium terway datapath
4+
Subject: cilium terway datapath
55

66
Signed-off-by: l1b0k <[email protected]>
77
---
@@ -735,5 +735,5 @@ index 5eca17daeb..1ee2227373 100644
735735
)
736736

737737
--
738-
2.39.1
738+
2.39.5 (Apple Git-154)
739739

policy/cilium/0002-overwrite-endpoint-when-conflicting.patch

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
22
From: Lyt99 <[email protected]>
33
Date: Wed, 9 Jun 2021 16:29:32 +0800
4-
Subject: [PATCH] overwrite endpoint when conflicting
4+
Subject: overwrite endpoint when conflicting
55

66
Signed-off-by: l1b0k <[email protected]>
77
---
@@ -24,5 +24,5 @@ index 9700af0b3a..c7c4ad1637 100644
2424
}
2525

2626
--
27-
2.39.1
27+
2.39.5 (Apple Git-154)
2828

policy/cilium/0003-run-operator.patch

+35-67
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,14 @@
11
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
22
From: l1b0k <[email protected]>
33
Date: Wed, 9 Jun 2021 16:32:33 +0800
4-
Subject: [PATCH] run operator
4+
Subject: run operator
55

66
Signed-off-by: l1b0k <[email protected]>
77
---
8-
daemon/cmd/daemon_main.go | 25 +++--
9-
operator/Makefile | 2 +-
10-
operator/main.go | 225 --------------------------------------
11-
3 files changed, 19 insertions(+), 233 deletions(-)
8+
operator/Makefile | 2 +-
9+
operator/main.go | 243 ++--------------------------------------------
10+
2 files changed, 11 insertions(+), 234 deletions(-)
1211

13-
diff --git a/daemon/cmd/daemon_main.go b/daemon/cmd/daemon_main.go
14-
index 28bf66a7a9..1f2796810b 100644
15-
--- a/daemon/cmd/daemon_main.go
16-
+++ b/daemon/cmd/daemon_main.go
17-
@@ -14,13 +14,6 @@ import (
18-
"strings"
19-
"time"
20-
21-
- "github.com/go-openapi/loads"
22-
- gops "github.com/google/gops/agent"
23-
- "github.com/sirupsen/logrus"
24-
- "github.com/spf13/cobra"
25-
- "github.com/spf13/viper"
26-
- "google.golang.org/grpc"
27-
-
28-
"github.com/cilium/cilium/api/v1/server"
29-
"github.com/cilium/cilium/api/v1/server/restapi"
30-
"github.com/cilium/cilium/pkg/aws/eni"
31-
@@ -28,6 +21,7 @@ import (
32-
"github.com/cilium/cilium/pkg/bgpv1/gobgp"
33-
"github.com/cilium/cilium/pkg/bpf"
34-
"github.com/cilium/cilium/pkg/cgroups"
35-
+ "github.com/cilium/cilium/pkg/command/exec"
36-
"github.com/cilium/cilium/pkg/common"
37-
"github.com/cilium/cilium/pkg/components"
38-
"github.com/cilium/cilium/pkg/controller"
39-
@@ -75,6 +69,12 @@ import (
40-
"github.com/cilium/cilium/pkg/version"
41-
wireguard "github.com/cilium/cilium/pkg/wireguard/agent"
42-
wireguardTypes "github.com/cilium/cilium/pkg/wireguard/types"
43-
+ "github.com/go-openapi/loads"
44-
+ gops "github.com/google/gops/agent"
45-
+ "github.com/sirupsen/logrus"
46-
+ "github.com/spf13/cobra"
47-
+ "github.com/spf13/viper"
48-
+ "google.golang.org/grpc"
49-
)
50-
51-
const (
52-
@@ -1624,6 +1624,17 @@ func (d *Daemon) initKVStore() {
53-
}
54-
55-
func runDaemon() {
56-
+ go func() {
57-
+ if os.Getenv("DISABLE_CILIUM_OPERATOR") == "true" {
58-
+ return
59-
+ }
60-
+ cmd := exec.CommandContext(server.ServerCtx, "cilium-operator-generic", "--skip-crd-creation", "--k8s-namespace", os.Getenv("CILIUM_K8S_NAMESPACE"), "--identity-gc-interval", "10m", "--identity-heartbeat-timeout", "20m")
61-
+ cmd.Stdout = os.Stdout
62-
+ cmd.Stderr = os.Stderr
63-
+ err := cmd.Run()
64-
+ log.Fatal(fmt.Errorf("cilium-operator exited, %w", err))
65-
+ }()
66-
+
67-
datapathConfig := linuxdatapath.DatapathConfiguration{
68-
HostDevice: defaults.HostDevice,
69-
ProcFs: option.Config.ProcFs,
7012
diff --git a/operator/Makefile b/operator/Makefile
7113
index ebd1285e3d..1710880c84 100644
7214
--- a/operator/Makefile
@@ -81,7 +23,7 @@ index ebd1285e3d..1710880c84 100644
8123
cilium-operator-aws: GO_TAGS_FLAGS+=ipam_provider_aws
8224
cilium-operator-azure: GO_TAGS_FLAGS+=ipam_provider_azure
8325
diff --git a/operator/main.go b/operator/main.go
84-
index 756b218121..ec71d565dc 100644
26+
index 756b218121..ec0a329109 100644
8527
--- a/operator/main.go
8628
+++ b/operator/main.go
8729
@@ -15,30 +15,22 @@ import (
@@ -123,7 +65,33 @@ index 756b218121..ec71d565dc 100644
12365
"github.com/cilium/cilium/pkg/rand"
12466
"github.com/cilium/cilium/pkg/rate"
12567
"github.com/cilium/cilium/pkg/version"
126-
@@ -250,14 +241,6 @@ func runOperator() {
68+
@@ -72,15 +63,17 @@ var (
69+
}
70+
71+
// Open socket for using gops to get stacktraces of the agent.
72+
- addr := fmt.Sprintf("127.0.0.1:%d", viper.GetInt(option.GopsPort))
73+
- addrField := logrus.Fields{"address": addr}
74+
- if err := gops.Listen(gops.Options{
75+
- Addr: addr,
76+
- ReuseSocketAddrAndPort: true,
77+
- }); err != nil {
78+
- log.WithError(err).WithFields(addrField).Fatal("Cannot start gops server")
79+
+ if viper.GetInt(option.GopsPort) > 0 {
80+
+ addr := fmt.Sprintf("127.0.0.1:%d", viper.GetInt(option.GopsPort))
81+
+ addrField := logrus.Fields{"address": addr}
82+
+ if err := gops.Listen(gops.Options{
83+
+ Addr: addr,
84+
+ ReuseSocketAddrAndPort: true,
85+
+ }); err != nil {
86+
+ log.WithError(err).WithFields(addrField).Fatal("Cannot start gops server")
87+
+ }
88+
+ log.WithFields(addrField).Info("Started gops server")
89+
}
90+
- log.WithFields(addrField).Info("Started gops server")
91+
92+
initEnv()
93+
runOperator()
94+
@@ -250,14 +243,6 @@ func runOperator() {
12795
}
12896
}()
12997

@@ -138,7 +106,7 @@ index 756b218121..ec71d565dc 100644
138106
initK8s(k8sInitDone)
139107

140108
capabilities := k8sversion.Capabilities()
141-
@@ -367,189 +350,6 @@ func onOperatorStartLeading(ctx context.Context) {
109+
@@ -367,189 +352,6 @@ func onOperatorStartLeading(ctx context.Context) {
142110
go cesController.Run(operatorWatchers.CiliumEndpointStore, stopCh)
143111
}
144112

@@ -328,7 +296,7 @@ index 756b218121..ec71d565dc 100644
328296
if operatorOption.Config.IdentityGCInterval != 0 {
329297
identityRateLimiter = rate.NewLimiter(
330298
operatorOption.Config.IdentityGCRateInterval,
331-
@@ -583,31 +383,6 @@ func onOperatorStartLeading(ctx context.Context) {
299+
@@ -583,31 +385,6 @@ func onOperatorStartLeading(ctx context.Context) {
332300
enableCiliumEndpointSyncGC(true)
333301
}
334302

@@ -361,5 +329,5 @@ index 756b218121..ec71d565dc 100644
361329

362330
<-shutdownSignal
363331
--
364-
2.39.1
332+
2.39.5 (Apple Git-154)
365333

policy/cilium/0004-adapt-1.10-for-terway.patch

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
22
From: l1b0k <[email protected]>
33
Date: Thu, 10 Jun 2021 19:20:58 +0800
4-
Subject: [PATCH] adapt 1.10 for terway
4+
Subject: adapt 1.10 for terway
55

66
Signed-off-by: l1b0k <[email protected]>
77
---
@@ -40,5 +40,5 @@ index 7c0eaa8932..f713067030 100644
4040
c.KubeProxyReplacementHealthzBindAddr = viper.GetString(KubeProxyReplacementHealthzBindAddr)
4141

4242
--
43-
2.39.1
43+
2.39.5 (Apple Git-154)
4444

policy/cilium/0005-add-flag-to-control-in-cluster-loadBalance.patch

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
22
From: l1b0k <[email protected]>
33
Date: Thu, 9 Dec 2021 10:39:49 +0800
4-
Subject: [PATCH] add flag to control in cluster loadBalance
4+
Subject: add flag to control in cluster loadBalance
55

66
Signed-off-by: l1b0k <[email protected]>
77
---
@@ -11,7 +11,7 @@ Signed-off-by: l1b0k <[email protected]>
1111
3 files changed, 11 insertions(+), 1 deletion(-)
1212

1313
diff --git a/daemon/cmd/daemon_main.go b/daemon/cmd/daemon_main.go
14-
index 1f2796810b..375a11d5cf 100644
14+
index 28bf66a7a9..ac3c6834a3 100644
1515
--- a/daemon/cmd/daemon_main.go
1616
+++ b/daemon/cmd/daemon_main.go
1717
@@ -390,6 +390,9 @@ func initializeFlags() {
@@ -70,5 +70,5 @@ index f713067030..df026092f8 100644
7070
c.EnableHostPort = viper.GetBool(EnableHostPort)
7171
c.EnableHostLegacyRouting = viper.GetBool(EnableHostLegacyRouting)
7272
--
73-
2.39.1
73+
2.39.5 (Apple Git-154)
7474

policy/cilium/0006-terway-support-kubelet-health-check.patch

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
22
From: l1b0k <[email protected]>
33
Date: Mon, 23 May 2022 17:43:50 +0800
4-
Subject: [PATCH] terway: support kubelet health check
4+
Subject: terway: support kubelet health check
55

66
when package travel cross netns fw mark will lost ,this will cause bpf unable to identify host network.
77

@@ -35,5 +35,5 @@ index 6192691586..64f9169958 100644
3535
}
3636
cilium_dbg(ctx, info ? DBG_IP_ID_MAP_SUCCEED4 : DBG_IP_ID_MAP_FAILED4,
3737
--
38-
2.39.1
38+
2.39.5 (Apple Git-154)
3939

policy/cilium/0007-add-bandwidth-for-terway-ipvlan.patch

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
22
From: l1b0k <[email protected]>
33
Date: Mon, 20 Jun 2022 10:57:16 +0800
4-
Subject: [PATCH] add bandwidth for terway ipvlan
4+
Subject: add bandwidth for terway ipvlan
55

66
Signed-off-by: l1b0k <[email protected]>
77
---
@@ -93,5 +93,5 @@ index ea542dd527..0f078ad502 100644
9393
ctmap.WriteBPFMacros(fw, e)
9494
} else {
9595
--
96-
2.39.1
96+
2.39.5 (Apple Git-154)
9797

policy/cilium/0008-adapt-1.12.patch

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
22
From: l1b0k <[email protected]>
33
Date: Wed, 28 Sep 2022 10:11:36 +0800
4-
Subject: [PATCH] adapt 1.12
4+
Subject: adapt 1.12
55

66
- disable source ip check
77
- disable host bpf
@@ -61,5 +61,5 @@ index d85bba9285..802384084e 100644
6161
}
6262

6363
--
64-
2.39.1
64+
2.39.5 (Apple Git-154)
6565

0 commit comments

Comments
 (0)