Skip to content

Commit 81d739d

Browse files
authored
Merge pull request #260 from Nordix/target
Move target example under /examples/target and ctraffic container renamed
2 parents 8a4229f + 2e81893 commit 81d739d

File tree

19 files changed

+91
-55
lines changed

19 files changed

+91
-55
lines changed

CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Contributing
22

33
List of projects:
4-
1. ctraffic
4+
1. example-target
55
2. ipam
66
3. stateless-lb
77
4. nsp

Makefile

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ help: ## Display this help.
1313
# Variables
1414
############################################################################
1515

16-
IMAGES ?= base-image stateless-lb proxy tapa ipam nsp ctraffic frontend
16+
IMAGES ?= base-image stateless-lb proxy tapa ipam nsp example-target frontend
1717

1818
# Versions
1919
VERSION ?= latest
@@ -22,7 +22,7 @@ VERSION_PROXY ?= $(VERSION)
2222
VERSION_TAPA ?= $(VERSION)
2323
VERSION_IPAM ?= $(VERSION)
2424
VERSION_NSP ?= $(VERSION)
25-
VERSION_CTRAFFIC ?= $(VERSION)
25+
VERSION_EXAMPLE_TARGET ?= $(VERSION)
2626
VERSION_FRONTEND ?= $(VERSION)
2727
VERSION_BASE_IMAGE ?= $(VERSION)
2828
LOCAL_VERSION ?= $(VERSION)
@@ -101,9 +101,9 @@ ipam: ## Build the ipam.
101101
nsp: ## Build the nsp.
102102
VERSION=$(VERSION_NSP) IMAGE=nsp $(MAKE) -s $(BUILD_STEPS)
103103

104-
.PHONY: ctraffic
105-
ctraffic: ## Build the ctraffic.
106-
VERSION=$(VERSION_CTRAFFIC) IMAGE=ctraffic $(MAKE) -s $(BUILD_STEPS)
104+
.PHONY: example-target
105+
example-target:
106+
VERSION=$(VERSION_EXAMPLE_TARGET) BUILD_DIR=examples/target/build IMAGE=example-target $(MAKE) $(BUILD_STEPS)
107107

108108
.PHONY: frontend
109109
frontend: ## Build the frontend.

deployments/helm/values.yaml

-4
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,6 @@ proxy:
4545
readiness:
4646
service: "Readiness"
4747

48-
ctraffic:
49-
image: ctraffic
50-
version: latest
51-
5248
ipam:
5349
image: ipam
5450
version: latest

docs/demo/deployments/xcluster/ovl/meridio/helm/gateway/templates/tg.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ spec:
5757
- -c
5858
- sysctl -w net.ipv4.fib_multipath_hash_policy=1 ; sysctl -w net.ipv6.fib_multipath_hash_policy=1
5959
containers:
60-
- name: ctraffic
61-
image: {{ .Values.registry }}/{{ .Values.organization }}/ctraffic:latest
60+
- name: example-target
61+
image: {{ .Values.registry }}/{{ .Values.organization }}/example-target:latest
6262
imagePullPolicy: {{ .Values.pullPolicy }}
6363
securityContext:
6464
privileged: true

docs/demo/readme.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ helm install deployments/helm/ --generate-name --create-namespace --namespace re
3939

4040
Install targets
4141
```
42-
helm install examples/target/helm/ --generate-name --create-namespace --namespace red --set applicationName=target-a --set default.trench.name=trench-a
42+
helm install examples/target/deployments/helm/ --generate-name --create-namespace --namespace red --set applicationName=target-a --set default.trench.name=trench-a
4343
```
4444

4545
### External host / External connectivity

docs/demo/xcluster.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ EOF
265265

266266
Install targets connected to trench-a and conduit "load-balancer"
267267
```
268-
helm install examples/target/helm/ --generate-name --namespace default --set applicationName=target-a --set default.trench.name=trench-a --set default.conduit.name=load-balancer
268+
helm install examples/target/deployments/helm/ --generate-name --namespace default --set applicationName=target-a --set default.trench.name=trench-a --set default.conduit.name=load-balancer
269269
```
270270

271271
## Traffic

docs/test.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ helm install deployments/helm/ --generate-name --create-namespace --namespace re
7070
6. Deploy target of trench-a
7171

7272
```bash
73-
helm install examples/target/helm/ --generate-name --create-namespace --namespace red --set applicationName=target-a --set default.trench.name=trench-a
73+
helm install examples/target/deployments/helm/ --generate-name --create-namespace --namespace red --set applicationName=target-a --set default.trench.name=trench-a
7474
```
7575

7676
7. Deploy target of trench-b
7777

7878
```bash
79-
helm install examples/target/helm/ --generate-name --create-namespace --namespace red --set applicationName=target-b --set default.trench.name=trench-b
79+
helm install examples/target/deployments/helm/ --generate-name --create-namespace --namespace red --set applicationName=target-b --set default.trench.name=trench-b
8080
```
8181

8282
8. Run e2e tests

build/ctraffic/Dockerfile examples/target/build/example-target/Dockerfile

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ RUN go mod download
1515

1616
COPY . .
1717

18-
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags '-extldflags "-static"' -o target-client ./test/applications/target-client
18+
WORKDIR /app/examples/target
19+
20+
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags '-extldflags "-static"' -o target-client ./cmd/target-client
1921

2022
FROM ubuntu:22.04
2123

@@ -45,7 +47,7 @@ ADD https://github.com/Nordix/mconnect/releases/download/v2.2.0/mconnect.xz mcon
4547
RUN unxz mconnect.xz \
4648
&& chmod a+x mconnect
4749

48-
COPY --from=build /app/target-client .
50+
COPY --from=build /app/examples/target/target-client .
4951

5052
USER ${UID}:${UID}
5153
CMD ./ctraffic -server -address [::]:5000
File renamed without changes.

examples/target/helm/templates/target.yaml examples/target/deployments/helm/templates/target.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ spec:
1717
"spiffe.io/spiffe-id": "true"
1818
spec:
1919
containers:
20-
- name: ctraffic
21-
image: {{ .Values.registry }}/{{ .Values.organization }}/{{ .Values.ctraffic.image }}:{{ .Values.ctraffic.version }}
20+
- name: example-target
21+
image: {{ .Values.registry }}/{{ .Values.organization }}/{{ .Values.exampleTarget.image }}:{{ .Values.exampleTarget.version }}
2222
imagePullPolicy: {{ .Values.pullPolicy }}
2323
args:
2424
- ./target-client open -t {{ .Values.default.trench.name }} -c {{ .Values.default.conduit.name }} -s {{ .Values.default.stream.name }} ;

examples/target/helm/values.yaml examples/target/deployments/helm/values.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ tapa:
2424
image: tapa
2525
version: latest
2626

27-
ctraffic:
28-
image: ctraffic
27+
exampleTarget:
28+
image: example-target
2929
version: latest
3030

3131
nsp:

examples/target/go.mod

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
module github.com/nordix/meridio/examples/target
2+
3+
go 1.18
4+
5+
require (
6+
github.com/nordix/meridio v0.8.0
7+
google.golang.org/grpc v1.49.0
8+
)
9+
10+
require (
11+
github.com/golang/protobuf v1.5.2 // indirect
12+
golang.org/x/net v0.0.0-20220907135653-1e95f45603a7 // indirect
13+
golang.org/x/sys v0.0.0-20220908164124-27713097b956 // indirect
14+
golang.org/x/text v0.3.7 // indirect
15+
google.golang.org/genproto v0.0.0-20220908141613-51c1cc9bc6d0 // indirect
16+
google.golang.org/protobuf v1.28.1 // indirect
17+
)
18+
19+
replace github.com/nordix/meridio => ../..

examples/target/go.sum

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
2+
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
3+
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
4+
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
5+
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
6+
golang.org/x/net v0.0.0-20220907135653-1e95f45603a7 h1:1WGATo9HAhkWMbfyuVU0tEFP88OIkUvwaHFveQPvzCQ=
7+
golang.org/x/net v0.0.0-20220907135653-1e95f45603a7/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
8+
golang.org/x/sys v0.0.0-20220908164124-27713097b956 h1:XeJjHH1KiLpKGb6lvMiksZ9l0fVUh+AmGcm0nOMEBOY=
9+
golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
10+
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
11+
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
12+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
13+
google.golang.org/genproto v0.0.0-20220908141613-51c1cc9bc6d0 h1:bMz0aY2wd9TwUp9M7QfjBWuQqaFD/ZaTtvDpPDCo2Ow=
14+
google.golang.org/genproto v0.0.0-20220908141613-51c1cc9bc6d0/go.mod h1:rQWNQYp1kbHR3+n5cARSTCF5rlJOttUn8yIhRklGAWQ=
15+
google.golang.org/grpc v1.49.0 h1:WTLtQzmQori5FUH25Pq4WT22oCsv8USpQ+F6rqtsmxw=
16+
google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI=
17+
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
18+
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
19+
google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w=
20+
google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=

examples/target/readme.md

+21-2
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,35 @@
11
# Target example application
22

3+
## Deploy
4+
35
Deploy the common helm chart
46
```
57
helm install examples/target/common/ --generate-name --create-namespace --namespace my-app
68
```
79

810
Deploy application target-a with trench-a as default trench
911
```
10-
helm install examples/target/helm/ --generate-name --create-namespace --namespace my-app --set ipFamily=dualstack --set applicationName=target-a --set defaultTrench=trench-a
12+
helm install examples/target/deployments/helm/ --generate-name --create-namespace --namespace my-app --set ipFamily=dualstack --set applicationName=target-a --set defaultTrench=trench-a
1113
```
1214

1315
Deploy application target-b with trench-b as default trench
1416
```
15-
helm install examples/target/helm/ --generate-name --create-namespace --namespace my-app --set ipFamily=dualstack --set applicationName=target-b --set defaultTrench=trench-b
17+
helm install examples/target/deployments/helm/ --generate-name --create-namespace --namespace my-app --set ipFamily=dualstack --set applicationName=target-b --set defaultTrench=trench-b
18+
```
19+
20+
## Target Client
21+
22+
Open a stream
23+
```
24+
./target-client open -t trench-a -c load-balancer -s stream-a
25+
```
26+
27+
Close a stream
28+
```
29+
./target-client close -t trench-a -c load-balancer -s stream-a
30+
```
31+
32+
Watch stream events (on each event the full list is sent with the status of each stream)
33+
```
34+
./target-client watch
1635
```

test/applications/target-client/readme.md

-20
This file was deleted.

test/e2e/multi_trenches_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,12 @@ var _ = Describe("MultiTrenches", func() {
8585

8686
When("a target disconnects from a trench and connect to another one", func() {
8787
BeforeEach(func() {
88-
_, err := utils.PodExec(targetPod, "ctraffic", []string{"./target-client", "close", "-t", trenchAName, "-c", conduitA1Name, "-s", streamA1Name})
88+
_, err := utils.PodExec(targetPod, "example-target", []string{"./target-client", "close", "-t", trenchAName, "-c", conduitA1Name, "-s", streamA1Name})
8989
Expect(err).NotTo(HaveOccurred())
90-
_, err = utils.PodExec(targetPod, "ctraffic", []string{"./target-client", "open", "-t", trenchBName, "-c", conduitB1Name, "-s", streamB1Name})
90+
_, err = utils.PodExec(targetPod, "example-target", []string{"./target-client", "open", "-t", trenchBName, "-c", conduitB1Name, "-s", streamB1Name})
9191
Expect(err).NotTo(HaveOccurred())
9292
Eventually(func() bool {
93-
targetWatchOutput, err := utils.PodExec(targetPod, "ctraffic", []string{"timeout", "--preserve-status", "0.5", "./target-client", "watch"})
93+
targetWatchOutput, err := utils.PodExec(targetPod, "example-target", []string{"timeout", "--preserve-status", "0.5", "./target-client", "watch"})
9494
Expect(err).NotTo(HaveOccurred())
9595
streamStatus := utils.ParseTargetWatch(targetWatchOutput)
9696
if len(streamStatus) == 1 && streamStatus[0].Status == "OPEN" && streamStatus[0].Trench == trenchBName && streamStatus[0].Conduit == conduitB1Name && streamStatus[0].Stream == streamB1Name {
@@ -101,12 +101,12 @@ var _ = Describe("MultiTrenches", func() {
101101
})
102102

103103
AfterEach(func() {
104-
_, err := utils.PodExec(targetPod, "ctraffic", []string{"./target-client", "close", "-t", trenchBName, "-c", conduitB1Name, "-s", streamB1Name})
104+
_, err := utils.PodExec(targetPod, "example-target", []string{"./target-client", "close", "-t", trenchBName, "-c", conduitB1Name, "-s", streamB1Name})
105105
Expect(err).NotTo(HaveOccurred())
106-
_, err = utils.PodExec(targetPod, "ctraffic", []string{"./target-client", "open", "-t", trenchAName, "-c", conduitA1Name, "-s", streamA1Name})
106+
_, err = utils.PodExec(targetPod, "example-target", []string{"./target-client", "open", "-t", trenchAName, "-c", conduitA1Name, "-s", streamA1Name})
107107
Expect(err).NotTo(HaveOccurred())
108108
Eventually(func() bool {
109-
targetWatchOutput, err := utils.PodExec(targetPod, "ctraffic", []string{"timeout", "--preserve-status", "0.5", "./target-client", "watch"})
109+
targetWatchOutput, err := utils.PodExec(targetPod, "example-target", []string{"timeout", "--preserve-status", "0.5", "./target-client", "watch"})
110110
Expect(err).NotTo(HaveOccurred())
111111
streamStatus := utils.ParseTargetWatch(targetWatchOutput)
112112
if len(streamStatus) == 1 && streamStatus[0].Status == "OPEN" && streamStatus[0].Trench == trenchAName && streamStatus[0].Conduit == conduitA1Name && streamStatus[0].Stream == streamA1Name {

test/e2e/target_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,21 @@ var _ = Describe("Target", func() {
5454
)
5555

5656
BeforeEach(func() {
57-
_, err := utils.PodExec(targetPod, "ctraffic", []string{"./target-client", "close", "-t", trenchAName, "-c", conduitA1Name, "-s", streamA1Name})
57+
_, err := utils.PodExec(targetPod, "example-target", []string{"./target-client", "close", "-t", trenchAName, "-c", conduitA1Name, "-s", streamA1Name})
5858
Expect(err).NotTo(HaveOccurred())
5959
Eventually(func() bool {
60-
targetWatchOutput, err := utils.PodExec(targetPod, "ctraffic", []string{"timeout", "--preserve-status", "0.5", "./target-client", "watch"})
60+
targetWatchOutput, err := utils.PodExec(targetPod, "example-target", []string{"timeout", "--preserve-status", "0.5", "./target-client", "watch"})
6161
Expect(err).NotTo(HaveOccurred())
6262
streamStatus := utils.ParseTargetWatch(targetWatchOutput)
6363
return len(streamStatus) == 0
6464
}, timeout, interval).Should(BeTrue())
6565
})
6666

6767
AfterEach(func() {
68-
_, err = utils.PodExec(targetPod, "ctraffic", []string{"./target-client", "open", "-t", trenchAName, "-c", conduitA1Name, "-s", streamA1Name})
68+
_, err = utils.PodExec(targetPod, "example-target", []string{"./target-client", "open", "-t", trenchAName, "-c", conduitA1Name, "-s", streamA1Name})
6969
Expect(err).NotTo(HaveOccurred())
7070
Eventually(func() bool {
71-
targetWatchOutput, err := utils.PodExec(targetPod, "ctraffic", []string{"timeout", "--preserve-status", "0.5", "./target-client", "watch"})
71+
targetWatchOutput, err := utils.PodExec(targetPod, "example-target", []string{"timeout", "--preserve-status", "0.5", "./target-client", "watch"})
7272
Expect(err).NotTo(HaveOccurred())
7373
streamStatus := utils.ParseTargetWatch(targetWatchOutput)
7474
if len(streamStatus) == 1 && streamStatus[0].Status == "OPEN" && streamStatus[0].Trench == trenchAName && streamStatus[0].Conduit == conduitA1Name && streamStatus[0].Stream == streamA1Name {

test/e2e/utils/kubernetes.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func PodExec(pod *corev1.Pod, container string, command []string) (string, error
9292
}
9393

9494
func PodHasNetworkInterface(pod *corev1.Pod, container string, interfaceSubName string) (bool, error) {
95-
interfaces, err := PodExec(pod, "ctraffic", []string{"ip", "-o", "link", "show"})
95+
interfaces, err := PodExec(pod, "example-target", []string{"ip", "-o", "link", "show"})
9696
if err != nil {
9797
return false, err
9898
}

0 commit comments

Comments
 (0)