'Elastic Search with Skaffold
apiVersion: apps/v1
kind: Deployment
metadata:
name: eks-deploy
spec:
replicas: 1
selector:
matchLabels:
app: eks
template:
metadata:
labels:
app: eks
spec:
containers:
- name: elasticsearch
image: docker.elastic.co/elasticsearch/elasticsearch:7.11.1
---
apiVersion: v1
kind: Service
metadata:
name: eks-srv
spec:
selector:
app: eks
ports:
- name: eks-db
protocol: TCP
port: 9200
targetPort: 9200
I use this code for setting up Elastic Search for my project through skaffold. But when I try to connect to the elastic search running on port 9200 it gives me back an error that the connection has been refused.
const client: NewTypes = new Client({
node: 'http://localhost:9200'
})
interface Source {
foo: string
}
const request: estypes.IndexRequest<Source> = {
index: 'test',
body: {
foo: 'bar'
}
}
await client.index(request);
What am I doing wrong?
Solution 1:[1]
Elasticsearch needs a Persistent Volume to work.
Also, the configuration you wrote looks like its for a database like MongoDB or PostgresSQL. Elasticsearch is not a database. It's a tool for managing, scaling and analysing big data. So, its configuration would be way different from any database.
You should be installing Elastic Cloud on your system using the following command
kubectl create -f https://download.elastic.co/downloads/eck/2.0.0/crds.yaml
kubectl apply -f https://download.elastic.co/downloads/eck/2.0.0/operator.yaml
After you apply Elastic Cloud files to Kubernetes you can deploy a elastic cluster with the following configuration file.
apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
name: quickstart
spec:
version: 8.0.1
nodeSets:
- name: default
count: 1
config:
node.store.allow_mmap: false
I would recommend you also visit
Also, please go through Helm Charts documentation of how to setup Elasticsearch because it just takes one simple line to get Elastic search on your cluster. I am leaving this link for your reference if in case you have any doubts how to setup Elasticsearch with helm
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
