Skip to content

Commit

Permalink
Merge pull request #34 from yrodiere/opensearch
Browse files Browse the repository at this point in the history
Backend change
  • Loading branch information
yrodiere authored Nov 3, 2023
2 parents 186b7ee + e4dcd09 commit 493b386
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 47 deletions.
10 changes: 5 additions & 5 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ podman pod create -p 8080:8080 -p 9000:9000 -p 9200:9200 --name search.quarkus.i
podman container run -d --name elasticearch --pod search.quarkus.io \
-e "discovery.type=single-node" -e "xpack.security.enabled=false" \
-e "ES_JAVA_OPTS=-Xms1g -Xmx1g" -e "cluster.routing.allocation.disk.threshold_enabled=false" \
elastic/elasticsearch:8.10.2
docker.io/opensearchproject/opensearch:2.11.0
# Then the app; this will fetch the actual data on startup (might take a while):
podman container run -it --rm --pod search.quarkus.io search-quarkus-io:999-SNAPSHOT
# OR, if you already have a local clone of quarkus.io:
Expand Down Expand Up @@ -106,11 +106,11 @@ you will need to set up a few things manually:
`search-quarkus-io-secret`::
Secret environment variables for the application.
Put in there whatever secret configuration you need for your specific cluster.
`elasticsearch-config`::
Environment variables for the Elasticsearch instances.
`search-backend-config`::
Environment variables for the OpenSearch instances.
Put in there whatever configuration you need for your specific cluster.
`elasticsearch-secret`::
Secret environment variables for the Elasticsearch instances.
`search-backend-secret`::
Secret environment variables for the OpenSearch instances.
Put in there whatever secret configuration you need for your specific cluster.

[[license]]
Expand Down
65 changes: 31 additions & 34 deletions src/main/kubernetes/openshift.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apiVersion: v1
kind: Service
metadata:
name: elasticsearch
name: search-backend
labels:
app: elasticsearch
app.kubernetes.io/name: elasticsearch
app: search-backend
app.kubernetes.io/name: search-backend
app.kubernetes.io/component: datastore
app.kubernetes.io/part-of: search-quarkus-io
app.kubernetes.io/managed-by: quarkus
Expand All @@ -17,7 +17,7 @@ spec:
protocol: TCP
port: 9300
selector:
app.kubernetes.io/name: elasticsearch
app.kubernetes.io/name: search-backend
type: ClusterIP
# Using a StatefulSet, each pod has its own immutable address,
# so we don't need the service to have an IP.
Expand All @@ -26,32 +26,32 @@ spec:
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: elasticsearch
name: search-backend
labels:
app: elasticsearch
app.kubernetes.io/name: elasticsearch
app: search-backend
app.kubernetes.io/name: search-backend
app.kubernetes.io/component: datastore
app.kubernetes.io/part-of: search-quarkus-io
app.kubernetes.io/managed-by: quarkus
# See https://www.hafifbilgiler.com/hafif-bilgiler/elasticsearch-installation-on-openshift/
spec:
serviceName: elasticsearch
serviceName: search-backend
replicas: 3
selector:
matchLabels:
app.kubernetes.io/name: elasticsearch
app.kubernetes.io/name: search-backend
template:
metadata:
labels:
app: elasticsearch
app.kubernetes.io/name: elasticsearch
app: search-backend
app.kubernetes.io/name: search-backend
app.kubernetes.io/component: datastore
app.kubernetes.io/part-of: search-quarkus-io
app.kubernetes.io/managed-by: quarkus
spec:
containers:
- name: elasticsearch
image: elasticsearch:8.10.2
- name: search-backend
image: opensearch:2.11.0
imagePullPolicy: Always
resources:
limits:
Expand All @@ -75,40 +75,37 @@ spec:
protocol: TCP
volumeMounts:
- name: data
mountPath: /usr/share/elasticsearch/data
mountPath: /usr/share/opensearch/data
env:
- name: cluster.name
value: search-quarkus-io
- name: node.name
valueFrom:
fieldRef:
fieldPath: metadata.name
# https://www.elastic.co/guide/en/elasticsearch/reference/current/important-settings.html#discovery-settings
# https://opensearch.org/docs/latest/install-and-configure/install-opensearch/docker/#sample-docker-composeyml
# Rely on OpenShift's internal DNS to address the other hosts
- name: discovery.seed_hosts
value: "elasticsearch-0.elasticsearch,elasticsearch-1.elasticsearch,elasticsearch-2.elasticsearch"
- name: cluster.initial_master_nodes
value: "elasticsearch-0,elasticsearch-1,elasticsearch-2"
value: "search-backend-0.search-backend,search-backend-1.search-backend,search-backend-2.search-backend"
- name: cluster.initial_cluster_manager_nodes
value: "search-backend-0,search-backend-1,search-backend-2"
# Not exposed to the internet, no sensitive data
# => We don't bother with HTTPS and pesky self-signed certificates
- name: xpack.security.enabled
value: "false"
- name: plugins.security.disabled
value: "true"
- name: bootstrap.memory_lock
value: "false"
# https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#_configure_and_start_the_cluster
- name: ES_PORT
value: 127.0.0.1:9200
value: "true"
envFrom:
- configMapRef:
name: elasticsearch-config
name: search-backend-config
- secretRef:
name: elasticsearch-secrets
name: search-backend-secrets
volumeClaimTemplates:
- metadata:
name: data
labels:
app: elasticsearch
app.kubernetes.io/name: elasticsearch
app: search-backend
app.kubernetes.io/name: search-backend
app.kubernetes.io/component: datastore
app.kubernetes.io/part-of: search-quarkus-io
app.kubernetes.io/managed-by: quarkus
Expand All @@ -124,23 +121,23 @@ spec:
imageChangeParams:
automatic: true
containerNames:
- elasticsearch
- search-backend
from:
kind: ImageStreamTag
name: elasticsearch:8.10.2
name: opensearch:2.11.0
---
apiVersion: "v1"
kind: "ImageStream"
metadata:
name: elasticsearch
name: opensearch
labels:
app.kubernetes.io/name: elasticsearch
app.kubernetes.io/name: search-backend
app.kubernetes.io/component: datastore
app.kubernetes.io/part-of: search-quarkus-io
app.kubernetes.io/managed-by: quarkus
spec:
tags:
- name: 8.10.2
- name: 2.11.0
from:
kind: DockerImage
name: docker.elastic.co/elasticsearch/elasticsearch:8.10.2
name: docker.io/opensearchproject/opensearch:2.11.0
16 changes: 8 additions & 8 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ quarkus.http.header."Strict-Transport-Security".value=max-age=31536000; includeS
quarkus.datasource.jdbc.url=jdbc:h2:mem:searchquarkusio
quarkus.hibernate-orm.database.generation=drop-and-create
## Hibernate Search
quarkus.hibernate-search-orm.elasticsearch.version=8.10
quarkus.elasticsearch.devservices.image-name=docker.io/elastic/elasticsearch:8.10.2
## We need to apply a custom Elasticsearch mapping to exclude very large fields from the _source
quarkus.hibernate-search-orm.elasticsearch.schema-management.mapping-file=elasticsearch/mapping-template.json
## We don't expect Elasticsearch to be reachable when the application starts
quarkus.hibernate-search-orm.elasticsearch.version=opensearch:2.11
quarkus.elasticsearch.devservices.image-name=docker.io/opensearchproject/opensearch:2.11.0
## We need to apply a custom OpenSearch mapping to exclude very large fields from the _source
quarkus.hibernate-search-orm.elasticsearch.schema-management.mapping-file=indexes/mapping-template.json
## We don't expect OpenSearch to be reachable when the application starts
quarkus.hibernate-search-orm.elasticsearch.version-check.enabled=false
## ... and the application automatically creates indexes upon first indexing anyway.
quarkus.hibernate-search-orm.schema-management.strategy=none
Expand Down Expand Up @@ -68,9 +68,9 @@ quarkus.swagger-ui.title=Quarkus Search API
# Deployment to OpenShift
quarkus.container-image.builder=openshift
quarkus.openshift.part-of=search-quarkus-io
# See src/main/kubernetes/openshift.yml for the Elasticsearch StatefulSet definition
# Rely on OpenShift's internal DNS to resolve the IP to Elasticsearch nodes
quarkus.openshift.env.vars.quarkus-hibernate-search-orm-elasticsearch-hosts=elasticsearch-0.elasticsearch:9200,elasticsearch-1.elasticsearch:9200,elasticsearch-2.elasticsearch:9200
# See src/main/kubernetes/openshift.yml for the search-backend StatefulSet definition
# Rely on OpenShift's internal DNS to resolve the IP to search-backend nodes
quarkus.openshift.env.vars.quarkus-hibernate-search-orm-elasticsearch-hosts=search-backend-0.search-backend:9200,search-backend-1.search-backend:9200,search-backend-2.search-backend:9200
# Images built on OpenShift have their HOME environment variable set to '/' by default,
# which obviously won't work well due to filesystem permissions.
# JGit in particular doesn't like it: https://bugs.eclipse.org/bugs/show_bug.cgi?id=560555
Expand Down

0 comments on commit 493b386

Please sign in to comment.