# Beta - Installing Fleio in kubernetes using Fleio operator ```{warning} This is a beta release, and is not intended for production use. ``` ```{contents} :depth: 4 :backlinks: none ``` ## Important notes - This was only tested with MicroK8s cluster, so this documentation will contain instructions on how to install Fleio on a MicroK8s kubernetes cluster ## Hardware requirements Since in Kubernetes Fleio starts multiple pods for services, the hardware requirements will be slightly higher than {ref}`docker hardware requirements`. It is also recommended you run Fleio on a multi-node Kubernetes cluster. ## Preparing the environment ```{note} The following commands work on Ubuntu 24.04, if you plan to use other distribution, you will have to run commands specific to your distribution. ``` Install ``microk8s``, ``helm`` and ``kubectl``: ```shell sudo snap install microk8s --classic sudo snap install helm --classic sudo snap install kubectl --classic ``` The root CA certificate generated by MicroK8s does not include key usage extension needed by Fleio operator for authentication (click [here](https://github.com/canonical/microk8s/issues/4864) for more details). Execute the following commands to generate a certificate with key usage extension. ```shell mkdir cadir openssl genrsa -out cadir/ca.key 2048 openssl req -x509 -new -nodes -key cadir/ca.key -sha256 -days 360 -out cadir/ca.crt -addext "keyUsage=critical,digitalSignature,keyCertSign" sudo microk8s.refresh-certs cadir rm -Rf cadir sudo microk8s stop && sudo microk8s start microk8s status --wait-ready ``` Run the following commands to enable some MicroK8s extension needed by Fleio and update a kubectl config file: ```shell microk8s enable dashboard hostpath-storage registry ingress cert-manager microk8s status --wait-ready sudo usermod -a -G microk8s $USER ``` Re-login to apply group changes, then configure kubectl to connect to MicroK8s: ```shell mkdir ~/.kube microk8s config > ~/.kube/config chmod 600 ~/.kube/config ``` Test that ``kubectl`` works: ```shell kubectl get all ``` ## Deploying Fleio in Kubernetes using Fleio operator ### Install Fleio operator Fleio operator can be installed via helm. Add fleio helm repository: ```shell helm repo add fleio "https://fleio.com/helm" helm repo update fleio ``` Install Fleio operator: ```shell helm install fleio-operator fleio/fleio-operator ``` ### Create connections resources Fleio needs a redis server and a mariadb database. Fleio operator adds two custom resource definitions (``fleiodbconnection`` and ``fleioredisconnection``) to configure these. #### Create a **``fleiodbconnection``** and credentials secret Before proceeding you need to install a mariadb server and create a database for Fleio with ``utf8mb4`` character set and ``utf8mb4_unicode_ci`` collation. Create a ``kubenetes.io/basic-auth`` secret with mariadb credentials (replace ```` and ```` with your credentials): ```shell cat < fleio-mariadb-credentials.yaml apiVersion: v1 kind: Secret metadata: name: fleio-mariadb-credentials type: kubernetes.io/basic-auth stringData: username: "" password: "" EOT ``` Create a ``fleiodbconnection`` resource (replace ```` and ```` with your values): ```shell cat < fleio-mariadb-connection.yaml apiVersion: "k8s.fleio.com/v1" kind: FleioDbConnection metadata: name: fleio-db-connection spec: hostname: "" port: 3306 credentialsSecret: fleio-mariadb-credentials databaseName: "" EOT ``` Apply resources using ``kubectl``: ```shell kubectl apply -f fleio-mariadb-credentials.yaml kubectl apply -f fleio-mariadb-connection.yaml ``` #### Create a **``fleioredisconnection``** and credentials secret Before proceeding, you need to install a redis server. Create a ``kubenetes.io/basic-auth`` secret with redis credentials (replace ```` and ```` with your credentials, leave ```` empty if your redis server accepts only password): ```shell cat < fleio-redis-credentials.yaml apiVersion: v1 kind: Secret metadata: name: fleio-redis-credentials type: kubernetes.io/basic-auth stringData: username: "" password: "" EOT ``` Create a ``fleioredisconnection`` resource (replace ```` with your value): ```shell cat < fleio-redis-connection.yaml apiVersion: "k8s.fleio.com/v1" kind: FleioRedisConnection metadata: name: fleio-redis-connection spec: hostname: "" port: 6379 credentialsSecret: fleio-redis-credentials databaseId: "0" EOT ``` Apply resources using ``kubectl``: ```shell kubectl apply -f fleio-redis-credentials.yaml kubectl apply -f fleio-redis-connection.yaml ``` ### Create a **``fleiodeployment``** resource and admin credentials secret: Create a ``kubenetes.io/basic-auth`` secret with Fleio admin credentials (replace ```` and ```` with your credentials): ```shell cat < fleio-admin-credentials.yaml apiVersion: v1 kind: Secret metadata: name: fleio-admin-credentials type: kubernetes.io/basic-auth stringData: username: "" password: "" EOT ``` Create a ``fleiodeployment`` resource (replace ```` and ```` with your Fleio license and ```` with public IP or FQDN of your machine): ```shell cat < fleio-deployment.yaml apiVersion: "k8s.fleio.com/v1" kind: FleioDeployment metadata: name: test spec: license: uuid: "" key: "" databaseConnection: "fleio-mariadb-connection" redisConnection: "fleio-redis-connection" adminCredentialsSecret: "fleio-admin-credentials" domain: "" EOT ``` Apply resources using ``kubectl``: ```shell kubectl apply -f fleio-admin-credentials.yaml kubectl apply -f fleio-deployment.yaml ``` Once a ``fleiodeployment`` resource exists in the cluster the Fleio operator will deploy Fleio in cluster. After deployment finishes, Fleio should be available at the domain or IP you specified over HTTP. ## Deploying with a helper script ```{warning} This script is not intended to be used for production. ``` This script installs and configures Fleio, mariadb and redis in a Kubernetes cluster. Run the script using the following command: ```shell curl -s -o "deploy-fleio" "https://fleio.com/helm/deploy-fleio" && bash "deploy-fleio" ``` ## Further steps See [Kubernetes documentation](#kubernetes-documentation)