diff --git a/examples/web-show/deploy.sh b/examples/web-show/deploy.sh new file mode 100755 index 0000000000..465734958a --- /dev/null +++ b/examples/web-show/deploy.sh @@ -0,0 +1,58 @@ +#!/usr/bin/env bash + +set -e + +usage() { + cat << EOF +This script is used to install web-show. +USAGE: + install.sh [FLAGS] [OPTIONS] +FLAGS: + -h, --help Prints help information + --docker-mirror Use docker mirror to pull image +EOF +} + +DOCKER_MIRROR=false + +while [[ $# -gt 0 ]] +do +key="$1" + +case $key in + --docker-mirror) + DOCKER_MIRROR=true + shift + ;; + -h|--help) + usage + exit 0 + ;; + *) + echo "unknown option: $key" + usage + exit 1 + ;; +esac +done + +TARGET_IP=$(kubectl get pod -n kube-system -o wide| grep kube-controller | head -n 1 | awk '{print $6}') + +sed "s/TARGETIP/$TARGET_IP/g" deployment.yaml > deployment-target.yaml + +if [ ${DOCKER_MIRROR} == "true" ]; then + docker pull dockerhub.azk8s.cn/pingcap/web-show || true + docker tag dockerhub.azk8s.cn/pingcap/web-show pingcap/web-show || true + kind load docker-image pingcap/web-show > /dev/null 2>&1 || true +fi + +kubectl apply -f service.yaml +kubectl apply -f deployment-target.yaml + +rm -rf deployment-target.yaml + +while [[ $(kubectl get pods -l app=web-show -o 'jsonpath={..status.conditions[?(@.type=="Ready")].status}') != "True" ]]; do echo "Waiting for pod running" && sleep 1; done + +kill $(lsof -t -i:8081) 2>&1 >/dev/null || true + +nohup kubectl port-forward svc/web-show 8081:8081 >/dev/null 2>&1 & diff --git a/examples/web-show/deployment.yaml b/examples/web-show/deployment.yaml new file mode 100644 index 0000000000..6888c817a3 --- /dev/null +++ b/examples/web-show/deployment.yaml @@ -0,0 +1,27 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: web-show + labels: + app: web-show +spec: + replicas: 1 + selector: + matchLabels: + app: web-show + template: + metadata: + labels: + app: web-show + spec: + containers: + - name: web-show + image: pingcap/web-show + imagePullPolicy: Always + command: + - /usr/local/bin/web-show + - --target-ip=TARGETIP + ports: + - name: web-port + containerPort: 8081 + hostPort: 8081 diff --git a/examples/web-show/network-delay.yaml b/examples/web-show/network-delay.yaml new file mode 100644 index 0000000000..e7db6ecad3 --- /dev/null +++ b/examples/web-show/network-delay.yaml @@ -0,0 +1,19 @@ +apiVersion: pingcap.com/v1alpha1 +kind: NetworkChaos +metadata: + name: network-delay-example +spec: + action: delay + mode: one + selector: + namespaces: + - default + labelSelectors: + "app": "web-show" + delay: + latency: "10ms" + correlation: "100" + jitter: "0ms" + duration: "30s" + scheduler: + cron: "@every 60s" diff --git a/examples/web-show/service.yaml b/examples/web-show/service.yaml new file mode 100644 index 0000000000..faad46b80f --- /dev/null +++ b/examples/web-show/service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: web-show + labels: + app: web-show +spec: + selector: + app: web-show + ports: + - protocol: TCP + port: 8081 + targetPort: 8081