一、鏡像下載node
全部節點下載鏡像linux
docker pull kibana:5.6.4 docker tag kibana:5.6.4 docker.elastic.co/kibana/kibana:5.6.4 docker pull dotbalo/fluentd-elasticsearch:v2.0.4 docker pull dotbalo/elasticsearch:v5.6.4 docker tag dotbalo/fluentd-elasticsearch:v2.0.4 k8s.gcr.io/fluentd-elasticsearch:v2.0.4 docker tag dotbalo/elasticsearch:v5.6.4 k8s.gcr.io/elasticsearch:v5.6.4
master01下載對應的k8s源碼包git
wget https://github.com/kubernetes/kubernetes/releases/download/v1.11.1/kubernetes.tar.gz
對節點進行labelgithub
[root@k8s-master01 fluentd-elasticsearch]# kubectl label node beta.kubernetes.io/fluentd-ds-ready=true --all node/k8s-master01 labeled node/k8s-master02 labeled node/k8s-master03 labeled node/k8s-node01 labeled node/k8s-node02 labeled [root@k8s-master01 fluentd-elasticsearch]# kubectl get nodes --show-labels | grep beta.kubernetes.io/fluentd-ds-ready k8s-master01 Ready master 1d v1.11.1 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/fluentd-ds-ready=true,beta.kubernetes.io/os=linux,kubernetes.io/hostname=k8s-master01,node-role.kubernetes.io/master= k8s-master02 Ready master 1d v1.11.1 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/fluentd-ds-ready=true,beta.kubernetes.io/os=linux,kubernetes.io/hostname=k8s-master02,node-role.kubernetes.io/master= k8s-master03 Ready master 1d v1.11.1 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/fluentd-ds-ready=true,beta.kubernetes.io/os=linux,kubernetes.io/hostname=k8s-master03,node-role.kubernetes.io/master= k8s-node01 Ready <none> 7h v1.11.1 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/fluentd-ds-ready=true,beta.kubernetes.io/os=linux,kubernetes.io/hostname=k8s-node01 k8s-node02 Ready <none> 7h v1.11.1 beta.kubernetes.io/arch=amd64,beta.kubernetes.io/fluentd-ds-ready=true,beta.kubernetes.io/os=linux,kubernetes.io/hostname=k8s-node02
二、持久化卷docker
採用NFS做爲後端存儲,NAS、GFS、CEPH同理後端
在NFS服務器上建立es的存儲目錄(使用動態存儲能夠自動建立pv,無需此步驟)api
[root@nfs es]# pwd /nfs/es [root@nfs es]# mkdir es{0..2}
三個es實例建立三個目錄,以此類推服務器
掛載測試app
# 全部k8s節點 yum install nfs-utils -y # 掛載 [root@k8s-master01 ~]# mount -t nfs 192.168.2.2:/nfs/es/es0 /mnt/ # 無問題卸載 [root@k8s-master01 ~]# umount /mnt/
三、建立集羣elasticsearch
使用靜態pv建立es集羣,文件地址:https://github.com/dotbalo/k8s/
[root@k8s-master01 efk-static]# ls efk-namespaces.yaml es2-pv.yaml fluentd-es-configmap.yaml kibana-svc.yaml es0-pv.yaml es-service.yaml fluentd-es-ds.yaml README.md es1-pv.yaml es-ss.yaml kibana-deployment.yaml [root@k8s-master01 efk-static]# kubectl apply -f . [root@k8s-master01 efk-static]# kubectl apply -f . namespace/logging configured service/elasticsearch-logging created serviceaccount/elasticsearch-logging created clusterrole.rbac.authorization.k8s.io/elasticsearch-logging configured clusterrolebinding.rbac.authorization.k8s.io/elasticsearch-logging configured statefulset.apps/elasticsearch-logging created persistentvolume/pv-es-0 configured persistentvolume/pv-es-1 configured persistentvolume/pv-es-2 configured configmap/fluentd-es-config-v0.1.1 created serviceaccount/fluentd-es created clusterrole.rbac.authorization.k8s.io/fluentd-es configured clusterrolebinding.rbac.authorization.k8s.io/fluentd-es configured daemonset.apps/fluentd-es-v2.0.2 created deployment.apps/kibana-logging created service/kibana-logging created
查看pv、pvc、pods
[root@k8s-master01 efk-static]# kubectl get pv NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE pv-es-0 4Gi RWX Recycle Bound logging/elasticsearch-logging-elasticsearch-logging-1 es-storage-class 59m pv-es-1 4Gi RWX Recycle Available es-storage-class 59m pv-es-2 4Gi RWX Recycle Bound logging/elasticsearch-logging-elasticsearch-logging-0 es-storage-class 59m [root@k8s-master01 efk-static]# kubectl get pvc -n logging NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE elasticsearch-logging-elasticsearch-logging-0 Bound pv-es-2 4Gi RWX es-storage-class 1h elasticsearch-logging-elasticsearch-logging-1 Bound pv-es-0 4Gi RWX es-storage-class 1h
[root@k8s-master01 ~]# kubectl get pods -n logging NAME READY STATUS RESTARTS AGE elasticsearch-logging-0 1/1 Running 2 3h elasticsearch-logging-1 1/1 Running 0 3h fluentd-es-v2.0.4-5jqhw 1/1 Running 0 10m fluentd-es-v2.0.4-fw5gk 1/1 Running 0 10m fluentd-es-v2.0.4-hm2tc 1/1 Running 0 10m fluentd-es-v2.0.4-nqqtm 1/1 Running 0 10m fluentd-es-v2.0.4-r5fgh 1/1 Running 0 10m kibana-logging-677854568-l6pvc 1/1 Running 0 3h
四、建立kibana的ingress
apiVersion: extensions/v1beta1 kind: Ingress metadata: name: kibana namespace: logging annotations: kubernetes.io/ingress.class: traefik spec: rules: - host: kibana.net http: paths: - backend: serviceName: kibana-logging servicePort: 5601
訪問kibana,建立index
贊助做者: