From 43669aa5d99bed487036e294ff058deb17ac6756 Mon Sep 17 00:00:00 2001 From: ycz008 Date: Mon, 10 Jul 2023 19:38:19 +0800 Subject: [PATCH] add es --- dev-upgrade/elastic/elastic.yaml | 112 +++++++++++++++++++++++++++++++ dev-upgrade/elastic/kibana.yaml | 69 +++++++++++++++++++ dev-upgrade/elastic/stroage.yaml | 74 ++++++++++++++++++++ 3 files changed, 255 insertions(+) create mode 100644 dev-upgrade/elastic/elastic.yaml create mode 100644 dev-upgrade/elastic/kibana.yaml create mode 100644 dev-upgrade/elastic/stroage.yaml diff --git a/dev-upgrade/elastic/elastic.yaml b/dev-upgrade/elastic/elastic.yaml new file mode 100644 index 0000000..bd9592c --- /dev/null +++ b/dev-upgrade/elastic/elastic.yaml @@ -0,0 +1,112 @@ +--- +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: elastic +spec: + serviceName: elastic + replicas: 3 + selector: + matchLabels: + app: elastic + template: + metadata: + labels: + app: elastic + spec: + securityContext: + fsGroup: 100 + nodeSelector: + kubernetes.io/arch: amd64 + initContainers: + - name: init + image: busybox + imagePullPolicy: IfNotPresent + command: ["/bin/sh", "-c", "sysctl -w vm.max_map_count=262144"] + securityContext: + privileged: true + containers: + - name: elasticsearch + image: docker.elastic.co/elasticsearch/elasticsearch:8.8.0 + imagePullPolicy: Always + ports: + - containerPort: 9200 + name: restful + - containerPort: 9300 + name: transport + env: + - name: cluster.name + value: bfs-elastic-1 + - name: network.host + value: 0.0.0.0 + - name: node.name + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: discovery.seed_hosts + value: "elastic-0.elastic,elastic-1.elastic,elastic-2.elastic" + - name: cluster.initial_master_nodes + value: "elastic-0,elastic-1,elastic-2" + - name: xpack.security.enabled + value: "true" + - name: xpack.security.transport.ssl.enabled + value: "true" + - name: xpack.monitoring.collection.enabled + value: "true" + - name: ES_JAVA_OPTS + value: "-Xms256m -Xmx256m" + - name: ELASTIC_PASSWORD + value: "changeme" + resources: + limits: + cpu: 2 + memory: 4Gi + requests: + cpu: 100m + memory: 128Mi + volumeMounts: + - name: es-data + mountPath: /usr/share/elasticsearch/data + volumeClaimTemplates: + - metadata: + name: es-data + spec: + accessModes: ['ReadWriteOnce'] + storageClassName: "local-elastic" + resources: + requests: + storage: 30Gi + +--- +apiVersion: v1 +kind: Service +metadata: + name: elastic-internel + labels: + app: elastic +spec: + ports: + - name: restful + port: 9200 + targetPort: 9200 + nodePort: 30020 + type: NodePort + selector: + app: elastic + +--- +apiVersion: v1 +kind: Service +metadata: + name: elastic + labels: + app: elastic +spec: + ports: + - name: restful + port: 9200 + - name: transport + port: 9300 + clusterIP: None + selector: + app: elastic diff --git a/dev-upgrade/elastic/kibana.yaml b/dev-upgrade/elastic/kibana.yaml new file mode 100644 index 0000000..72781fb --- /dev/null +++ b/dev-upgrade/elastic/kibana.yaml @@ -0,0 +1,69 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: kibana-config +data: + kibana.yml: |- + server.name: kibana + server.host: 0.0.0.0 + elasticsearch.hosts: [ "http://elastic:9200" ] + monitoring.ui.container.elasticsearch.enabled: true + xpack.security.enabled: true + elasticsearch.username: kibana-admin + elasticsearch.password: admin123 +--- +apiVersion: v1 +kind: Service +metadata: + name: kibana + labels: + app: kibana +spec: + ports: + - port: 5601 + targetPort: 5601 + nodePort: 30019 + selector: + app: kibana + type: NodePort +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: kibana + labels: + app: kibana +spec: + replicas: 1 + selector: + matchLabels: + app: kibana + template: + metadata: + labels: + app: kibana + spec: + containers: + - name: kibana + image: docker.elastic.co/kibana/kibana:8.8.0 + volumeMounts: + - name: config + mountPath: /usr/share/kibana/config/kibana.yml + subPath: kibana.yml + readOnly: true + resources: + requests: + cpu: 100m + memory: 128Mi + limits: + cpu: 1 + memory: 1Gi + ports: + - containerPort: 5601 + volumes: + - name: config + configMap: + name: kibana-config + items: + - key: kibana.yml + path: kibana.yml \ No newline at end of file diff --git a/dev-upgrade/elastic/stroage.yaml b/dev-upgrade/elastic/stroage.yaml new file mode 100644 index 0000000..c7a29e6 --- /dev/null +++ b/dev-upgrade/elastic/stroage.yaml @@ -0,0 +1,74 @@ +--- +apiVersion: v1 +kind: PersistentVolume +metadata: + name: elastic-dev-0 +spec: + storageClassName: local-elastic + capacity: + storage: 50Gi + accessModes: + - ReadWriteOnce + local: + path: /data/elastic-dev/es_data + nodeAffinity: + required: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/hostname + operator: In + values: + - bfs-k8snode-10-2-0-12.hetzner.base.beaconfireinc.com + +--- +apiVersion: v1 +kind: PersistentVolume +metadata: + name: elastic-dev-1 +spec: + storageClassName: local-elastic + capacity: + storage: 50Gi + accessModes: + - ReadWriteOnce + local: + path: /data/elastic-dev/es_data + nodeAffinity: + required: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/hostname + operator: In + values: + - bfs-k8snode-10-2-0-13.hetzner.base.beaconfireinc.com + +--- +apiVersion: v1 +kind: PersistentVolume +metadata: + name: elastic-dev-2 +spec: + storageClassName: local-elastic + capacity: + storage: 50Gi + accessModes: + - ReadWriteOnce + local: + path: /data/elastic-dev/es_data + nodeAffinity: + required: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/hostname + operator: In + values: + - bfs-k8snode-10-2-0-14.hetzner.base.beaconfireinc.com + +--- +apiVersion: storage.k8s.io/v1 +kind: StorageClass +metadata: + name: local-elastic +provisioner: openebs.io/local +allowVolumeExpansion: true +volumeBindingMode: WaitForFirstConsumer