Skip to content

Commit

Permalink
update: use cgo instead of uds (#264)
Browse files Browse the repository at this point in the history
* init probe for cgo

Signed-off-by: sangyangji <songyujie@zju.edu.cn>

* add cgo receiver

Signed-off-by: jundizhou <jundizhou@harmonycloud.cn>

* convert the cgo event to the KindlingEvent

Signed-off-by: Daxin Wang <daxinwang@harmonycloud.cn>

* using a channel to store the events

Signed-off-by: Daxin Wang <daxinwang@harmonycloud.cn>

* update: use cgo instead of uds

Signed-off-by: jundizhou <jundizhou@harmonycloud.cn>

* gracefully shutdown the cgoreceiver

Signed-off-by: Daxin Wang <daxinwang@harmonycloud.cn>

* remove the probe binary

Signed-off-by: Daxin Wang <daxinwang@harmonycloud.cn>

* remove the udsreceiver since there are some code errors

Signed-off-by: Daxin Wang <daxinwang@harmonycloud.cn>

* add periodSeconds to the readiness probe

Signed-off-by: Daxin Wang <daxinwang@harmonycloud.cn>

* fix deploy files issues

Signed-off-by: Daxin Wang <daxinwang@harmonycloud.cn>

Co-authored-by: sangyangji <songyujie@zju.edu.cn>
Co-authored-by: Daxin Wang <daxinwang@harmonycloud.cn>
  • Loading branch information
3 people authored Jun 27, 2022
1 parent 7210fe0 commit 4d88144
Show file tree
Hide file tree
Showing 71 changed files with 2,013 additions and 9,393 deletions.
11 changes: 6 additions & 5 deletions collector/application/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/Kindling-project/kindling/collector/consumer/processor/aggregateprocessor"
"github.com/Kindling-project/kindling/collector/consumer/processor/k8sprocessor"
"github.com/Kindling-project/kindling/collector/receiver"
"github.com/Kindling-project/kindling/collector/receiver/udsreceiver"
"github.com/Kindling-project/kindling/collector/receiver/cgoreceiver"
"github.com/spf13/viper"
"go.uber.org/multierr"
)
Expand Down Expand Up @@ -73,7 +73,7 @@ func initFlags() error {
}

func (a *Application) registerFactory() {
a.componentsFactory.RegisterReceiver(udsreceiver.Uds, udsreceiver.NewUdsReceiver, &udsreceiver.Config{})
a.componentsFactory.RegisterReceiver(cgoreceiver.Cgo, cgoreceiver.NewCgoReceiver, &cgoreceiver.Config{})
a.componentsFactory.RegisterAnalyzer(network.Network.String(), network.NewNetworkAnalyzer, &network.Config{})
a.componentsFactory.RegisterProcessor(k8sprocessor.K8sMetadata, k8sprocessor.NewKubernetesProcessor, &k8sprocessor.DefaultConfig)
a.componentsFactory.RegisterExporter(otelexporter.Otel, otelexporter.NewExporter, &otelexporter.Config{})
Expand Down Expand Up @@ -130,8 +130,9 @@ func (a *Application) buildPipeline() error {
return fmt.Errorf("error happened while creating analyzer manager: %w", err)
}
a.analyzerManager = analyzerManager
udsReceiverFactory := a.componentsFactory.Receivers[udsreceiver.Uds]
udsReceiver := udsReceiverFactory.NewFunc(udsReceiverFactory.Config, a.telemetry.Telemetry, analyzerManager)
a.receiver = udsReceiver

cgoReceiverFactory := a.componentsFactory.Receivers[cgoreceiver.Cgo]
cgoReceiver := cgoReceiverFactory.NewFunc(cgoReceiverFactory.Config, a.telemetry.Telemetry, analyzerManager)
a.receiver = cgoReceiver
return nil
}
9 changes: 7 additions & 2 deletions collector/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
FROM centos:7

COPY libso/libzmq.so.5 /lib64/
WORKDIR /app/
RUN curl https://k8s-bpf-probes-public.oss-cn-hangzhou.aliyuncs.com/kindling-falcolib-probe-v0.3.0.tar.gz -o kindling-falcolib-probe.tar.gz --progress
COPY libso/libkindling.so /lib64/
RUN ldconfig

COPY kindling-probe-loader /usr/bin/kindling-probe-loader
RUN chmod +x /usr/bin/kindling-probe-loader
COPY kindling-collector-config.yml /etc/kindling/config/
COPY kindling-collector /usr/bin/kindling-collector
COPY start.sh /app/

CMD ["/usr/bin/kindling-collector", "--config=/etc/kindling/config/kindling-collector-config.yml"]
CMD ["sh", "start.sh"]
12 changes: 12 additions & 0 deletions collector/docker/DockerfileLocalProbe
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM centos:7

WORKDIR /app/
COPY kindling-falcolib-probe.tar.gz ./

COPY libso/libkindling.so /lib64/
RUN ldconfig

COPY kindling-collector-config.yml /etc/kindling/config/
COPY kindling-collector /usr/bin/kindling-collector

CMD ["sh", "start.sh"]
56 changes: 25 additions & 31 deletions collector/docker/kindling-collector-config.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,29 @@
receivers:
udsreceiver:
zeromqpull:
# Address for pulling events from probe
endpoint: ipc:///home/kindling-sub/0
zeromqreq:
# Address for sending subscribe messages to probe
endpoint: ipc:///home/kindling/0
subscribe:
- name: syscall_exit-writev
category: net
- name: syscall_exit-readv
category: net
- name: syscall_exit-write
category: net
- name: syscall_exit-read
category: net
- name: syscall_exit-sendto
category: net
- name: syscall_exit-recvfrom
category: net
- name: syscall_exit-sendmsg
category: net
- name: syscall_exit-recvmsg
category: net
- name: kprobe-tcp_close
- name: kprobe-tcp_rcv_established
- name: kprobe-tcp_drop
- name: kprobe-tcp_retransmit_skb
- name: syscall_exit-connect
- name: kretprobe-tcp_connect
- name: kprobe-tcp_set_state
cgoreceiver:
subscribe:
- name: syscall_exit-writev
category: net
- name: syscall_exit-readv
category: net
- name: syscall_exit-write
category: net
- name: syscall_exit-read
category: net
- name: syscall_exit-sendto
category: net
- name: syscall_exit-recvfrom
category: net
- name: syscall_exit-sendmsg
category: net
- name: syscall_exit-recvmsg
category: net
- name: kprobe-tcp_close
- name: kprobe-tcp_rcv_established
- name: kprobe-tcp_drop
- name: kprobe-tcp_retransmit_skb
- name: syscall_exit-connect
- name: kretprobe-tcp_connect
- name: kprobe-tcp_set_state
analyzers:
tcpconnectanalyzer:
channel_size: 10000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ SCRIPT_NAME=$(basename "${0}")
PROBE_NAME="kindling-falcolib-probe"
MAX_RMMOD_WAIT=60

tar -zxvf /pl/kindling-falcolib-probe.tar.gz -C /opt
tar -zxvf /app/kindling-falcolib-probe.tar.gz -C /opt
mv /opt/kindling-falcolib-probe /opt/.kindling

if [ -d /opt/kindling-extra-probe ]; then
Expand Down
Binary file removed collector/docker/libso/libzmq.so.5
Binary file not shown.
8 changes: 8 additions & 0 deletions collector/docker/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

/usr/bin/kindling-probe-loader

if [ -f "/opt/probe.o" ]; then
export SYSDIG_BPF_PROBE="/opt/probe.o"
fi

/usr/bin/kindling-collector --config=/etc/kindling/config/kindling-collector-config.yml
3 changes: 3 additions & 0 deletions collector/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,7 @@ golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRu
golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug=
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o=
Expand All @@ -590,6 +591,7 @@ golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/mod v0.5.0 h1:UG21uOlmZabA4fW5i7ZX6bjw1xELEGg/ZLgZq9auk/Q=
golang.org/x/mod v0.5.0/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro=
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
Expand Down Expand Up @@ -836,6 +838,7 @@ golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
Loading

0 comments on commit 4d88144

Please sign in to comment.