Skip to content

Instantly share code, notes, and snippets.

@aojea
Created February 23, 2024 14:56
Show Gist options
  • Save aojea/1a5f87d64fa3932cfc9c0ffe1225af99 to your computer and use it in GitHub Desktop.
Save aojea/1a5f87d64fa3932cfc9c0ffe1225af99 to your computer and use it in GitHub Desktop.
  1. Deploy the backends with the number of replicas we desire (we can always use kubectl later to scale up or down)
kubectl apply -f backend.yaml
  1. I recommend use the ClusterIP the Service and not depend on DNS since we just want to test the IP traffic
kubectl get service
NAME           TYPE        CLUSTER-IP         EXTERNAL-IP   PORT(S)   AGE
kubernetes     ClusterIP   10.96.0.1     <none>        443/TCP   4d3h
test-service   ClusterIP   10.96.0.23   <none>        80/TCP    13m

In this case is 10.96.0.3

  1. We can do manual tests just runnin an httpd:2 container
kubectl run ab1 --image apache:2
# ab -c 100 -t 2 -v 1 http://10.96.0.23:80/
This is ApacheBench, Version 2.3 <$Revision: 1903618 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 10.96.0.23 (be patient)
Completed 5000 requests
Completed 10000 requests
Completed 15000 requests
Finished 16021 requests


Server Software:
Server Hostname:        10.96.0.23
Server Port:            80
  1. If we can stress more the Service we can run multiple clients in parallel using a Job an adjunsting the completion and parallelism parameters
$ kubectl apply -f tester.yaml
$ kubectl get jobs
NAME     COMPLETIONS   DURATION   AGE
abtest   12/12         54s        5m19s

$  kubectl get pods
NAME                                 READY   STATUS             RESTARTS        AGE
ab1                                  0/1     ImagePullBackOff   0               22m
ab2                                  1/1     Running            0               21m
abtest-2dpdr                         0/1     Completed          0               5m11s
abtest-2rz6p                         0/1     Completed          0               5m24s
abtest-4lbsw                         0/1     Completed          0               5m36s
abtest-5456b                         0/1     Completed          0               4m56s
abtest-57277                         0/1     Completed          0               4m58s
abtest-b6lll                         0/1     Completed          0               5m11s
abtest-bzj7h                         0/1     Completed          0               5m24s
abtest-dzcvh                         0/1     Completed          0               5m36s
abtest-g4bg5                         0/1     Completed          0               5m36s
abtest-jc6qp                         0/1     Completed          0               5m24s
abtest-rptd8                         0/1     Completed          0               5m10s
abtest-wt9ft                         0/1     Completed          0               4m57s
apiVersion: apps/v1
kind: Deployment
metadata:
name: server-deployment
labels:
app: MyApp
spec:
replicas: 2
selector:
matchLabels:
app: MyApp
template:
metadata:
labels:
app: MyApp
spec:
containers:
- name: agnhost
image: k8s.gcr.io/e2e-test-images/agnhost:2.39
args:
- netexec
- --http-port=80
---
apiVersion: v1
kind: Service
metadata:
name: test-service
spec:
type: ClusterIP
selector:
app: MyApp
ports:
- protocol: TCP
port: 80
targetPort: 80
apiVersion: batch/v1
kind: Job
metadata:
name: abtest
spec:
completions: 12
parallelism: 3
template:
spec:
containers:
- name: ab
image: httpd:2
command: ["ab", "-n 50000", "-c 1000", “-v 1”, “http://[fd00:10:96::4d0c]:80/”]
restartPolicy: Never
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment