Skip to content

Commit 97ccf08

Browse files
authored
chore(demo-env): Fix resource tree and redis (#118)
Signed-off-by: jannfis <[email protected]>
1 parent ddbbf7b commit 97ccf08

File tree

7 files changed

+33
-9
lines changed

7 files changed

+33
-9
lines changed

hack/demo-env/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This directory and sub-directories contain scripts, kustomize manifests and othe
88

99
The scripts are targeting the author's development system. Do not run them against yours or be prepared to dive into undocumented configuration and to clean up after yourself.
1010

11-
It uses `vcluster` to create three virtual clusters:
11+
It uses [vcluster](https://github.com/loft-sh/vcluster) to create three virtual clusters:
1212

1313
* vcluster-control-plane - For hosting the control plane and principal
1414
* vcluster-agent-managed - A cluster with agent in managed mode
@@ -20,6 +20,8 @@ Both, vclusters and Argo CD installations, will require that LoadBalancer functi
2020

2121
## Set up
2222

23+
Make sure you have administrative access to a cluster and [vcluster](https://github.com/loft-sh/vcluster) is installed on your machine and within your `$PATH`.
24+
2325
To setup, run
2426

2527
```

hack/demo-env/agent-managed/argocd-cmd-params-cm.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ metadata:
55
data:
66
repo.server: 192.168.56.222:8081
77
redis.server: 192.168.56.221:6379
8+
application.namespaces: agent-managed

hack/demo-env/agent-managed/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ resources:
99

1010
patches:
1111
- path: argocd-cmd-params-cm.yaml
12-
- path: argocd-secret.yaml
12+
- path: argocd-secret.yaml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
resources:
22
- default-project.yaml
3+
- redis-secret.yaml
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: v1
2+
data:
3+
auth: a3BReU5ZLWpjaGU3RUJ1Vw==
4+
kind: Secret
5+
metadata:
6+
name: argocd-redis
7+
type: Opaque

hack/demo-env/setup-vcluster-env.sh

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
set -e
33
set -o pipefail
44
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
5-
VCLUSTERS="control-plane agent-managed agent-autonomous"
5+
VCLUSTERS="control-plane:argocd agent-managed:argocd agent-autonomous:argocd"
66
action="$1"
77

88
# Kubectl context to restore to
@@ -12,23 +12,35 @@ cleanup() {
1212
kubectl config set-context ${context}
1313
}
1414

15+
cluster() {
16+
IFS=":" s=($1); echo ${s[0]}
17+
}
18+
19+
namespace() {
20+
IFS=":" s=($1); echo ${s[1]}
21+
}
22+
1523
trap cleanup EXIT ERR
1624

1725
apply() {
1826
echo "-> Creating Argo CD instances in vclusters"
19-
for cluster in $VCLUSTERS; do
27+
for c in $VCLUSTERS; do
28+
cluster=$(cluster $c)
29+
namespace=$(namespace $c)
2030
echo " --> Creating instance in vcluster $cluster"
21-
kubectl --context vcluster-${cluster} create ns argocd || true
22-
kubectl --context vcluster-${cluster} apply -n argocd -k ${SCRIPTPATH}/${cluster}
31+
kubectl --context vcluster-$cluster create ns $namespace || true
32+
kubectl --context vcluster-$cluster apply -n $namespace -k ${SCRIPTPATH}/${cluster}
2333
done
2434
kubectl --context vcluster-control-plane create ns agent-autonomous || true
2535
kubectl --context vcluster-control-plane create ns agent-managed || true
36+
kubectl --context vcluster-agent-managed create ns agent-managed || true
2637
}
2738

2839
case "$action" in
2940
create)
3041
echo "-> Creating required vclusters"
31-
for cluster in $VCLUSTERS; do
42+
for c in $VCLUSTERS; do
43+
cluster=$(cluster $c)
3244
echo " --> Creating vcluster $cluster"
3345
vcluster create --context=default -n vcluster-${cluster} --expose --kube-config-context-name vcluster-${cluster} vcluster-${cluster}
3446
done
@@ -40,7 +52,8 @@ apply)
4052
;;
4153
delete)
4254
echo "-> Deleting vclusters"
43-
for cluster in $VCLUSTERS; do
55+
for c in $VCLUSTERS; do
56+
cluster=$(cluster $c)
4457
echo " --> Deleting vcluster $cluster"
4558
vcluster delete --context=default vcluster-${cluster} || true
4659
done

hack/demo-env/start-agent-managed.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ if ! kubectl config get-contexts | tail -n +2 | awk '{ print $2 }' | grep -qE '^
66
fi
77
SCRIPTPATH="$( cd -- "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
88
test -f cmd/agent/main.go || (echo "Script should be run from argocd-agent's root path" >&2; exit 1)
9-
go run ./cmd/agent/main.go --agent-mode managed --creds userpass:${SCRIPTPATH}/creds/creds.agent-managed --server-address 127.0.0.1 --server-port 8443 --insecure-tls --kubecontext vcluster-agent-managed --namespace argocd
9+
go run ./cmd/agent/main.go --agent-mode managed --creds userpass:${SCRIPTPATH}/creds/creds.agent-managed --server-address 127.0.0.1 --server-port 8443 --insecure-tls --kubecontext vcluster-agent-managed --namespace agent-managed

0 commit comments

Comments
 (0)