forked from chaos-mesh/chaos-mesh
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add web-show example (chaos-mesh#304)
- Loading branch information
Showing
4 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 & |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |