From c14e3675f7cb59d81b11c3e48f77be7e289cffaa Mon Sep 17 00:00:00 2001 From: Bob Ong <2261238+welbon@users.noreply.github.com> Date: Mon, 9 Dec 2024 19:33:41 +0800 Subject: [PATCH] [digital ocean] Separate elasticsearch related deployment configuration into different files --- kube/elasticsearch/elasticsearch-config.yaml | 16 +++++ .../elasticsearch-deployment.yaml | 59 +------------------ .../elasticsearch-pv-snapshot.yaml | 21 +++++++ kube/elasticsearch/elasticsearch-service.yaml | 11 ++++ .../elasticsearch-storage-snapshot.yaml | 28 +++++++++ kube/elasticsearch/elasticsearch-storage.yaml | 26 ++++++++ 6 files changed, 103 insertions(+), 58 deletions(-) create mode 100644 kube/elasticsearch/elasticsearch-config.yaml rename kube/{base-components => elasticsearch}/elasticsearch-deployment.yaml (72%) create mode 100644 kube/elasticsearch/elasticsearch-pv-snapshot.yaml create mode 100644 kube/elasticsearch/elasticsearch-service.yaml create mode 100644 kube/elasticsearch/elasticsearch-storage-snapshot.yaml create mode 100644 kube/elasticsearch/elasticsearch-storage.yaml diff --git a/kube/elasticsearch/elasticsearch-config.yaml b/kube/elasticsearch/elasticsearch-config.yaml new file mode 100644 index 0000000..012c720 --- /dev/null +++ b/kube/elasticsearch/elasticsearch-config.yaml @@ -0,0 +1,16 @@ +# Elasticsearch Configuration +apiVersion: v1 +kind: ConfigMap +metadata: + name: elasticsearch-config +data: + elasticsearch.yml: | + xpack.security.enabled: true + xpack.license.self_generated.type: basic + network.host: 0.0.0.0 + path.repo: ["/data/es_snapshot_repository"] + s3.client.default.endpoint: "s3.ap-northeast-1.amazonaws.com" + s3.client.default.protocol: https + s3.client.default.read_timeout: 50s + s3.client.default.max_retries: 3 + s3.client.default.use_throttle_retries: true \ No newline at end of file diff --git a/kube/base-components/elasticsearch-deployment.yaml b/kube/elasticsearch/elasticsearch-deployment.yaml similarity index 72% rename from kube/base-components/elasticsearch-deployment.yaml rename to kube/elasticsearch/elasticsearch-deployment.yaml index b4bb176..6b49d43 100644 --- a/kube/base-components/elasticsearch-deployment.yaml +++ b/kube/elasticsearch/elasticsearch-deployment.yaml @@ -90,61 +90,4 @@ spec: configMap: name: elasticsearch-config # - name: s3-mount-point -# emptyDir: {} - ---- -# Elasticsearch Configuration -apiVersion: v1 -kind: ConfigMap -metadata: - name: elasticsearch-config -data: - elasticsearch.yml: | - xpack.security.enabled: true - xpack.license.self_generated.type: basic - network.host: 0.0.0.0 - path.repo: ["/data/es_snapshot_repository"] - s3.client.default.endpoint: "s3.ap-northeast-1.amazonaws.com" - s3.client.default.protocol: https - s3.client.default.read_timeout: 50s - s3.client.default.max_retries: 3 - s3.client.default.use_throttle_retries: true ---- -# Elasticsearch Persistent Volume Claim -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: es-pvc -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 500Gi - storageClassName: do-block-storage-retain - ---- -# Elasticsearch Snapshot Repository Persistent Volume Claim -apiVersion: v1 -kind: PersistentVolumeClaim -metadata: - name: es-backup-pvc -spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 500Gi - storageClassName: do-block-storage-retain - ---- -# Elasticsearch Service -apiVersion: v1 -kind: Service -metadata: - name: elasticsearch -spec: - ports: - - port: 9200 - selector: - app: elasticsearch +# emptyDir: {} \ No newline at end of file diff --git a/kube/elasticsearch/elasticsearch-pv-snapshot.yaml b/kube/elasticsearch/elasticsearch-pv-snapshot.yaml new file mode 100644 index 0000000..92a81f3 --- /dev/null +++ b/kube/elasticsearch/elasticsearch-pv-snapshot.yaml @@ -0,0 +1,21 @@ +# The PV of ElasticSearch is created with the following configuration + +# VolumeSnapshotClass +apiVersion: snapshot.storage.k8s.io/v1 +kind: VolumeSnapshotClass +metadata: + name: do-snapshot-class +driver: dobs.csi.digitalocean.com +deletionPolicy: Retain + +--- + +# VolumeSnapshot +apiVersion: snapshot.storage.k8s.io/v1 +kind: VolumeSnapshot +metadata: + name: es-pv-snapshot +spec: + volumeSnapshotClassName: do-snapshot-class + source: + persistentVolumeClaimName: es-pvc \ No newline at end of file diff --git a/kube/elasticsearch/elasticsearch-service.yaml b/kube/elasticsearch/elasticsearch-service.yaml new file mode 100644 index 0000000..263c7da --- /dev/null +++ b/kube/elasticsearch/elasticsearch-service.yaml @@ -0,0 +1,11 @@ +--- +# Elasticsearch Service +apiVersion: v1 +kind: Service +metadata: + name: elasticsearch +spec: + ports: + - port: 9200 + selector: + app: elasticsearch diff --git a/kube/elasticsearch/elasticsearch-storage-snapshot.yaml b/kube/elasticsearch/elasticsearch-storage-snapshot.yaml new file mode 100644 index 0000000..bd189fa --- /dev/null +++ b/kube/elasticsearch/elasticsearch-storage-snapshot.yaml @@ -0,0 +1,28 @@ +# elasticsearch-snapshot-pv.yaml +apiVersion: v1 +kind: PersistentVolume +metadata: + name: es-snapshot-pv +spec: + capacity: + storage: 1Ti + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Retain + storageClassName: do-block-storage-retain + hostPath: + path: /data/elasticsearch-snapshots + +--- +# elasticsearch-snapshot-pvc.yaml +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: es-snapshot-pvc +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Ti + storageClassName: do-block-storage-retain \ No newline at end of file diff --git a/kube/elasticsearch/elasticsearch-storage.yaml b/kube/elasticsearch/elasticsearch-storage.yaml new file mode 100644 index 0000000..2392545 --- /dev/null +++ b/kube/elasticsearch/elasticsearch-storage.yaml @@ -0,0 +1,26 @@ +# Elasticsearch Persistent Volume Claim +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: es-pvc +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 500Gi + storageClassName: do-block-storage-retain + +--- +# Elasticsearch Snapshot Repository Persistent Volume Claim +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: es-backup-pvc +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 500Gi + storageClassName: do-block-storage-retain \ No newline at end of file