From 60b6a38082631548839325df3fe609bd46304d58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Wed, 11 Oct 2023 10:10:44 +0200 Subject: [PATCH] Include Elasticsearch service in the OpenShift deployment Taking advantage of https://quarkus.io/guides/deploying-to-kubernetes#using-existing-resources --- src/main/kubernetes/openshift.yml | 70 +++++++++++++++++++++++ src/main/resources/application.properties | 8 +++ 2 files changed, 78 insertions(+) create mode 100644 src/main/kubernetes/openshift.yml diff --git a/src/main/kubernetes/openshift.yml b/src/main/kubernetes/openshift.yml new file mode 100644 index 00000000..e347519c --- /dev/null +++ b/src/main/kubernetes/openshift.yml @@ -0,0 +1,70 @@ +apiVersion: v1 +kind: Service +metadata: + name: elasticsearch + labels: + app: elasticsearch + app.kubernetes.io/name: elasticsearch + app.kubernetes.io/component: datastore + app.kubernetes.io/part-of: search-quarkus-io + app.kubernetes.io/managed-by: quarkus +spec: + ports: + - name: http + port: 80 + protocol: TCP + targetPort: 9200 + selector: + app.kubernetes.io/name: elasticsearch + type: ClusterIP +--- +apiVersion: apps.openshift.io/v1 +kind: DeploymentConfig +metadata: + name: elasticsearch + labels: + app: elasticsearch + app.kubernetes.io/name: elasticsearch + app.kubernetes.io/component: datastore + app.kubernetes.io/part-of: search-quarkus-io + app.kubernetes.io/managed-by: quarkus +spec: + replicas: 3 + selector: + app.kubernetes.io/name: elasticsearch + template: + metadata: + labels: + app: elasticsearch + app.kubernetes.io/name: elasticsearch + app.kubernetes.io/component: datastore + app.kubernetes.io/part-of: search-quarkus-io + app.kubernetes.io/managed-by: quarkus + spec: + containers: + - name: elasticsearch + image: docker.elastic.co/elasticsearch/elasticsearch:8.10.2 + imagePullPolicy: Always + resources: + limits: + cpu: 1000m + memory: 1Gi + requests: + cpu: 250m + memory: 500Mi + env: + - name: cluster.name + value: search-quarkus-io + # 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 + envFrom: + - configMapRef: + name: elasticsearch-config + - secretRef: + name: elasticsearch-secrets + ports: + - containerPort: 9200 + name: http + protocol: TCP diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 0374771e..726774b0 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -51,6 +51,14 @@ quarkus.swagger-ui.always-include=true quarkus.swagger-ui.title=Quarkus Search API # Production +## This should match the Elasticsearch service defined in src/main/kubernetes +## We assume the cluster DNS will resolve the service name to the service IP automatically +%prod.quarkus.hibernate-search-orm.elasticsearch.hosts=elasticsearch:80 +%prod.quarkus.hibernate-search-orm.elasticsearch.protocol=http +## We don't expect Elasticsearch to be reachable when the application starts +%prod.quarkus.hibernate-search-orm.elasticsearch.version-check.enabled=false +## ... and the application automatically creates indexes upon first indexing anyway. +%prod.quarkus.hibernate-search-orm.schema-management.strategy=none # Deployment to OpenShift %prod.quarkus.openshift.labels."app"=search.quarkus.io