Skip to content

Commit

Permalink
Merge pull request #10 from lumbrjx/dev-tcSvcControllerCall
Browse files Browse the repository at this point in the history
Feat ✨ Integrate Ebpf Service
  • Loading branch information
lumbrjx authored Aug 30, 2024
2 parents 4532f66 + a539b7d commit aede57f
Show file tree
Hide file tree
Showing 27 changed files with 110 additions and 375 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: Run tests
run: echo "Running tests..." # Replace with actual test command
run: echo "No tests for now..." # Replace with actual test command

build-and-push-staging:
needs: test
Expand All @@ -41,12 +41,16 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push Daemon Docker image
- name: Build and push Daemon, Controller Docker images
run: |
make build-daemon TAG=${{ github.sha }}
make push-daemon TAG=${{ github.sha }}
docker tag ${{ env.DAEMON_IMAGE_NAME }}:${{ github.sha }} ${{ env.DAEMON_IMAGE_NAME }}:staging
docker push ${{ env.DAEMON_IMAGE_NAME }}:staging
make build-controller TAG=${{ github.sha }}
make push-controller TAG=${{ github.sha }}
docker tag ${{ env.CONTROLLER_IMAGE_NAME }}:${{ github.sha }} ${{ env.CONTROLLER_IMAGE_NAME}}:staging
docker push ${{ env.CONTROLLER_IMAGE_NAME}}:staging
create-release:
if: github.ref == 'refs/heads/release'
Expand All @@ -72,6 +76,11 @@ jobs:
docker push ${{ env.DAEMON_IMAGE_NAME }}:v${{ github.run_number }}
docker tag ${{ env.DAEMON_IMAGE_NAME }}:v${{ github.run_number }} ${{ env.DAEMON_IMAGE_NAME }}:latest
docker push ${{ env.DAEMON_IMAGE_NAME }}:latest
docker pull ${{ env.CONTROLLER_IMAGE_NAME}}:staging
docker tag ${{ env.CONTROLLER_IMAGE_NAME}}:staging ${{ env.CONTROLLER_IMAGE_NAME}}:v${{ github.run_number }}
docker push ${{ env.CONTROLLER_IMAGE_NAME}}:v${{ github.run_number }}
docker tag ${{ env.CONTROLLER_IMAGE_NAME}}:v${{ github.run_number }} ${{ env.CONTROLLER_IMAGE_NAME}}:latest
docker push ${{ env.CONTROLLER_IMAGE_NAME}}:latest
- name: Create GitHub Release
uses: actions/create-release@v1
Expand Down
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,26 @@ build-daemon:
fi
docker build -f daemon/api/grpc/Dockerfile -t lumbrjx/obzev0-grpc-daemon:$$TAG .

build-controller:
@if [ -z "$$TAG" ]; then \
echo "Usage: make build-controller TAG=<tag>"; \
exit 1; \
fi
docker build -f controller/Dockerfile -t lumbrjx/obzev0poc:$$TAG .

push-daemon:
@if [ -z "$$TAG" ]; then \
echo "Usage: make push-daemon TAG=<tag>"; \
exit 1; \
fi
docker push lumbrjx/obzev0-grpc-daemon:$$TAG

push-controller:
@if [ -z "$$TAG" ]; then \
echo "Usage: make push-controller TAG=<tag>"; \
exit 1; \
fi
docker push lumbrjx/obzev0poc:$$TAG

generate-proto:
@if [ -z "$$PROTO_PATH" ]; then \
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ Obzev0 is built using a microservices architecture, with the following component
- **Controller:** Responsible for watching Custom Resource Definitions (CRDs) representing chaos scenarios and dispatching work to the DaemonSet.
- **DaemonSet:** Runs on every node in the Kubernetes cluster and acts as a gRPC server. It executes the chaos scenarios and communicates with the eBPF program in the kernel space.
- **eBPF Program:** Written in C, it runs in the kernel space and is responsible for monitoring and manipulating network traffic for performance monitoring.

## ToDo

[ ] complete Update/Delete informer functions
[ ] integrate tcAnalyser service in k8s controller grpc calls

114 changes: 0 additions & 114 deletions controller/README.md

This file was deleted.

11 changes: 8 additions & 3 deletions controller/api/v1/obzev0resource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,18 @@ type TcpConfig struct {
Client string `json:"client,omitempty"`
}

type TcAnalyserConfig struct {
NetIFace string `json:"netIFace,omitempty"`
}

// Obzev0ResourceSpec defines the desired state of Obzev0Resource
type Obzev0ResourceSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// Foo is an example field of Obzev0Resource. Edit obzev0resource_types.go to remove/update
Config TcpConfig `json:"config,omitempty"`
LatencyServiceConfig TcpConfig `json:"latencySvcConfig,omitempty"`
TcAnalyserServiceConfig TcAnalyserConfig `json:"tcAnalyserSvcConfig,omitempty"`
}

// Obzev0ResourceStatus defines the observed state of Obzev0Resource
Expand All @@ -68,8 +73,8 @@ type Obzev0Resource struct {

// Obzev0ResourceList contains a list of Obzev0Resource
type Obzev0ResourceList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
metav1.TypeMeta ` json:",inline"`
metav1.ListMeta ` json:"metadata,omitempty"`
Items []Obzev0Resource `json:"items"`
}

Expand Down
2 changes: 1 addition & 1 deletion controller/api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ spec:
spec:
description: Obzev0ResourceSpec defines the desired state of Obzev0Resource
properties:
config:
latencySvcConfig:
description: Foo is an example field of Obzev0Resource. Edit obzev0resource_types.go
to remove/update
properties:
Expand All @@ -58,6 +58,11 @@ spec:
description: TCP server address
type: string
type: object
tcAnalyserSvcConfig:
properties:
netIFace:
type: string
type: object
type: object
status:
description: Obzev0ResourceStatus defines the observed state of Obzev0Resource
Expand Down
2 changes: 1 addition & 1 deletion controller/config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ kind: Kustomization
images:
- name: controller
newName: lumbrjx/obzev0poc
newTag: 1.0.4
newTag: 1.0.5-alpha
10 changes: 7 additions & 3 deletions controller/config/samples/batch_v1_obzev0resource.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ metadata:
app.kubernetes.io/managed-by: kustomize
name: obzev0resource-sample
spec:
config:
reqDelay: 10
resDelay: 20
latencySvcConfig:
reqDelay: 0
resDelay: 0
server: "7090"
client: "8080"
tcAnalyserSvcConfig:
netIFace: "eth0"


status:
message: "Server started successfully"

1 change: 1 addition & 0 deletions controller/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ require (

require (
github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230305170008-8188dc5388df // indirect
github.com/envoyproxy/protoc-gen-validate v1.0.4 // indirect
k8s.io/apiserver v0.30.2 // indirect
)

Expand Down
2 changes: 2 additions & 0 deletions controller/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/emicklei/go-restful/v3 v3.12.1 h1:PJMDIM/ak7btuL8Ex0iYET9hxM3CI2sjZtzpL63nKAU=
github.com/emicklei/go-restful/v3 v3.12.1/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
github.com/envoyproxy/protoc-gen-validate v1.0.4 h1:gVPz/FMfvh57HdSJQyvBtF00j8JU4zdyUgIUNhlgg0A=
github.com/envoyproxy/protoc-gen-validate v1.0.4/go.mod h1:qys6tmnRsYrQqIhm2bvKZH4Blx/1gTIZ2UKVY1M+Yew=
github.com/evanphx/json-patch v4.12.0+incompatible h1:4onqiflcdA9EOZ4RxV643DvftH5pOlLGNtQ5lPWQu84=
github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk=
github.com/evanphx/json-patch/v5 v5.9.0 h1:kcBlZQbplgElYIlo/n1hJbls2z/1awpXxpRi0/FOJfg=
Expand Down
28 changes: 22 additions & 6 deletions controller/internal/controller/obzev0resource_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"obzev0/common/proto/latency"
pb "obzev0/common/proto/latency"
tca "obzev0/common/proto/tcAnalyser"

v1 "obzev0/controller/api/v1"

Expand Down Expand Up @@ -148,27 +149,42 @@ func handleAdd(obj interface{}, conn *grpc.ClientConn) {

name := obz.GetName()
namespace := obz.GetNamespace()
config := obz.Spec.Config
latencyConfig := obz.Spec.LatencyServiceConfig
tcAConfig := obz.Spec.TcAnalyserServiceConfig

klog.Infof("Custom Resource added: %s/%s", namespace, name)
klog.Infof("TCP Server Configuration: %+v", config)
klog.Infof("TCP Server Configuration: %+v", latencyConfig)
client := pb.NewLatencyServiceClient(conn)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*10)
defer cancel()
response, err := client.StartTcpServer(
ctx,
&pb.RequestForTcp{Config: &latency.TcpConfig{
ReqDelay: config.ReqDelay,
ResDelay: config.ResDelay,
Server: config.Server,
Client: config.Client,
ReqDelay: latencyConfig.ReqDelay,
ResDelay: latencyConfig.ResDelay,
Server: latencyConfig.Server,
Client: latencyConfig.Client,
}},
)

if err != nil {
log.Printf("Error calling gRPC method: %v\n", err)
} else {
fmt.Printf("Response from gRPC server: %s\n", response.Message)
}
client2 := tca.NewTcAnalyserServiceClient(conn)
rsp, err := client2.StartUserSpace(
ctx,
&tca.RequestForUserSpace{Config: &tca.TcConfig{
Interface: tcAConfig.NetIFace,
}},
)

if err != nil {
log.Printf("Error calling gRPC method: %v\n", err)
} else {
fmt.Printf("Response from gRPC server: %s\n", rsp.Message)
}

defer conn.Close()
}
Expand Down
18 changes: 0 additions & 18 deletions controller/pkg/client/clientset/versioned/clientset.go

This file was deleted.

19 changes: 0 additions & 19 deletions controller/pkg/client/clientset/versioned/doc.go

This file was deleted.

Loading

0 comments on commit aede57f

Please sign in to comment.