一、配置Kubectl
- 在Master上執行下面的命令來配置Kubectl
[root@k8s-master ~]# echo "export KUBECONFIG=/etc/kubernetes/admin.conf" >> /etc/profile
[root@k8s-master ~]# source /etc/profile
[root@k8s-master ~]# echo $KUBECONFIG
二、安裝Pod網路
- 安裝Pod網路是Pod之間進行通信的必要條件,k8s支持眾多網路方案,這里我們依然選用經典的flannel方案
- 首先是設定系統引數,主從都設定
[root@k8s-master bridge]# sysctl net.bridge.bridge-nf-call-iptables=1
- 然后在Master節點上執行如下命令:
kubectl apply -f kube-flannel.yaml
kube-flannel.yam下載地址:https://github.com/hansonwang99/JavaCollection/edit/master/docs/kubernetes/kube-flannel.yaml- 一旦Pod網路安裝完成,可以執行下面的命令來進行檢查CoreDNS Pod此刻是否正常運行起來的,一旦正常運行起來就可以執行后面步驟:
kubectl get pods --all-namespaces -o wide
三、安裝ElasticSearch集群部署
- 推薦一個開源鏡像倉https://mirrors.huaweicloud.com/,華為的開源鏡像倉,大家都可以進
- 節點準備,這里準備了兩個節點
- 節點一:192.168.1.9;節點二:192.168.1.8
- 下載elasticsearch,從開源鏡像倉,然后放到
/opt/elasticsearch目錄中
[root@k8s-master ~]# mkdir /opt/elasticsearch
[root@k8s-master ~]# cd /opt/elasticsearch/
[root@k8s-master elasticsearch]# tar -zxvf elasticsearch-6.4.2.tar.1.gz
[root@k8s-node-1 elasticsearch]# cd elasticsearch-6.4.2//config
[root@k8s-master config]# vim elasticsearch.yml
cluster.name:ruigege #集群名稱
node.name:ruigege1 #節點名
network.host:192.168.1.9 #系結的節點1地址
network.bind_host:0.0.0.0 #不設定這個,本機可能不能訪問
discovery.zen.ping.unicast.hosts:["192.168.1.9","192.168.1.8"] #hosts串列
discovery.zen.minimum_master_nodes:1
#如下配置是為了解決Elasticsearch可視化工具dejavu的跨域問題,若不使用可視化工具那么就可忽略
http.port: 9200
http.cors.allow-origin:"http://192.168.199.76:1358"
http.cors.enabled:true
http.cors.allow-headers: X-Requested-With,X-Auth-Token,Content-Type,Content-Leng
th,Authorization
http.cors.allow-credentials:true
- 退出保存,然后設定一下節點2,只替換一下就行了
- 添加群組,設定權限,關閉防火墻,開啟程式
[root@k8s-node-1 config]# groupadd es
[root@k8s-node-1 config]# useradd es -g es
[root@k8s-node-1 config]# cd ..
[root@k8s-node-1 elasticsearch-6.4.2]# cd ..
[root@k8s-node-1 elasticsearch]# chown -R es:es ./elasticsearch-6.4.2
[root@k8s-node-1 elasticsearch]# systemctl stop firewalld
[root@k8s-node-1 elasticsearch]# systemctl disable firewalld
[root@k8s-node-1 elasticsearch]# su es
[es@k8s-node-1 elasticsearch]$ cd elasticsearch-6.4.2/bin
[es@k8s-node-1 bin]$ ./elasticsearch
四、原始碼:
- 搭建一個開源專案12-Kubernetes集群部署(下)以及elasticsearch部署.md
- https://github.com/ruigege66/Linux/blob/master/搭建一個開源專案12-Kubernetes集群部署(下)以及elasticsearch部署.md
- CSDN:https://blog.csdn.net/weixin_44630050
- 博客園:https://www.cnblogs.com/ruigege0000/
- 歡迎關注微信公眾號:傅里葉變換,個人賬號,僅用于技術交流

轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/1769.html
標籤:Linux
上一篇:使用樹莓派搭建局域網監控
