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

docs(others): add infomaniac kubernetes cluster creation informations #7304

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
135 changes: 135 additions & 0 deletions deployment/scripts/cluster.install.test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
#!/bin/bash

# show help message
display_help() {
echo "Install ocelot.social and/or optional infrastructure pods"
echo "Usage: script.sh [options]"
echo ""
echo "Options:"
echo " -h, --help Displays this help message"
echo " -c, --cert-manager Option -c: Certificate manager"
echo " -n, --nginx Option -n: nginx"
echo " -o, --ocelot Option -o: ocelot.social"
}

# standard message if no option has been specified
display_error() {
echo "Error: An option is required."
echo "Use -h or --help for more information."
}

# main function
main() {
certmanager_selected=false
nginx_selected=false
ocelot_selected=false

# checking the options with while
while [[ $# -gt 0 ]]; do
case $1 in
-h | --help)
display_help
exit 0
;;
-n | --nginx)
nginx_selected=true
;;
-c | --cert-manager)
certmanager_selected=true
;;
-o | --ocelot)
ocelot_selected=true
;;
*)
echo "Invalid option: $1" >&2
display_help
exit 1
;;
esac
shift
done

# Überprüfen, ob mindestens eine Option angegeben wurde
if [[ $certmanager_selected == false && $nginx_selected == false && $ocelot_selected == false ]]; then
display_error
exit 1
fi


# base setup
SCRIPT_PATH=$(realpath $0)
SCRIPT_DIR=$(dirname $SCRIPT_PATH)

# check CONFIGURATION
if [ -z ${CONFIGURATION} ]; then
echo "You must provide a `CONFIGURATION` via environment variable"
exit 1
fi
echo "Using CONFIGURATION=${CONFIGURATION}"

# configuration
KUBECONFIG=${KUBECONFIG:-${SCRIPT_DIR}/../configurations/${CONFIGURATION}/kubeconfig.yaml}
VALUES=${SCRIPT_DIR}/../configurations/${CONFIGURATION}/kubernetes/values.yaml
DOCKERHUB_OCELOT_TAG=${DOCKERHUB_OCELOT_TAG:-"latest"}


if $nginx_selected; then
echo "Install nginx …"

## install Ingress-Nginx
helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
helm repo update
helm install \
ingress-nginx ingress-nginx/ingress-nginx \
--kubeconfig=${KUBECONFIG} \
-f ${SCRIPT_DIR}/../src/kubernetes/nginx.values.yaml

echo "nginx SUCCESSfully installed!"
fi

# Installationslogik entsprechend der Reihenfolge der Optionen
if $certmanager_selected; then
echo "Install cert-manager …"

## install Cert-Manager
helm repo add jetstack https://charts.jetstack.io
helm repo update
helm install \
cert-manager jetstack/cert-manager \
--kubeconfig=${KUBECONFIG} \
--namespace cert-manager \
--create-namespace \
--version v1.13.2 \
--set installCRDs=true

echo "cert-manager SUCCESSfully installed!"
fi

if $ocelot_selected; then
echo "Install ocelot.social …"

## install ocelot.social with helm
helm install \
ocelot \
--kubeconfig=${KUBECONFIG} \
--values ${VALUES} \
--set appVersion="${DOCKERHUB_OCELOT_TAG}" \
${SCRIPT_DIR}/../src/kubernetes/ \
--timeout 10m

## set Neo4j database indexes, constrains, and initial admin account plus run migrate up
kubectl --kubeconfig=${KUBECONFIG} \
-n default \
exec -it \
$(kubectl --kubeconfig=${KUBECONFIG} -n default get pods | grep ocelot-backend | awk '{ print $1 }') -- \
/bin/sh -c "yarn prod:migrate init && yarn prod:migrate up"
# /bin/sh -c "node --experimental-repl-await build/src/db/clean.js && node --experimental-repl-await build/src/db/seed.js"

echo "ocelot.social SUCCESSfully installed!"
echo "!!! You must install a firewall or similar !!! (for DigitalOcean see: deployment/src/kubernetes/README.md)"
fi
}


# call main function
main "$@"
4 changes: 4 additions & 0 deletions deployment/src/kubernetes/DigitalOcean.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ DigitalOcean has a website about Kubernetes Dashboard and alternatives:

There are the following two ways to set up the DNS.

### Set a Static IP

In the menu on the left side under `Networking` on tab `Reserved IP` you can reserve a static IP for your cluster.

### Manage DNS With A Different Domain Provider

If you have registered your domain or subdomain with another domain provider, add an `A` record there with one of the IP addresses from one of the cluster droplets in the DNS.
Expand Down
86 changes: 86 additions & 0 deletions deployment/src/kubernetes/infomaniac.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# `infomaniac`

If you want to set up a [Kubernetes](https://kubernetes.io) cluster on [infomaniac](https://www.infomaniak.com), follow this guide.

## Create Account

Create an account with `infomaniac`.

## Create a Kubernetes Cluster in the Jelastic Cloud Area

XXX On the right top you find the button `Create`. Click on it and choose `Kubernetes - Create Kubernetes Cluster`.

- select `Remote API` (to be installed to become able to manage the cluster from your local terminal)
- select `Kubernetes Dashboard`
- XXX choose your datacenter region
- name your node pool: e.g. `pool-<your-network-name>`
- `2 Basic nodes` with `2.5 GB RAM (total of 4 GB)`, `2 shared CPUs`, and `80 GB Disk` each is optimal for the beginning
- set your cluster name: e.g. `cluster-<your-network-name>`
- select your project
- no tags necessary

Save all the information you get at the and of the process.

## Getting Started

After your cluster is set up you need access to it in your local terminal via `kubectl`.
Please install the following management tools:

- [kubectl v1.28.x](https://kubernetes.io/docs/tasks/tools/)

Install the tools as described on the tab or see the links here.

### Set your Kubernetes Cluster to the Current One

If you have received the credentials from `infomaniak` via the modal dialog or e-mail after provisioning the cluster, use them to access your Kubernetes cluster.

#### In Terminal

How this works is described on [Virtuozzo PaaS Docs](https://www.virtuozzo.com/application-platform-docs/kubernetes-cluster-access/#kubectl-client).

```bash
kubectl config set-cluster jelastic --server={api-endpoint} && \
kubectl config set-context jelastic --cluster=jelastic && \
kubectl config set-credentials user --token={token} && \
kubectl config set-context jelastic --user=user && \
kubectl config use-context jelastic
```

> Replace the `{api-endpoint}` and `{token}` placeholders with the Remote API URL and access token respectively.

#### By a `kubeconfig` File

Create a kubeconfig file by replacing `{api-endpoint}` and `{token}`.
Then place it in your clusters configuration folder.

```yaml
apiVersion: v1
clusters:
- cluster:
server: {api-endpoint}
name: jelastic
contexts:
- context:
cluster: jelastic
user: user
name: jelastic
current-context: jelastic
kind: Config
preferences: {}
users:
- name: user
user:
token: {token}
```

How this files work is described here: <https://kubernetes.io/docs/tasks/access-application-cluster/configure-access-multiple-clusters/>

## Deploy

Yeah, you're done here. Back to [Deployment with Helm for Kubernetes](./README.md).

## Backups On `infomaniak`

You can and should do [backups](./Backup.md) with Kubernetes for sure.

Additional to backup and copying the Neo4j database dump and the backend images you may do a volume snapshot on `infomaniak` at the moment you have the database in sleep mode.
Loading