Skip to content

Commit 107ecc3

Browse files
committed
Reuse the automated test setup for y-cluster-provision-k3s-docker
1 parent 3f46562 commit 107ecc3

File tree

5 files changed

+40
-30
lines changed

5 files changed

+40
-30
lines changed

bin/y-cluster-provision-k3s-docker

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,24 @@ set -e
44

55
[ -z "$KUBECONFIG" ] && echo "Provision requires an explicit KUBECONFIG env" && exit 1
66

7-
COMPOSE="docker-compose -p ystack -f docker-compose.test.yml"
8-
[ -z "$NODES" ] && NODES=2
9-
# TODO condition to toggle dev/qa mode
10-
false || {
11-
COMPOSE="$COMPOSE -f docker-compose.dev-overrides.yml"
12-
# ATM with port-forward we only support one node
13-
[ $NODES -eq 1 ] || echo "# Dev mode only supports one node, util we add some kind of load balancer container"
14-
NODES=1
15-
}
16-
17-
(cd $YSTACK_HOME/ && \
18-
$COMPOSE up --scale node=$NODES -d --build && \
19-
docker ps && \
20-
echo "# Compose commmand:" && echo "$COMPOSE" && \
21-
echo "# To tear down:" && echo "$COMPOSE down --remove-orphans -v" && \
22-
echo "# Currently, because sut doesn't wait for server to be up, you need another:" && echo "$COMPOSE up -d" && \
23-
true )
24-
25-
$COMPOSE exec server sh -c 'until test -f /admin/.kube/kubeconfig.yaml; do echo "# Waiting ..." && sleep 1; done; cat /admin/.kube/kubeconfig.yaml' \
7+
[ -z "$CONTEXTNAME" ] && CONTEXTNAME=local
8+
9+
COMPOSE=y-docker-compose
10+
$COMPOSE up --build -d ystack-proxy
11+
12+
echo "# Compose command:"
13+
echo "$COMPOSE"
14+
echo "# To tear down:"
15+
echo "$COMPOSE down --remove-orphans -v"
16+
17+
$COMPOSE exec master1 sh -c 'until test -f /admin/.kube/kubeconfig.yaml; do sleep 1; done; cat /admin/.kube/kubeconfig.yaml' \
2618
> "$KUBECONFIG.tmp"
2719

28-
KUBECONFIG="$KUBECONFIG.tmp" kubectl config rename-context default local
20+
KUBECONFIG="$KUBECONFIG.tmp" kubectl config rename-context default $CONTEXTNAME
2921

3022
y-kubeconfig-import "$KUBECONFIG.tmp"
23+
24+
YSTACK_SUT_KEEP_RUNNING=false y-docker-compose up --build sut
25+
26+
# specs currently don't clean up after themselves
27+
kubectl --context=$CONTEXTNAME -n ystack-specs scale --replicas=0 deploy --all

bin/y-cluster-provision-k3s-multipass

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ set -e
44

55
[ -z "$KUBECONFIG" ] && echo "Provision requires an explicit KUBECONFIG env" && exit 1
66

7+
[ -z "$CONTEXTNAME" ] && CONTEXTNAME=local
8+
79
[ -z "$VM_NAME" ] && VM_NAME="ystack-master"
810
[ -z "$VM_RESOURCES" ] && VM_RESOURCES="-m 8G -d 40G -c 4"
911

@@ -24,7 +26,7 @@ multipass exec "$VM_NAME" -- sudo cat /etc/rancher/k3s/k3s.yaml \
2426
| sed "s|127.0.0.1|$K3S_NODEIP_MASTER|" \
2527
> "$KUBECONFIG.tmp"
2628

27-
KUBECONFIG="$KUBECONFIG.tmp" kubectl config rename-context default local
29+
KUBECONFIG="$KUBECONFIG.tmp" kubectl config rename-context default $CONTEXTNAME
2830

2931
KUBECONFIG="$KUBECONFIG.tmp" kubectl --context=local create namespace ystack
3032

bin/y-docker-compose

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,22 @@ COMPOSEFILES="-f $YSTACK_HOME/docker-compose.test.yml -f $YSTACK_HOME/docker-com
88

99
KUBECONFIG=$YSTACK_HOME/devcluster/.kube/kubeconfig.yaml
1010

11-
[ "$1" = "kubeconfig-path" ] && \
11+
if [ "$1" = "kubeconfig-path" ]; then
1212
echo "$KUBECONFIG" && \
1313
exit 0
14+
fi
1415

15-
[ "$1" = "kubie" ] && \
16-
y-kubie ctx -f $KUBECONFIG && \
16+
if [ "$1" = "kubie" ]; then
17+
y-kubie ctx -f $KUBECONFIG
1718
exit 0
19+
fi
1820

1921
docker-compose $COMPOSEFILES "$@"
2022

21-
[ "$1" = "down" ] && \
22-
echo "Removing local config" && \
23-
(docker-compose $COMPOSEFILES up cleanup) && \
24-
echo "Cleaning up volumes" && \
25-
(docker volume rm ystack_admin ystack_k3s-server 2>/dev/null || true) && \
23+
if [ "$1" = "down" ]; then
24+
echo "Removing local config"
25+
(docker-compose $COMPOSEFILES up cleanup)
26+
echo "Cleaning up volumes"
27+
(docker volume rm ystack_admin ystack_k3s-server 2>/dev/null || true)
2628
echo "Done"
29+
fi

docker-compose.dev-overrides.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ services:
2020

2121
sut:
2222
environment:
23-
- KEEP_RUNNING=true
23+
- KEEP_RUNNING=${YSTACK_SUT_KEEP_RUNNING-true}
24+
- EXAMPLES=${YSTACK_SUT_EXAMPLES-}
2425

2526
volumes:
2627
admin:

hooks/post_push

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
echo "post_push listing env"
4+
printenv
5+
6+
echo "post_push listing images"
7+
docker images

0 commit comments

Comments
 (0)