Skip to content

Commit 78bc884

Browse files
committed
Initial commit for the script files
Signed-off-by: Anand Francis Joseph <[email protected]>
1 parent 6b1cfb6 commit 78bc884

10 files changed

+349
-0
lines changed

cleanup-clusters.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CLUSTERS="hub cluster1 cluster2"
2+
for cluster in ${CLUSTERS};do
3+
kind delete cluster --name ${cluster}
4+
done;

clusteradm

52.1 MB
Binary file not shown.

create-multicluster-kind.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
3+
cd $(dirname ${BASH_SOURCE})
4+
5+
set -e
6+
7+
hub=${CLUSTER1:-hub}
8+
c1=${CLUSTER1:-cluster1}
9+
c2=${CLUSTER2:-cluster2}
10+
11+
hubctx="kind-${hub}"
12+
c1ctx="kind-${c1}"
13+
c2ctx="kind-${c2}"
14+
15+
kind create cluster --name "${hub}"
16+
kind create cluster --name "${c1}"
17+
kind create cluster --name "${c2}"
18+
19+
echo "Initialize the ocm hub cluster\n"
20+
clusteradm init --feature-gates=ManifestWorkReplicaSet=true --wait --context ${hubctx}
21+
joincmd=$(clusteradm get token --context ${hubctx} | grep clusteradm)
22+
23+
echo "Join cluster1 to hub\n"
24+
$(echo ${joincmd} --force-internal-endpoint-lookup --wait --context ${c1ctx} | sed "s/<cluster_name>/$c1/g")
25+
26+
echo "Join cluster2 to hub\n"
27+
$(echo ${joincmd} --force-internal-endpoint-lookup --wait --context ${c2ctx} | sed "s/<cluster_name>/$c2/g")
28+
29+
echo "Accept join of cluster1 and cluster2"
30+
clusteradm accept --context ${hubctx} --clusters ${c1},${c2} --wait
31+
32+
kubectl get managedclusters --all-namespaces --context ${hubctx}
33+
34+
sleep 10
35+
36+
clusteradm clusterset bind default --namespace default --context kind-hub

create-mwr-app-platform.sh

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
cat << EOF | kubectl apply --context kind-hub -f -
2+
apiVersion: work.open-cluster-management.io/v1alpha1
3+
kind: ManifestWorkReplicaSet
4+
metadata:
5+
name: argo-app-platform
6+
namespace: default
7+
spec:
8+
manifestWorkTemplate:
9+
workload:
10+
manifests:
11+
- apiVersion: rbac.authorization.k8s.io/v1
12+
kind: ClusterRole
13+
metadata:
14+
name: open-cluster-management:klusterlet-work:my-role
15+
rules:
16+
- apiGroups:
17+
- argoproj.io
18+
resources:
19+
- '*'
20+
verbs:
21+
- get
22+
- list
23+
- watch
24+
- create
25+
- update
26+
- patch
27+
- delete
28+
- apiVersion: rbac.authorization.k8s.io/v1
29+
kind: ClusterRoleBinding
30+
metadata:
31+
name: open-cluster-management:klusterlet-work:my-binding
32+
roleRef:
33+
apiGroup: rbac.authorization.k8s.io
34+
kind: ClusterRole
35+
name: open-cluster-management:klusterlet-work:my-role
36+
subjects:
37+
- kind: ServiceAccount
38+
name: klusterlet-work-sa
39+
namespace: open-cluster-management-agent
40+
- apiVersion: argoproj.io/v1alpha1
41+
kind: ApplicationSet
42+
metadata:
43+
name: app-platform
44+
namespace: argocd
45+
spec:
46+
generators:
47+
- list:
48+
elements:
49+
- component: cert-manager
50+
repoURL: https://charts.jetstack.io
51+
chartVersion: "v1.11.2"
52+
chart: cert-manager
53+
namespace: cert-manager
54+
- component: istio
55+
repoURL: https://istio-release.storage.googleapis.com/charts
56+
chartVersion: "1.18.0"
57+
chart: base
58+
namespace: istio-system
59+
- component: jaeger
60+
repoURL: https://jaegertracing.github.io/helm-charts
61+
chartVersion: "2.43.0"
62+
chart: jaeger-operator
63+
namespace: o11y
64+
- component: opensearch
65+
repoURL: https://opensearch-project.github.io/helm-charts
66+
chartVersion: "1.20.0"
67+
chart: opensearch
68+
namespace: o11y
69+
- component: opensearch-dashboards
70+
repoURL: https://opensearch-project.github.io/helm-charts
71+
chartVersion: "1.13.0"
72+
chart: opensearch-dashboards
73+
namespace: o11y
74+
- component: kiali
75+
repoURL: https://kiali.org/helm-charts
76+
chartVersion: "1.69.0"
77+
chart: kiali-operator
78+
namespace: o11y
79+
- component: prometheus
80+
repoURL: https://prometheus-community.github.io/helm-charts
81+
chartVersion: "47.0.0"
82+
chart: kube-prometheus-stack
83+
namespace: o11y
84+
serverSideApply: true
85+
- component: grafana
86+
repoURL: https://grafana.github.io/helm-charts
87+
chartVersion: "6.56.5"
88+
chart: grafana
89+
namespace: o11y
90+
- component: fluentd
91+
repoURL: registry-1.docker.io
92+
chartVersion: "5.8.2"
93+
chart: bitnamicharts/fluentd
94+
namespace: o11y
95+
- component: keycloak
96+
repoURL: https://codecentric.github.io/helm-charts
97+
chartVersion: "18.4.3"
98+
chart: keycloak
99+
namespace: security
100+
- component: ingress-nginx
101+
repoURL: https://kubernetes.github.io/ingress-nginx
102+
chartVersion: "4.7.0"
103+
chart: ingress-nginx
104+
namespace: ingress-nginx
105+
- component: kubevela
106+
repoURL: https://charts.kubevela.net/core
107+
chartVersion: "1.8.2"
108+
chart: vela-core
109+
namespace: vela-system
110+
- component: velero
111+
repoURL: https://vmware-tanzu.github.io/helm-charts
112+
chartVersion: "4.0.2"
113+
chart: velero
114+
namespace: velero
115+
goTemplate: true
116+
template:
117+
metadata:
118+
name: "{{.component}}"
119+
annotations:
120+
argocd.argoproj.io/manifest-generate-paths: ".;.."
121+
spec:
122+
ignoreDifferences:
123+
- group: admissionregistration.k8s.io
124+
kind: MutatingWebhookConfiguration
125+
jqPathExpressions:
126+
- '.webhooks[]?.clientConfig.caBundle'
127+
- group: admissionregistration.k8s.io
128+
kind: ValidatingWebhookConfiguration
129+
jqPathExpressions:
130+
- '.webhooks[]?.clientConfig.caBundle'
131+
- '.webhooks[]?.failurePolicy'
132+
- group: cert-manager.io
133+
kind: Certificate
134+
jsonPointers:
135+
- /spec/duration
136+
- group: apiregistration.k8s.io
137+
kind: APIService
138+
jsonPointers:
139+
- /spec/insecureSkipTLSVerify
140+
- /spec/caBundle
141+
project: default
142+
sources:
143+
- repoURL: "{{.repoURL}}"
144+
targetRevision: "{{.chartVersion}}"
145+
helm:
146+
passCredentials: true
147+
valueFiles:
148+
- '\$values/components/{{.component}}/values.yaml'
149+
releaseName: "{{.component}}"
150+
chart: "{{.chart}}"
151+
- repoURL: "https://github.com/anandf/app-platform-argocd.git"
152+
targetRevision: main
153+
ref: values
154+
- repoURL: "https://github.com/anandf/app-platform-argocd"
155+
targetRevision: main
156+
path: "components/{{.component}}"
157+
destination:
158+
name: in-cluster
159+
namespace: "{{.namespace}}"
160+
syncPolicy:
161+
automated:
162+
prune: true
163+
selfHeal: true
164+
syncOptions:
165+
- CreateNamespace=true
166+
- ServerSideApply={{or .serverSideApply false}}
167+
168+
placementRefs:
169+
- name: demo-clusters
170+
EOF

create-mwr-guestbook.sh

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
cat << EOF | kubectl apply --context kind-hub -f -
2+
apiVersion: work.open-cluster-management.io/v1alpha1
3+
kind: ManifestWorkReplicaSet
4+
metadata:
5+
name: argo-guestbook
6+
namespace: default
7+
spec:
8+
manifestWorkTemplate:
9+
manifestConfigs:
10+
- resourceIdentifier:
11+
group: argoproj.io
12+
resource: applications
13+
namespace: argocd
14+
name: guestbook
15+
feedbackRules:
16+
- type: WellKnownStatus
17+
workload:
18+
manifests:
19+
- apiVersion: rbac.authorization.k8s.io/v1
20+
kind: ClusterRole
21+
metadata:
22+
name: open-cluster-management:klusterlet-work:my-role
23+
rules:
24+
- apiGroups:
25+
- argoproj.io
26+
resources:
27+
- '*'
28+
verbs:
29+
- get
30+
- list
31+
- watch
32+
- create
33+
- update
34+
- patch
35+
- delete
36+
- apiVersion: rbac.authorization.k8s.io/v1
37+
kind: ClusterRoleBinding
38+
metadata:
39+
name: open-cluster-management:klusterlet-work:my-binding
40+
roleRef:
41+
apiGroup: rbac.authorization.k8s.io
42+
kind: ClusterRole
43+
name: open-cluster-management:klusterlet-work:my-role
44+
subjects:
45+
- kind: ServiceAccount
46+
name: klusterlet-work-sa
47+
namespace: open-cluster-management-agent
48+
- apiVersion: argoproj.io/v1alpha1
49+
kind: Application
50+
metadata:
51+
name: guestbook
52+
namespace: argocd
53+
spec:
54+
destination:
55+
namespace: guestbook
56+
server: https://kubernetes.default.svc
57+
project: default
58+
source:
59+
path: guestbook
60+
repoURL: https://github.com/argoproj/argocd-example-apps.git
61+
targetRevision: HEAD
62+
syncPolicy:
63+
automated:
64+
prune: true
65+
selfHeal: true
66+
syncOptions:
67+
- CreateNamespace=true
68+
placementRefs:
69+
- name: demo-clusters
70+
EOF

create-placement.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
cat << EOF | kubectl apply --context kind-hub -f -
2+
apiVersion: cluster.open-cluster-management.io/v1beta1
3+
kind: Placement
4+
metadata:
5+
name: demo-clusters
6+
namespace: default
7+
spec:
8+
numberOfClusters: 2
9+
clusterSets:
10+
- default
11+
EOF

create-workload.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
apiVersion: argoproj.io/v1alpha1
2+
kind: Application
3+
metadata:
4+
name: guestbook
5+
namespace: argocd
6+
spec:
7+
project: default
8+
source:
9+
repoURL: https://github.com/argoproj/argocd-example-apps.git
10+
targetRevision: HEAD
11+
path: guestbook
12+
destination:
13+
server: https://kubernetes.default.svc
14+
namespace: guestbook

install-argocd.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
ARGOCD_VERSION="v2.7.6"
3+
MANAGED_CLUSTERS="cluster1 cluster2"
4+
5+
for mc in ${MANAGED_CLUSTERS}; do
6+
echo "Installing ArgoCD in cluster: ${mc}"
7+
curr_ctx="kind-${mc}"
8+
kubectl create ns argocd --context ${curr_ctx}
9+
kubectl apply -f https://raw.githubusercontent.com/argoproj/argo-cd/${ARGOCD_VERSION}/manifests/install.yaml -n argocd --context ${curr_ctx}
10+
echo "============================"
11+
done;
12+
13+
14+
15+

install-clusteradm.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
CLUSTERADM_CLIENT_VERSION=${1:-"v0.6.0"}
4+
TARGET_PATH=${2:-/usr/local/bin}
5+
6+
OS=$(uname -o | cut -f2 -d/ | tr '[:upper:]' '[:lower:]')
7+
ARCH=$(uname -m | sed s/aarch64/arm64/ | sed s/x86_64/amd64/)
8+
TAR_FILE=${TMPDIR:-"/tmp"}/clusteradm.tar.gz
9+
10+
wget https://github.com/open-cluster-management-io/clusteradm/releases/download/${CLUSTERADM_CLIENT_VERSION}/clusteradm_${OS}_${ARCH}.tar.gz -O ${TAR_FILE}
11+
if [ -f "${TAR_FILE}" ]; then
12+
tar zxf /tmp/clusteradm.tar.gz --directory ${TARGET_PATH} clusteradm
13+
fi
14+
rm -rf ${TAR_FILE}

uninstall-argocd.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
ARGOCD_VERSION="v2.7.6"
3+
MANAGED_CLUSTERS="cluster1 cluster2"
4+
5+
for mc in ${MANAGED_CLUSTERS}; do
6+
echo "Uninstalling ArgoCD from cluster: ${mc}"
7+
curr_ctx="kind-${mc}"
8+
kubectl delete -f https://raw.githubusercontent.com/argoproj/argo-cd/${ARGOCD_VERSION}/manifests/install.yaml -n argocd --context ${curr_ctx}
9+
kubectl delete ns argocd
10+
echo "============================"
11+
done;
12+
13+
14+
15+

0 commit comments

Comments
 (0)