Skip to content

Commit 76ab46e

Browse files
committed
Traffic access v0
Signed-off-by: Naveen Jain <[email protected]>
1 parent 591afce commit 76ab46e

File tree

5 files changed

+251
-3
lines changed

5 files changed

+251
-3
lines changed

deploy/k8s.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ spec:
1313
metadata:
1414
labels:
1515
app: app-a
16-
annotations:
1716
spec:
1817
containers:
1918
- name: app-a
@@ -37,7 +36,6 @@ spec:
3736
metadata:
3837
labels:
3938
app: app-b
40-
annotations:
4139
spec:
4240
containers:
4341
- name: app-b
@@ -61,7 +59,6 @@ spec:
6159
metadata:
6260
labels:
6361
app: app-c
64-
annotations:
6562
spec:
6663
containers:
6764
- name: app-c

smi-test/trafficAccess/01-assert.yaml

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: app-a
5+
labels:
6+
app: app-a
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app: app-a
12+
template:
13+
metadata:
14+
labels:
15+
app: app-a
16+
spec:
17+
containers:
18+
- name: app-a
19+
image: layer5/sample-app-service:dev
20+
imagePullPolicy: Never
21+
ports:
22+
- containerPort: 9091
23+
status:
24+
availableReplicas: 1
25+
readyReplicas: 1
26+
replicas: 1
27+
28+
---
29+
apiVersion: apps/v1
30+
kind: Deployment
31+
metadata:
32+
name: app-b
33+
labels:
34+
app: app-b
35+
spec:
36+
replicas: 1
37+
selector:
38+
matchLabels:
39+
app: app-b
40+
template:
41+
metadata:
42+
labels:
43+
app: app-b
44+
spec:
45+
containers:
46+
- name: app-b
47+
image: layer5/sample-app-service:dev
48+
imagePullPolicy: Never
49+
ports:
50+
- containerPort: 9091
51+
status:
52+
availableReplicas: 1
53+
readyReplicas: 1
54+
replicas: 1
55+
56+
---
57+
apiVersion: apps/v1
58+
kind: Deployment
59+
metadata:
60+
name: app-c
61+
labels:
62+
app: app-c
63+
spec:
64+
replicas: 1
65+
selector:
66+
matchLabels:
67+
app: app-c
68+
template:
69+
metadata:
70+
labels:
71+
app: app-c
72+
spec:
73+
containers:
74+
- name: app-c
75+
image: layer5/sample-app-service:dev
76+
imagePullPolicy: Never
77+
ports:
78+
- containerPort: 9091
79+
status:
80+
availableReplicas: 1
81+
readyReplicas: 1
82+
replicas: 1
83+
84+
---
85+
apiVersion: v1
86+
kind: Service
87+
metadata:
88+
name: service-a
89+
spec:
90+
type: NodePort
91+
selector:
92+
app: app-a
93+
ports:
94+
- name: http
95+
protocol: TCP
96+
port: 9091
97+
targetPort: 9091
98+
---
99+
apiVersion: v1
100+
kind: Service
101+
metadata:
102+
name: service-b
103+
spec:
104+
type: ClusterIP
105+
selector:
106+
app: app-b
107+
ports:
108+
- name: http
109+
protocol: TCP
110+
port: 9091
111+
targetPort: 9091
112+
---
113+
apiVersion: v1
114+
kind: Service
115+
metadata:
116+
name: service-c
117+
spec:
118+
type: ClusterIP
119+
selector:
120+
app: app-c
121+
ports:
122+
- name: http
123+
protocol: TCP
124+
port: 9091
125+
targetPort: 9091
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: app-a
5+
labels:
6+
app: app-a
7+
spec:
8+
replicas: 1
9+
selector:
10+
matchLabels:
11+
app: app-a
12+
template:
13+
metadata:
14+
labels:
15+
app: app-a
16+
spec:
17+
containers:
18+
- name: app-a
19+
image: layer5/sample-app-service:dev
20+
imagePullPolicy: Never
21+
ports:
22+
- containerPort: 9091
23+
---
24+
apiVersion: apps/v1
25+
kind: Deployment
26+
metadata:
27+
name: app-b
28+
labels:
29+
app: app-b
30+
spec:
31+
replicas: 1
32+
selector:
33+
matchLabels:
34+
app: app-b
35+
template:
36+
metadata:
37+
labels:
38+
app: app-b
39+
spec:
40+
containers:
41+
- name: app-b
42+
image: layer5/sample-app-service:dev
43+
imagePullPolicy: Never
44+
ports:
45+
- containerPort: 9091
46+
---
47+
apiVersion: apps/v1
48+
kind: Deployment
49+
metadata:
50+
name: app-c
51+
labels:
52+
app: app-c
53+
spec:
54+
replicas: 1
55+
selector:
56+
matchLabels:
57+
app: app-c
58+
template:
59+
metadata:
60+
labels:
61+
app: app-c
62+
spec:
63+
containers:
64+
- name: app-c
65+
image: layer5/sample-app-service:dev
66+
imagePullPolicy: Never
67+
ports:
68+
- containerPort: 9091
69+
---
70+
apiVersion: v1
71+
kind: Service
72+
metadata:
73+
name: service-a
74+
spec:
75+
type: NodePort
76+
selector:
77+
app: app-a
78+
ports:
79+
- name: http
80+
protocol: TCP
81+
port: 9091
82+
targetPort: 9091
83+
---
84+
apiVersion: v1
85+
kind: Service
86+
metadata:
87+
name: service-b
88+
spec:
89+
type: ClusterIP
90+
selector:
91+
app: app-b
92+
ports:
93+
- name: http
94+
protocol: TCP
95+
port: 9091
96+
targetPort: 9091
97+
---
98+
apiVersion: v1
99+
kind: Service
100+
metadata:
101+
name: service-c
102+
spec:
103+
type: ClusterIP
104+
selector:
105+
app: app-c
106+
ports:
107+
- name: http
108+
protocol: TCP
109+
port: 9091
110+
targetPort: 9091
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
apiVersion: kudo.dev/v1alpha1
2+
kind: TestStep
3+
delete:
4+
- apiVersion: v1
5+
kind: Pod
6+
name: my-pod
7+
commands:
8+
- command: chmod +x ./execThis.sh
9+
- command: sh ./execThis.sh

smi-test/trafficAccess/execThis.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
echo $(kubectl get service service-a --namespace=$NAMESPACE -o jsonpath="{.spec.ports[0].nodePort}")
3+
kubectl describe pods --namespace=$NAMESPACE
4+
curl --location --request POST 'http://localhost:'$(echo $(kubectl get service service-a --namespace=$NAMESPACE -o jsonpath="{.spec.ports[0].nodePort}"))'/call' -w "%{http_code}" --data-raw '{"host": "http://service-b/post",}'
5+
6+
7+
curl --location --request GET 'localhost:'$(echo $(kubectl get service service-a --namespace=$NAMESPACE -o jsonpath="{.spec.ports[0].nodePort}"))'/metrics' --header 'Content-Type: application/json' --data-raw '{"hello": "bye"}'

0 commit comments

Comments
 (0)