https://github.com/kaitoy/elasticsearch-db-operator
A Kubernetes Operator for Elasticsearch database
https://github.com/kaitoy/elasticsearch-db-operator
elasticsearch golang kubebuilder kubernetes kubernetes-operator
Last synced: 2 months ago
JSON representation
A Kubernetes Operator for Elasticsearch database
- Host: GitHub
- URL: https://github.com/kaitoy/elasticsearch-db-operator
- Owner: kaitoy
- License: apache-2.0
- Created: 2019-02-11T04:37:30.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2019-03-19T14:48:17.000Z (over 6 years ago)
- Last Synced: 2025-01-29T09:47:55.520Z (11 months ago)
- Topics: elasticsearch, golang, kubebuilder, kubernetes, kubernetes-operator
- Language: Go
- Size: 30.1 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Elasticsearch DB Operator
=========================
[](https://goreportcard.com/report/kaitoy/elasticsearch-db-operator)
Elasticsearch DB Operator is a [Kubernetes operator](https://github.com/operator-framework/awesome-operators) built with [Kubebuilder](https://github.com/kubernetes-sigs/kubebuilder), that operates [Elasticsearch](https://www.elastic.co/products/elasticsearch) database (i.e. indices and settings).
Deploy to Kubernetes cluster
-----------------------------------
You need [kubectl](https://kubernetes.io/docs/reference/kubectl/overview/) to deploy Elasticsearch DB Operator with it.
1. `git clone https://github.com/kaitoy/elasticsearch-db-operator.git`
2. `cd elasticsearch-db-operator`
3. `kubectl apply -f config/crds/elasticsearchdb_v1beta1_index.yaml`
4. `kubectl apply -f config/crds/elasticsearchdb_v1beta1_template.yaml`
5. `kubectl apply -f elasticsearch-db-operator.yaml`
Usage
-----
### Operate an index
1. Write an index manifest.
e.g.)
```yaml
apiVersion: elasticsearchdb.kaitoy.github.com/v1beta1
kind: Index
metadata:
labels:
controller-tools.k8s.io: "1.0"
name: index-sample
url:
elasticsearchEndpoint: http://elasticsearch:9200
index: user
spec:
settings:
index:
number_of_shards: 5
number_of_replicas: 1
mappings:
_doc:
_source:
enabled: true
properties:
age:
type: integer
name:
properties:
first:
type: keyword
boost: 2.5
last:
type: keyword
```
2. Apply the manifest to create the index.
3. Delete the manifest to delete the index.
### Operate a template
1. Write a template manifest.
e.g.)
```yaml
apiVersion: elasticsearchdb.kaitoy.github.com/v1beta1
kind: Template
metadata:
labels:
controller-tools.k8s.io: "1.0"
name: template-sample
url:
elasticsearchEndpoint: http://elasticsearch:9200
template: user_template
spec:
index_patterns:
- user-*
settings:
index:
number_of_shards: 5
number_of_replicas: 1
order: 10
version: 3
mappings:
_doc:
_source:
enabled: true
properties:
age:
type: integer
name:
properties:
first:
type: keyword
boost: 2.5
last:
type: keyword
```
2. Apply the manifest to create the template.
3. Delete the manifest to delete the template.
Docker Image
------------
[](https://microbadger.com/images/kaitoy/elasticsearch-db-operator "Get your own version badge on microbadger.com")
[](https://microbadger.com/images/kaitoy/elasticsearch-db-operator "Get your own image badge on microbadger.com")
Development
-----------
You need [Docker](https://www.docker.com/) to build Elasticsearch DB Operator container image, and [kustomize](https://github.com/kubernetes-sigs/kustomize) to generate a Kubernetes manifest file.
1. Build container image
1. `git clone https://github.com/kaitoy/elasticsearch-db-operator.git`
2. `cd elasticsearch-db-operator`
3. `docker build .`
2. Generate Kubernetes manifest file
1. `kustomize build config/default > elasticsearch-db-operator.yaml`