diff --git a/kube/elasticsearch/elasticsearch-deployment.yaml b/kube/elasticsearch/elasticsearch-deployment.yaml new file mode 100644 index 0000000..30c1add --- /dev/null +++ b/kube/elasticsearch/elasticsearch-deployment.yaml @@ -0,0 +1,111 @@ +# elasticsearch-deployment.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: elasticsearch +spec: + replicas: 1 + selector: + matchLabels: + app: elasticsearch + template: + metadata: + labels: + app: elasticsearch + spec: + initContainers: + - name: init-permissions + image: busybox + command: [ "sh", "-c", "chown -R 1000:1000 /usr/share/elasticsearch/data" ] + volumeMounts: + - name: es-data + mountPath: /usr/share/elasticsearch/data + containers: + - name: elasticsearch + image: docker.elastic.co/elasticsearch/elasticsearch:7.17.0 + resources: + requests: + cpu: "1" + memory: "4Gi" + limits: + cpu: "2" + memory: "6Gi" + ports: + - containerPort: 9200 + name: http + - containerPort: 9300 + name: transport + volumeMounts: + - name: es-data + mountPath: /usr/share/elasticsearch/data + - name: elasticsearch-config + mountPath: /usr/share/elasticsearch/config/elasticsearch.yml + subPath: elasticsearch.yml + env: + - name: discovery.type + value: single-node + - name: ELASTIC_USERNAME + valueFrom: + secretKeyRef: + name: elasticsearch + key: username + - name: ELASTIC_PASSWORD + valueFrom: + secretKeyRef: + name: elasticsearch + key: password + volumes: + - name: es-data + persistentVolumeClaim: + claimName: es-pvc + - name: elasticsearch-config + configMap: + name: elasticsearch-config +--- +# 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 +--- +# Elasticsearch Persistent Volume +apiVersion: v1 +kind: PersistentVolume +metadata: + name: es-pv +spec: + capacity: + storage: 80Gi + accessModes: + - ReadWriteOnce + hostPath: + path: /mnt/data/es +--- +# Elasticsearch Persistent Volume Claim +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: es-pvc +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 80Gi + +--- +# Elasticsearch Service +apiVersion: v1 +kind: Service +metadata: + name: elasticsearch +spec: + ports: + - port: 9200 + selector: + app: elasticsearch diff --git a/kube/elasticsearch/kibana-deployment.yaml b/kube/elasticsearch/kibana-deployment.yaml new file mode 100644 index 0000000..314fc7c --- /dev/null +++ b/kube/elasticsearch/kibana-deployment.yaml @@ -0,0 +1,74 @@ +# kibana-deployment.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: kibana +spec: + replicas: 1 + selector: + matchLabels: + app: kibana + template: + metadata: + labels: + app: kibana + spec: + containers: + - name: kibana + image: docker.elastic.co/kibana/kibana:7.17.0 + resources: + requests: + cpu: "0.5" + memory: "2Gi" + limits: + cpu: "1" + memory: "2Gi" + ports: + - containerPort: 5601 + volumeMounts: + - name: kibana-config + mountPath: /usr/share/kibana/config/kibana.yml + subPath: kibana.yml + env: + - name: ELASTICSEARCH_HOSTS + value: "http://elasticsearch:9200" + - name: ES_USERNAME + valueFrom: + secretKeyRef: + name: elasticsearch + key: username + - name: ES_PASSWORD + valueFrom: + secretKeyRef: + name: elasticsearch + key: password + volumes: + - name: kibana-config + configMap: + name: kibana-config +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: kibana-config +data: + kibana.yml: | + server.name: kibana + server.host: "0.0.0.0" + elasticsearch.hosts: ["http://elasticsearch:9200"] + elasticsearch.username: "${ES_USERNAME}" + elasticsearch.password: "${ES_PASSWORD}" +--- +apiVersion: v1 +kind: Service +metadata: + name: kibana +spec: + type: NodePort + selector: + app: kibana + ports: + - protocol: TCP + port: 5601 + targetPort: 5601 + nodePort: 31000 \ No newline at end of file