https://github.com/appbaseio/reactivesearch-api-k8s
https://github.com/appbaseio/reactivesearch-api-k8s
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/appbaseio/reactivesearch-api-k8s
- Owner: appbaseio
- Created: 2019-11-26T08:34:26.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-05-12T10:41:26.000Z (about 3 years ago)
- Last Synced: 2025-06-19T03:06:41.132Z (about 1 year ago)
- Size: 52.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
README
# K8S setup for Appbase.io + ElasticSearch
[Appbase.io](https://appbase.io) acts as an API gateway for ElasticSearch and augments the search experience by offering:
- Out-of-the-box search and click analytics,
- Fine-grained security controls but without any restrictions (Apache 2.0 licensed),
- A superior development experience: Import data via GUI, build and test search relevancy visually with no code, set query rules and advanced query suggestions.
This example demonstrates how you can deploy ElasticSearch kubernetes operator, i.e. [Elastic Cloud on Kubernetes (ECK)](https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-overview.html) with [Appbase.io](https://appbase.io/) on any kubernetes cluster.
## Quick Start
> Note: Steps described here assumes a [kubernetes](https://kubernetes.io/docs/tasks/tools/install-kubectl/) installation on the system. This will allow you to execute `kubectl` commands.
- **Step 1 -** Create kubernetes cluster with your favourite provider. Here are some of the well known Kubernetes Cluster providers.
- [Google Cloud](https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-cluster)
- [AWS](https://aws.amazon.com/kubernetes/)
- [Azure](https://azure.microsoft.com/en-in/services/kubernetes-service/)
- [Digital Ocean](https://www.digitalocean.com/products/kubernetes/)
_Here is an example on how you can create a cluster on Google Cloud._
> _Note: We assume that you have `gcloud` sdk installed on your machine, if not you can install from [here](https://cloud.google.com/sdk/install). Also you have a project on [Google Cloud](https://console.cloud.google.com/) with [Kubernetes Engine](https://console.cloud.google.com/apis/library/container.googleapis.com?q=kubernetes%20engine&_ga=2.12989943.-1532196267.1571335381) enabled_
_1. Login and Initialized Google Cloud_
```bash
gcloud init
```
_2. Create Cluster_
```bash
gcloud container clusters create YOUR_CLUSTER_NAME --num-nodes 1 --machine-type e2-standard-2 --zone us-east1-b --node-locations us-east1-b --cluster-version latest --network default --create-subnetwork range=/19 --enable-ip-alias --no-enable-autoupgrade --project YOUR_PROJECT
```
_For more configuration options, you can go through `glcoud container cluster create` command [docs](https://cloud.google.com/sdk/gcloud/reference/container/clusters/create). Also in the above command, you can choose a different zone, machine size, number of nodes, etc based on your requirements._
_Once the cluster is created you will get cluster IP + status in output._

> _Note: For GKE clusters you will need to have cluster admin role added. Following is the command: `kubectl create clusterrolebinding cluster-admin-binding --clusterrole cluster-admin`_
- **Step 2 -** Get custom resources for ECK k8s operator
```bash
kubectl apply -f https://download.elastic.co/downloads/eck/1.1.2/all-in-one.yaml
```

- **Step 3 -** Deploy ElasticSearch
Here is a basic Kubernetes configuration which will allow you to quickly deploy a single node ElasticSearch cluster, with 4gb RAM, 2 core CPU, and 5GB storage.
```bash
cat < Note: For more configuration options you can check [Elastic Cloud on Kubernetes docs](https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-overview.html)
- **Step 4 -** Monitor cluster health & creation process
```bash
kubectl get elasticsearch
```

> **Note:** Wait until health shows up as `green`. It can take upto 3-4 min.
- **Step 5 -** Create Appbase.io instance. Appbase.io instance will enable you to access Appbase.io Dashboard. While following instance creation process, you will get an `APPBASE_ID` , which will help you successfully deploy appbase.io on the cluster.
Follow the steps listed below to successfully create an appbase.io instance.
- Go to [Appbase.io Dashboard](https://dash.appbase.io/install)

- Enter your email address
- You will receive an OTP on an entered email address. Enter OTP to verify the email address.
- You will receive an email with APPBASE_ID which can be used with Appbase.io configuration.
- **Step 6 -** Deploy Appbase.io
```bash
kubectl apply -f https://raw.githubusercontent.com/appbaseio/arc-k8s/master/appbase.yaml
```

- **Step 7 -** Get Environment Variables. By now all the resources are deployed but Appbase.io service will need the following environment variables to start successfully.
- `APPBASE_ID`
- `ES_CLUSTER_URL`
- `USERNAME`
- `PASSWORD`
We have already obtained APPBASE_ID , in step 5. Now we need ElasticSearch cluster URL, i.e. `ES_CLUSTER_URL`. Since we are using Kubernetes orchestration, we can connect to ElasticSearch using its service name and port number. But [ECK](https://www.elastic.co/guide/en/cloud-on-k8s/current/k8s-quickstart.html) comes with [xpack](http://elastic.co/guide/en/elasticsearch/reference/current/security-settings.html) security which has basic auth enabled. So first let's get the user name password to successfully connect with ElasticSearch. Username here defaults to elastic , so we only need a way to get the password, which is stored in the secrets of Kubernetes.
Here is the command to get the Password for ElasticSearch
```bash
kubectl get secret elasticsearch-es-elastic-user -o=jsonpath='{.data.elastic}' | base64 --decode
```

Once we have password our `ES_CLUSTER_URL` looks like
```bash
http://elastic:jwg7k9fc9l89trb7l98jmhf2@elasticsearch-es-http:9200/
```
Also, default `USERNAME` and `PASSWORD` are set to `admin:admin` you can change them before deploying for production as these credentials will act as master credentials to access Appbase Dashboard.
- **Step 8 -** Configure fluent bit. Update the `ELASTICSEARCH_PASSWORD` password obtained in step 7 and execute the following command
```bash
cat < Note: if you do not update the host, then also you will be able to access the appbase URL using Load Balancer IP.
You can update the [TLS](https://en.wikipedia.org/wiki/Transport_Layer_Security) certificate, Key and Root CA values in the following command and execute it so that the correct certificate is attached to your domain. Make sure that the values of certificates and keys are encoded in base64.
```bash
cat <
- Enter appbase URL, i.e. Cluster IP obtained in step 8 or domain configured on step 10.
- Enter master credentials, i.e. username and password configured on step 7.