Skip to content

Instantly share code, notes, and snippets.

@jamesward
Created October 4, 2021 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesward/92d9168680faaadfaf24a89f0b6983ca to your computer and use it in GitHub Desktop.
Save jamesward/92d9168680faaadfaf24a89f0b6983ca to your computer and use it in GitHub Desktop.
cat <<EOF | kubectl apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
  name: hello-server
spec:
  selector:
    matchLabels:
      run: hello-server
  replicas: 1
  template:
    metadata:
      labels:
        run: hello-server
    spec:
      containers:
      - name: hello-server
        image: nginx
        ports:
        - containerPort: 80
        resources:
          requests:
            cpu: "0.5"
---
apiVersion: v1
kind: Service
metadata:
  name: hello-server
spec:
  type: ClusterIP
  ports:
    - port: 80
      targetPort: 80
  selector:
    run: hello-server
EOF
kubectl run -it --rm --image=gcr.io/gcp-runtimes/ubuntu_18_0_4 \
  --restart=Never \
  loadtest \
  --command -- bash -c "apt -qq update && apt -qq install -y wget && wget -q https://hey-release.s3.us-east-2.amazonaws.com/hey_linux_amd64 && chmod +x hey_linux_amd64 && ./hey_linux_amd64 -z 30s http://hello-server"

kubectl scale deployment/hello-server --replicas=5

kubectl delete pod/loadtest

kubectl run -it --rm --image=gcr.io/gcp-runtimes/ubuntu_18_0_4 \
  --restart=Never \
  loadtest \
  --command -- bash -c "apt -qq update && apt -qq install -y wget && wget -q https://hey-release.s3.us-east-2.amazonaws.com/hey_linux_amd64 && chmod +x hey_linux_amd64 && ./hey_linux_amd64 -z 30s http://hello-server"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment