Skip to content

Commit

Permalink
Traffic access v0
Browse files Browse the repository at this point in the history
Signed-off-by: Naveen Jain <[email protected]>
  • Loading branch information
nveenjain committed Jun 9, 2020
1 parent 591afce commit 76ab46e
Show file tree
Hide file tree
Showing 5 changed files with 251 additions and 3 deletions.
3 changes: 0 additions & 3 deletions deploy/k8s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ spec:
metadata:
labels:
app: app-a
annotations:
spec:
containers:
- name: app-a
Expand All @@ -37,7 +36,6 @@ spec:
metadata:
labels:
app: app-b
annotations:
spec:
containers:
- name: app-b
Expand All @@ -61,7 +59,6 @@ spec:
metadata:
labels:
app: app-c
annotations:
spec:
containers:
- name: app-c
Expand Down
125 changes: 125 additions & 0 deletions smi-test/trafficAccess/01-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: app-a
labels:
app: app-a
spec:
replicas: 1
selector:
matchLabels:
app: app-a
template:
metadata:
labels:
app: app-a
spec:
containers:
- name: app-a
image: layer5/sample-app-service:dev
imagePullPolicy: Never
ports:
- containerPort: 9091
status:
availableReplicas: 1
readyReplicas: 1
replicas: 1

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: app-b
labels:
app: app-b
spec:
replicas: 1
selector:
matchLabels:
app: app-b
template:
metadata:
labels:
app: app-b
spec:
containers:
- name: app-b
image: layer5/sample-app-service:dev
imagePullPolicy: Never
ports:
- containerPort: 9091
status:
availableReplicas: 1
readyReplicas: 1
replicas: 1

---
apiVersion: apps/v1
kind: Deployment
metadata:
name: app-c
labels:
app: app-c
spec:
replicas: 1
selector:
matchLabels:
app: app-c
template:
metadata:
labels:
app: app-c
spec:
containers:
- name: app-c
image: layer5/sample-app-service:dev
imagePullPolicy: Never
ports:
- containerPort: 9091
status:
availableReplicas: 1
readyReplicas: 1
replicas: 1

---
apiVersion: v1
kind: Service
metadata:
name: service-a
spec:
type: NodePort
selector:
app: app-a
ports:
- name: http
protocol: TCP
port: 9091
targetPort: 9091
---
apiVersion: v1
kind: Service
metadata:
name: service-b
spec:
type: ClusterIP
selector:
app: app-b
ports:
- name: http
protocol: TCP
port: 9091
targetPort: 9091
---
apiVersion: v1
kind: Service
metadata:
name: service-c
spec:
type: ClusterIP
selector:
app: app-c
ports:
- name: http
protocol: TCP
port: 9091
targetPort: 9091
110 changes: 110 additions & 0 deletions smi-test/trafficAccess/01-install.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: app-a
labels:
app: app-a
spec:
replicas: 1
selector:
matchLabels:
app: app-a
template:
metadata:
labels:
app: app-a
spec:
containers:
- name: app-a
image: layer5/sample-app-service:dev
imagePullPolicy: Never
ports:
- containerPort: 9091
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: app-b
labels:
app: app-b
spec:
replicas: 1
selector:
matchLabels:
app: app-b
template:
metadata:
labels:
app: app-b
spec:
containers:
- name: app-b
image: layer5/sample-app-service:dev
imagePullPolicy: Never
ports:
- containerPort: 9091
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: app-c
labels:
app: app-c
spec:
replicas: 1
selector:
matchLabels:
app: app-c
template:
metadata:
labels:
app: app-c
spec:
containers:
- name: app-c
image: layer5/sample-app-service:dev
imagePullPolicy: Never
ports:
- containerPort: 9091
---
apiVersion: v1
kind: Service
metadata:
name: service-a
spec:
type: NodePort
selector:
app: app-a
ports:
- name: http
protocol: TCP
port: 9091
targetPort: 9091
---
apiVersion: v1
kind: Service
metadata:
name: service-b
spec:
type: ClusterIP
selector:
app: app-b
ports:
- name: http
protocol: TCP
port: 9091
targetPort: 9091
---
apiVersion: v1
kind: Service
metadata:
name: service-c
spec:
type: ClusterIP
selector:
app: app-c
ports:
- name: http
protocol: TCP
port: 9091
targetPort: 9091
9 changes: 9 additions & 0 deletions smi-test/trafficAccess/02-traffic.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: kudo.dev/v1alpha1
kind: TestStep
delete:
- apiVersion: v1
kind: Pod
name: my-pod
commands:
- command: chmod +x ./execThis.sh
- command: sh ./execThis.sh
7 changes: 7 additions & 0 deletions smi-test/trafficAccess/execThis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

echo $(kubectl get service service-a --namespace=$NAMESPACE -o jsonpath="{.spec.ports[0].nodePort}")
kubectl describe pods --namespace=$NAMESPACE
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",}'


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 comments on commit 76ab46e

Please sign in to comment.