3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Raspberry Pi(arm64)のKubernetesにElasticsearchとKibana環境を構築する

Last updated at Posted at 2020-09-06

![Raspberry_Pi_OS-2020--05--27--raspios--buster--arm64] (https://img.shields.io/badge/Raspberry_Pi_OS-2020--05--27--raspios--buster--arm64-brightgreen) Kubernetes-v1.18.3 Minikube-v1.12.1 Helm-v3.3.1 Elasticsearch-7.9.1 Kibana-7.9.1

arm64向けのKibanaのコンテナイメージの作成に成功したので、Kubernetes上で構築してみました。
(コンテナイメージの作成方法とDocker Composeでの構築はこちらを参照)

Helmのインストール

wget https://get.helm.sh/helm-v3.3.1-linux-arm64.tar.gz
tar zxvf helm-v3.3.1-linux-arm64.tar.gz
cd linux-arm64/
sudo install helm /usr/local/bin

動作確認

 $ helm version
version.BuildInfo{Version:"v3.3.1", GitCommit:"249e5215cde0c3fa72e27eb7a30e8d55c9696144", GitTreeState:"clean", GoVersion:"go1.14.7"}
 $ 

HelmのElasticリポジトリ設定

Elastic Stack Kubernetes Helm Charts
https://github.com/elastic/helm-charts

helm repo add elastic https://helm.elastic.co
$ helm search repo elastic
NAME                    CHART VERSION   APP VERSION     DESCRIPTION                                       
elastic/elasticsearch   7.9.1           7.9.1           Official Elastic helm chart for Elasticsearch     
elastic/apm-server      7.9.1           7.9.1           Official Elastic helm chart for Elastic APM Server
elastic/filebeat        7.9.1           7.9.1           Official Elastic helm chart for Filebeat          
elastic/kibana          7.9.1           7.9.1           Official Elastic helm chart for Kibana            
elastic/logstash        7.9.1           7.9.1           Official Elastic helm chart for Logstash          
elastic/metricbeat      7.9.1           7.9.1           Official Elastic helm chart for Metricbeat        
 $ 

Elasticsearch環境の構築

PersistentVolumeの作成

Helmのインストールの前にPersistentVolumeを作成します。

apiVersion: v1
kind: PersistentVolume
metadata:
  name: es-pv-volume
  labels:
    type: local
    app: elasticsearch-master
spec:
  storageClassName: standard
  capacity:
    storage: 1Gi
  persistentVolumeReclaimPolicy: Delete
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/data/elasticsearch"

/data/elasticsearchディレクトリを自動生成させると、rootユーザーが所有者となってPodの起動が失敗しましたので、先にホストOS側で準備しておきます

mkdir /data/elasticsearch
chown 1000:1000 /data/elasticsearch

Elasticsearch Helm Chartのインストール

minikube環境向けのサンプルがありますので、そちらを元にしました。imageTagreplicasだけ独自に足しました。

---
imageTag: 7.9.1

replicas: 1

# Permit co-located instances for solitary minikube virtual machines.
antiAffinity: "soft"

# Shrink default JVM heap.
esJavaOpts: "-Xmx128m -Xms128m"

# Allocate smaller chunks of memory per pod.
resources:
  requests:
    cpu: "100m"
    memory: "512M"
  limits:
    cpu: "1000m"
    memory: "512M"

# Request smaller persistent volumes.
volumeClaimTemplate:
  accessModes: [ "ReadWriteOnce" ]
  storageClassName: "standard"
  resources:
    requests:
      storage: 100M
helm install elasticsearch elastic/elasticsearch --values ./values.yml

うまく行けば一式起動します

 $ kubectl get service,statefulset,pod,persistentvolumeclaim,persistentvolume --namespace=default -l app=elasticsearch-master
NAME                                    TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)             AGE
service/elasticsearch-master            ClusterIP   10.103.52.98   <none>        9200/TCP,9300/TCP   6h38m
service/elasticsearch-master-headless   ClusterIP   None           <none>        9200/TCP,9300/TCP   6h38m

NAME                                    READY   AGE
statefulset.apps/elasticsearch-master   1/1     6h38m

NAME                         READY   STATUS    RESTARTS   AGE
pod/elasticsearch-master-0   1/1     Running   2          6h38m

NAME                                                                STATUS   VOLUME         CAPACITY   ACCESS MODES   STORAGECLASS   AGE
persistentvolumeclaim/elasticsearch-master-elasticsearch-master-0   Bound    es-pv-volume   1Gi        RWO            standard       6h38m

NAME                            CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                                                 STORAGECLASS   REASON   AGE
persistentvolume/es-pv-volume   1Gi        RWO            Delete           Bound    default/elasticsearch-master-elasticsearch-master-0   standard                6h43m
 $ 

Kibana環境の構築

Kibana Helm Chartのインストール

Kibanaもvalues.ymlを用意します。

Kibanaはarm64向けコンテナイメージが提供されていないので、自前で作成しました。
(詳しい説明はこちら

---
image: "ghcr.io/moritalous/ghcr/kibana-arm64"
imageTag: 7.9.1

service:
  type: NodePort
  port: 5601
  nodePort: 30601
helm install kibana elastic/kibana --values ./values.yml

起動確認

$ kubectl get service,deployment,pod --namespace=default -l app=kibana
NAME                    TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)          AGE
service/kibana-kibana   NodePort   10.109.131.74   <none>        5601:30601/TCP   8h

NAME                            READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/kibana-kibana   1/1     1            1           8h

NAME                                 READY   STATUS    RESTARTS   AGE
pod/kibana-kibana-56b7b6c95c-vj6sv   1/1     Running   0          7h37m
 $ 

動作確認

http://raspberrypi.local:30601/

image.png

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?