Deploy Elasticsearch 6.8.23 on K8S

  Uncategorized
### volume
#Volume 1
kind: PersistentVolume
apiVersion: v1
metadata:
    name: elasticsearch01
spec:
    capacity:
        storage: 5G
    volumeMode: Filesystem
    accessModes:
        - ReadWriteMany
    persistentVolumeReclaimPolicy: Retain
    storageClassName: efs
    csi:
        driver: efs.csi.aws.com
        volumeHandle: fs-01190056cfdde3cce:/elasticsearch01
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
    name: elasticsearch01
spec:
    accessModes:
        - ReadWriteMany
    storageClassName: efs
    resources:
        requests:
            storage: 5G
---
# volume 2
kind: PersistentVolume
apiVersion: v1
metadata:
    name: elasticsearch02
spec:
    capacity:
        storage: 5G
    volumeMode: Filesystem
    accessModes:
        - ReadWriteMany
    persistentVolumeReclaimPolicy: Retain
    storageClassName: efs
    csi:
        driver: efs.csi.aws.com
        volumeHandle: fs-01190056cfdde3cce:/elasticsearch02
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
    name: elasticsearch02
spec:
    accessModes:
        - ReadWriteMany
    storageClassName: efs
    resources:
        requests:
            storage: 5G
---
# volume 3
kind: PersistentVolume
apiVersion: v1
metadata:
    name: elasticsearch03
spec:
    capacity:
        storage: 5G
    volumeMode: Filesystem
    accessModes:
        - ReadWriteMany
    persistentVolumeReclaimPolicy: Retain
    storageClassName: efs
    csi:
        driver: efs.csi.aws.com
        volumeHandle: fs-01190056cfdde3cce:/elasticsearch03
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
    name: elasticsearch03
spec:
    accessModes:
        - ReadWriteMany
    storageClassName: efs
    resources:
        requests:
            storage: 5G
### end volume
---
### deployment pod
apiVersion: v1
kind: Pod
metadata:
    labels:
        app: elasticsearch01
    name: elasticsearch01
spec:
    containers:
        -   name: elasticsearch01
            image: docker.elastic.co/elasticsearch/elasticsearch:6.8.23
            ports:
                -   containerPort: 9200
                -   containerPort: 9300
            volumeMounts:
                -   mountPath: /usr/share/elasticsearch/data
                    name: elasticsearch01
            securityContext:
                allowPrivilegeEscalation: false
                runAsUser: 0
            env:
                -   name: node.name
                    value: "elasticsearch01"
                -   name: cluster.name
                    value: "es-docker-cluster"
                -   name: discovery.zen.ping.unicast.hosts
                    value: "elasticsearch02,elasticsearch03"
                -   name: node.master
                    value: "true"
                -   name: node.data
                    value: "false"
                -   name: node.ingest
                    value: "false"
                -   name: bootstrap.memory_lock
                    value: "true"
                -   name: ES_JAVA_OPTS
                    value: "-Xms1g -Xmx1g"
    volumes:
        -   name: elasticsearch01
            persistentVolumeClaim:
                claimName: elasticsearch01
---
apiVersion: v1
kind: Service
metadata:
    name: elasticsearch01
spec:
    type: ClusterIP
    selector:
        app: elasticsearch01
    ports:
        -   protocol: TCP
            port: 9200
            targetPort: 9200
            name: es
        -   protocol: TCP
            port: 9300
            targetPort: 9300
            name: ess
---
apiVersion: v1
kind: Pod
metadata:
    labels:
        app: elasticsearch02
    name: elasticsearch02
spec:
    containers:
        -   name: elasticsearch02
            image: docker.elastic.co/elasticsearch/elasticsearch:6.8.23
            ports:
                -   containerPort: 9200
                -   containerPort: 9300
            volumeMounts:
                -   mountPath: /usr/share/elasticsearch/data
                    name: elasticsearch02
            securityContext:
                allowPrivilegeEscalation: false
                runAsUser: 0
            env:
                -   name: node.name
                    value: "elasticsearch02"
                -   name: cluster.name
                    value: "es-docker-cluster"
                -   name: discovery.zen.ping.unicast.hosts
                    value: "elasticsearch01,elasticsearch03"
                -   name: node.master
                    value: "false"
                -   name: node.data
                    value: "true"
                -   name: node.ingest
                    value: "true"
                -   name: bootstrap.memory_lock
                    value: "true"
                -   name: ES_JAVA_OPTS
                    value: "-Xms512m -Xmx512m"
    volumes:
        -   name: elasticsearch02
            persistentVolumeClaim:
                claimName: elasticsearch02
---
apiVersion: v1
kind: Service
metadata:
    name: elasticsearch02
spec:
    type: ClusterIP
    selector:
        app: elasticsearch02
    ports:
        -   protocol: TCP
            port: 9200
            targetPort: 9200
            name: es
        -   protocol: TCP
            port: 9300
            targetPort: 9300
            name: ess
---
apiVersion: v1
kind: Pod
metadata:
    labels:
        app: elasticsearch03
    name: elasticsearch03
spec:
    containers:
        -   name: elasticsearch03
            image: docker.elastic.co/elasticsearch/elasticsearch:6.8.23
            ports:
                -   containerPort: 9200
                -   containerPort: 9300
            volumeMounts:
                -   mountPath: /usr/share/elasticsearch/data
                    name: elasticsearch03
            securityContext:
                allowPrivilegeEscalation: false
                runAsUser: 0
            env:
                -   name: node.name
                    value: "elasticsearch03"
                -   name: cluster.name
                    value: "es-docker-cluster"
                -   name: discovery.zen.ping.unicast.hosts
                    value: "elasticsearch01,elasticsearch02"
                -   name: node.master
                    value: "false"
                -   name: node.data
                    value: "true"
                -   name: node.ingest
                    value: "true"
                -   name: bootstrap.memory_lock
                    value: "true"
                -   name: ES_JAVA_OPTS
                    value: "-Xms512m -Xmx512m"
    volumes:
        -   name: elasticsearch03
            persistentVolumeClaim:
                claimName: elasticsearch03
---
apiVersion: v1
kind: Service
metadata:
    name: elasticsearch03
spec:
    type: ClusterIP
    selector:
        app: elasticsearch03
    ports:
        -   protocol: TCP
            port: 9200
            targetPort: 9200
            name: es
        -   protocol: TCP
            port: 9300
            targetPort: 9300
            name: ess
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
    name: elasticsearch
    annotations:
        kubernetes.io/ingress.class: nginx
spec:
    rules:
        -   host: elasticsearch.dotb.cloud
            http:
                paths:
                    -   path: /
                        pathType: Prefix
                        backend:
                            service:
                                name: elasticsearch01
                                port:
                                    number: 9200