-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
734b731
commit 2ed3935
Showing
15 changed files
with
251 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM python:3.8-slim-buster | ||
|
||
WORKDIR /app | ||
COPY requirements.txt requirements.txt | ||
RUN pip3 install -r requirements.txt | ||
RUN apt-get update | ||
RUN apt-get -y install curl procps | ||
COPY example.py . | ||
COPY run.sh . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
docker build . -t mertyildiran/mizutest-sctp-client:latest && docker push mertyildiran/mizutest-sctp-client:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import socket | ||
import sctp | ||
import time | ||
|
||
print("Start SCTP client") | ||
|
||
sock = sctp.sctpsocket_tcp(socket.AF_INET) | ||
|
||
cnt = 0 | ||
connected = False | ||
while True: | ||
if not connected: | ||
try: | ||
sock.connect(("mizutest-sctp-server", 50051)) | ||
except: | ||
print("couldn't connect") | ||
time.sleep(3) | ||
continue | ||
|
||
connected = True | ||
|
||
msg = 'hello world %s' % cnt | ||
sock.sctp_send(msg=msg) | ||
print("Sent %s" % msg) | ||
cnt += 1 | ||
|
||
time.sleep(3) | ||
|
||
sock.shutdown(0) | ||
|
||
|
||
sock.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pysctp==0.7.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
python3 example.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM python:3.8-slim-buster | ||
|
||
WORKDIR /app | ||
COPY requirements.txt requirements.txt | ||
RUN pip3 install -r requirements.txt | ||
RUN apt-get update | ||
RUN apt-get -y install curl procps | ||
COPY example.py . | ||
COPY run.sh . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
docker build . -t mertyildiran/mizutest-sctp-server:latest && docker push mertyildiran/mizutest-sctp-server:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import socket | ||
import sctp | ||
|
||
print("Start SCTP server") | ||
|
||
host = '0.0.0.0' | ||
port = 50051 | ||
|
||
sock = sctp.sctpsocket_tcp(socket.AF_INET) | ||
sock.bind((host, port)) | ||
sock.listen(1) | ||
|
||
while True: | ||
# wait for a connection | ||
print ('waiting for a connection') | ||
connection, client_address = sock.accept() | ||
|
||
try: | ||
# show who connected to us | ||
print ('connection from', client_address) | ||
print (connection) | ||
# receive the data in small chunks and print it | ||
while True: | ||
data = connection.recv(999) | ||
if data: | ||
# output received data | ||
print ("Data: %s" % data.decode()) | ||
connection.sendall(str.encode("We recieved " + str(len(data)) + " bytes from you")) | ||
else: | ||
# no more data -- quit the loop | ||
print ("no more data.") | ||
break | ||
finally: | ||
# Clean up the connection | ||
connection.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pysctp==0.7.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
python3 example.py |
50 changes: 50 additions & 0 deletions
50
deploy/kubernetes/manifests/extras/56-mizutest-sctp-server-dep.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: mizutest-sctp-server | ||
labels: | ||
name: mizutest-sctp-server | ||
namespace: sock-shop | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
name: mizutest-sctp-server | ||
template: | ||
metadata: | ||
labels: | ||
name: mizutest-sctp-server | ||
spec: | ||
containers: | ||
- name: mizutest-sctp-server | ||
image: mertyildiran/mizutest-sctp-server:latest | ||
env: | ||
- name: PYTHONUNBUFFERED | ||
value: "1" | ||
- name: PYTHONIOENCODING | ||
value: "UTF-8" | ||
imagePullPolicy: Always | ||
command: ["sh", "-c", "./run.sh"] | ||
resources: | ||
limits: | ||
cpu: 75m | ||
memory: 100Mi | ||
requests: | ||
cpu: 10m | ||
memory: 10Mi | ||
ports: | ||
- containerPort: 50051 | ||
hostPort: 50051 | ||
protocol: SCTP | ||
securityContext: | ||
runAsNonRoot: true | ||
runAsUser: 10001 | ||
capabilities: | ||
drop: | ||
- all | ||
add: | ||
- NET_BIND_SERVICE | ||
readOnlyRootFilesystem: true | ||
nodeSelector: | ||
beta.kubernetes.io/os: linux |
19 changes: 19 additions & 0 deletions
19
deploy/kubernetes/manifests/extras/57-mizutest-sctp-server-svc.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: mizutest-sctp-server | ||
annotations: | ||
prometheus.io/scrape: 'true' | ||
labels: | ||
name: mizutest-sctp-server | ||
namespace: sock-shop | ||
spec: | ||
clusterIP: None # Headless | ||
ports: | ||
# the port that this service should serve on | ||
- port: 50051 | ||
targetPort: 50051 | ||
protocol: SCTP | ||
selector: | ||
name: mizutest-sctp-server |
48 changes: 48 additions & 0 deletions
48
deploy/kubernetes/manifests/extras/58-mizutest-sctp-client-dep.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: mizutest-sctp-client | ||
labels: | ||
name: mizutest-sctp-client | ||
namespace: sock-shop | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
name: mizutest-sctp-client | ||
template: | ||
metadata: | ||
labels: | ||
name: mizutest-sctp-client | ||
spec: | ||
containers: | ||
- name: mizutest-sctp-client | ||
image: mertyildiran/mizutest-sctp-client:latest | ||
env: | ||
- name: PYTHONUNBUFFERED | ||
value: "1" | ||
- name: PYTHONIOENCODING | ||
value: "UTF-8" | ||
imagePullPolicy: Always | ||
command: ["sh", "-c", "./run.sh"] | ||
resources: | ||
limits: | ||
cpu: 75m | ||
memory: 100Mi | ||
requests: | ||
cpu: 10m | ||
memory: 10Mi | ||
ports: | ||
- containerPort: 50051 | ||
securityContext: | ||
runAsNonRoot: true | ||
runAsUser: 10001 | ||
capabilities: | ||
drop: | ||
- all | ||
add: | ||
- NET_BIND_SERVICE | ||
readOnlyRootFilesystem: true | ||
nodeSelector: | ||
beta.kubernetes.io/os: linux |
17 changes: 17 additions & 0 deletions
17
deploy/kubernetes/manifests/extras/59-mizutest-sctp-client-svc.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: mizutest-sctp-client | ||
annotations: | ||
prometheus.io/scrape: 'true' | ||
labels: | ||
name: mizutest-sctp-client | ||
namespace: sock-shop | ||
spec: | ||
ports: | ||
# the port that this service should serve on | ||
- port: 50051 | ||
targetPort: 50051 | ||
selector: | ||
name: mizutest-sctp-client |
18 changes: 18 additions & 0 deletions
18
deploy/kubernetes/manifests/extras/60-mizutest-sctp-network-policy.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
apiVersion: networking.k8s.io/v1 | ||
kind: NetworkPolicy | ||
metadata: | ||
name: kubeshark-hub-network-policy | ||
namespace: sock-shop | ||
spec: | ||
podSelector: | ||
matchLabels: | ||
name: mizutest-sctp-server | ||
policyTypes: | ||
- Ingress | ||
- Egress | ||
ingress: | ||
- ports: | ||
- protocol: SCTP | ||
port: 50051 | ||
egress: | ||
- {} |