Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add a install script #400

Merged
merged 1 commit into from
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ Kubebb Core provides core implementations on Component Lifecycle Management.Our
- automatically upgrade component with subscription
- flexible and powerful manifest override mechanism


## Qucik Start

```shell
./hack/quick-install.sh
```

## Documentation

To learn more about KubeBB Core,[go to complete documentation](https://kubebb.github.io/website/).
Expand Down
104 changes: 104 additions & 0 deletions hack/quick-install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/bin/bash

echo "> input nodename: "
read nodename

echo "> input reponame(used in helm repo add): "
read reponame

if [[ ${#nodename} -eq 0 ]]; then
nodename="kubebb"
fi

if [[ ${#reponame} -eq 0 ]]; then
reponame="kubebb"
fi

nodeip=$(kubectl get node $nodename --no-headers -owide | awk '{print $6}')
echo -e "nodename: $nodename, nodeip: $nodeip\n"

if [[ ${#nodeip} -eq 0 ]]; then
echo -e "\033[31mUnable to find node ip. enter correct node name\033[0m"
exit 1
fi

echo "1. add repo as ${reponame}"

helm repo add $reponame https://kubebb.github.io/components 2>/dev/null
helm repo update $reponame 2>/dev/null

echo -e "\n2. create namespace u4a-system, kubebb-system"
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Namespace
metadata:
name: u4a-system
EOF

cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Namespace
metadata:
name: kubebb-system
EOF

echo -e "\n3. install kubebb-core in namesapce kubebb-system with name kubebb-core"

errmsg=$(helm -nkubebb-system install kubebb-core ${reponame}/kubebb-core --wait 2>&1 >/dev/null)
if [[ $? -ne 0 ]]; then
echo -e "\033[31m[KUBEBB-CORE-COMPNENT]: ${errmsg}\033[0m"
exit 1
else
echo -e "\033[32mkubebb-core-component installed successfully\033[0m"
fi

echo -e "\n4. install the cluster-component in namespace u4a-system with name cluster-component"

if [[ -d "cluster-component" ]]; then
rm -rf cluster-component
fi

errmsg=$(helm pull --untar=true ${reponame}/cluster-component 2>&1 >/dev/null)
if [[ $? -ne 0 ]]; then
echo -e "\033[31m[CLUSTER-COMPNENT]: ${errmsg}\033[0m"
exit 1
fi

echo "4.1 replace <replaced-ingress-node-name> in values.yaml"
sed -e "s/<replaced-ingress-node-name>/${nodename}/g" cluster-component/values.yaml >cluster-component/values-tmp.yaml

echo "4.2 intall cluster-component"
errmsg=$(helm -nu4a-system install cluster-component ${reponame}/cluster-component -f cluster-component/values-tmp.yaml --wait 2>&1 >/dev/null)

if [[ $? -ne 0 ]]; then
echo -e "\033[31m[CLUSTER-COMPNENT]: ${errmsg}\033[0m"
exit 1
else
echo -e "\033[32mcluster-component installed successfully\033[0m"
fi

echo -e "\n5. install the u4a-component in namespace u4a-system with name u4a-component"

if [[ -d "u4a-component" ]]; then
rm -rf u4a-component
fi

errmsg=$(helm pull --untar=true ${reponame}/u4a-component 2>&1 >/dev/null)
if [[ $? -ne 0 ]]; then
echo -e "\033[31m[U4A-COMPNENT]: ${errmsg}\033[0m"
exit 1
fi

echo "5.1 replace <replaced-ingress-nginx-ip> in values.yaml"
sed -e "s/<replaced-ingress-nginx-ip>/${nodeip}/g" u4a-component/values.yaml >u4a-component/values-tmp.yaml

echo "5.2 install u4a-compnent"
errmsg=$(helm -nu4a-system install u4a-component ${reponame}/u4a-component -f u4a-component/values-tmp.yaml --wait 2>&1 >/dev/null)
if [[ $? -ne 0 ]]; then
echo -e "\033[31m[U4A-COMPNENT]: ${errmsg}\033[0m"
exit 1
else
echo -e "\033[32mu4a-component installed successfully\033[0m"
fi

echo -e "\n\033[32mDone\033[0m"
Loading