Last active
October 12, 2022 10:38
-
-
Save thikade/25789786f0295ba6d945c39bdf4cb2ce to your computer and use it in GitHub Desktop.
test K8s service loadbalancing. Deploys a client pod, a webserver deployment with 2 replicas, as well as a *stateful* and a *stateless* service to the webserver pods
This file contains hidden or 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
--- | |
# Use curl to test service loadbalancing on stateful and stateless services: | |
### simple: | |
# oc exec client -- curl -sS http://stateless:8080 | |
# | |
### automated: | |
# for i in $(seq 1 100); do oc exec client -- curl -sS http://stateless:8080 | head -n1; sleep 1; done | |
# for i in $(seq 1 100); do oc exec client -- curl -sS http://stateful:8080 | head -n1; sleep 1; done | |
apiVersion: v1 | |
kind: Pod | |
metadata: | |
creationTimestamp: null | |
labels: | |
run: client | |
name: client | |
spec: | |
containers: | |
- args: | |
- sleep | |
- infinity | |
image: rhel7/rhel-tools | |
name: client | |
resources: {} | |
dnsPolicy: ClusterFirst | |
restartPolicy: Always | |
--- | |
apiVersion: apps/v1 | |
kind: Deployment | |
metadata: | |
creationTimestamp: null | |
labels: | |
app: webserver | |
name: webserver | |
spec: | |
replicas: 2 | |
selector: | |
matchLabels: | |
app: webserver | |
strategy: {} | |
template: | |
metadata: | |
labels: | |
app: webserver | |
spec: | |
containers: | |
- image: docker.io/traefik/whoami:latest | |
name: whoami | |
args: | |
- "--port" | |
- "8080" | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
creationTimestamp: null | |
labels: | |
app: webserver | |
name: stateless | |
spec: | |
ports: | |
- port: 8080 | |
protocol: TCP | |
targetPort: 8080 | |
selector: | |
app: webserver | |
--- | |
apiVersion: v1 | |
kind: Service | |
metadata: | |
creationTimestamp: null | |
labels: | |
app: webserver | |
name: stateful | |
spec: | |
ports: | |
- port: 8080 | |
protocol: TCP | |
targetPort: 8080 | |
selector: | |
app: webserver | |
sessionAffinity: ClientIP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment