zoukankan      html  css  js  c++  java
  • Kubernetes

    1,镜像下载

    1.1 所有节点下载镜像

    docker pull kibana:5.6.4
    docker tag kibana:5.6.4 docker.elastic.co/kibana/kibana:5.6.4
    
    docker pull xiaoqshuo/fluentd-elasticsearch:v2.0.4
    docker pull xiaoqshuo/elasticsearch:v5.6.4
    
    docker tag xiaoqshuo/fluentd-elasticsearch:v2.0.4 k8s.gcr.io/fluentd-elasticsearch:v2.0.4
    docker tag xiaoqshuo/elasticsearch:v5.6.4 k8s.gcr.io/elasticsearch:v5.6.4
    
    • master01下载对应的k8s源码包
    wget https://github.com/kubernetes/kubernetes/releases/download/v1.12.3/kubernetes.tar.gz
    
    • 对节点进行label
    [root@k8s-master01 fluentd-elasticsearch]# pwd
    /opt/k8-ha-install/kubernetes/cluster/addons/fluentd-elasticsearch
    
    [root@k8s-master01 fluentd-elasticsearch]# kubectl label node beta.kubernetes.io/fluentd-ds-ready=true --all
    node/k8s-master01 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   27h   v1.12.3   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-node01     Ready    master   27h   v1.12.3   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/fluentd-ds-ready=true,beta.kubernetes.io/os=linux,kubernetes.io/hostname=k8s-node01,node-role.kubernetes.io/master=
    k8s-node02     Ready    master   27h   v1.12.3   beta.kubernetes.io/arch=amd64,beta.kubernetes.io/fluentd-ds-ready=true,beta.kubernetes.io/os=linux,kubernetes.io/hostname=k8s-node02,node-role.kubernetes.io/master=
    

    2,持久化卷

    • 采用NFS作为后端存储,NAS、GFS、CEPH同理
    • 所有节点
    yum install nfs-utils -y
    

    2.1 NFS -- > 服务器:k8s-node01

    • 在NFS服务器上创建es的存储目录(使用动态存储可以自动创建pv,无需此步骤)
    [root@k8s-node01 es]# pwd
    /nfs/es
    
    [root@k8s-node01 es]# mkdir es{0..2}
    
    [root@k8s-node01 es]# ls
    es0  es1  es2
    
    • 启动 nfs
    systemctl start rpcbind && systemctl enable rpcbind
    systemctl start nfs && systemctl enable nfs
    
    • 配置NFS
    [root@k8s-node01 ~]# more /etc/exports
    /nfs/es/ 192.168.2.0/24(rw,sync,no_subtree_check,no_root_squash)
    
    • 配置生效
    [root@k8s-node01 es]# exportfs -rv
    exporting 192.168.2.0/24:/nfs/es
    
    • 查看nfs挂载点
    [root@k8s-node01 es]# showmount -e localhost
    Export list for localhost:
    /nfs/es 192.168.2.0/24
    
    • 测试挂载
    [root@k8s-node02 ~]#mkdir -p /nfs/es
    [root@k8s-node02 ~]# mount -t nfs k8s-node01:/nfs/es /nfs/es
    

    3,创建集群

    [root@k8s-master01 k8s-cluster]# kubectl apply -f k8s-efk/
    namespace/logging created
    service/elasticsearch-logging created
    serviceaccount/elasticsearch-logging created
    clusterrole.rbac.authorization.k8s.io/elasticsearch-logging created
    clusterrolebinding.rbac.authorization.k8s.io/elasticsearch-logging created
    statefulset.apps/elasticsearch-logging created
    persistentvolume/pv-es-0 created
    persistentvolume/pv-es-1 created
    persistentvolume/pv-es-2 created
    configmap/fluentd-es-config-v0.1.4 created
    serviceaccount/fluentd-es created
    clusterrole.rbac.authorization.k8s.io/fluentd-es created
    clusterrolebinding.rbac.authorization.k8s.io/fluentd-es created
    daemonset.apps/fluentd-es-v2.0.4 created
    deployment.apps/kibana-logging created
    service/kibana-logging created
    
    • 查看pv、pvc、pods
    [root@k8s-master01 k8s-efk]# 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-0   es-storage-class            8s
    pv-es-1   4Gi        RWX            Recycle          Available                                                           es-storage-class            8s
    pv-es-2   4Gi        RWX            Recycle          Bound       logging/elasticsearch-logging-elasticsearch-logging-1   es-storage-class            8s
    
    
    [root@k8s-master01 k8s-efk]# kubectl get pod -n logging
    NAME                              READY   STATUS    RESTARTS   AGE
    elasticsearch-logging-0           1/1     Running   0          35s
    elasticsearch-logging-1           1/1     Running   0          32s
    fluentd-es-v2.0.4-595tq           1/1     Running   0          34s
    fluentd-es-v2.0.4-8x8bj           1/1     Running   0          34s
    fluentd-es-v2.0.4-fxjp4           1/1     Running   0          34s
    kibana-logging-8458f5d886-vfkzc   1/1     Running   0          34s
    

  • 相关阅读:
    IDEA搭建《算法》第四版的开发环境
    tomcat源码环境搭建
    cap定理
    idea jdk 源码搭建
    2020-04-07 学习记录
    idea 格式化代码
    Ajax工作原理
    prototype封装继承
    作用域
    原型链的原理
  • 原文地址:https://www.cnblogs.com/xiaoqshuo/p/10081896.html
Copyright © 2011-2022 走看看