• 使用kubeadm安装Kubernetes


    1. Docker安装
      yum install -y yum-utils
      yum-config-manager --add-repo https://docs.docker.com/v1.13/engine/installation/linux/repo_files/centos/docker.repo
      yum makecache fast
      yum list docker-engine.x86_64 --showduplicates |sort -r
      rpm -qa | grep docker*
      yum install -y docker-engine-1.12.6
      systemctl start docker
      systemctl enable docker

      Kubernetes 1.6还没有针对docker 1.13和最新的docker 17.03上做测试和验证,所以这里安装Kubernetes官方推荐的Docker 1.12版本

    2. 添加kubernetes源
      cat >> /etc/yum.repos.d/kubernetes.repo <<EOF
      [kubernetes]
      name=Kubernetes
      baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
      enabled=1
      gpgcheck=0
      EOF
      
      cat >> /etc/sysctl.d/k8s.conf <<EOF
      net.bridge.bridge-nf-call-ip6tables = 1  net.bridge.bridge-nf-call-iptables = 1
      EOF
      
      sysctl -p /etc/sysctl.d/k8s.conf
    3. 安装k8s服务
      yum install -y kubelet kubeadm kubectl kubernetes-cni
      systemctl enable kubelet.service
      systemctl restart kubelet.service
    4. 所有节点添加hosts
      cat >> /etc/hosts <<EOF
      10.10.24.237 k8s-master
      10.10.24.236 k8s-node-1
      10.10.24.232 k8s-node-2
      EOF
    5. 主节点初始化集群
      kubeadm init --kubernetes-version=v1.7.5 --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=10.10.24.237
      网络问题无法从google下载容器镜像:
      [apiclient] Created API client, waiting for the control plane to become ready
      卡住需要执行kubeadm reset清理,重新执行
      init成功后k8s的核心组件均正常启动,以container的形式启动:ps -ef|grep kube
      为了使用kubectl访问apiserver,在~/.bash_profile中追加下面的环境变量:
      export KUBECONFIG=/etc/kubernetes/admin.conf
      source ~/.bash_profile
      此时kubectl命令在master node上就可以用了,查看一下当前机器中的Node:
      kubectl get nodes
    6. 向集群中添加节点
      将node1和node2加入集群,分别在node1和node2上执行:
      kubeadm join --token e7986d.e440de5882342711 10.10.24.237:6443
      使master node参与工作负载
      kubectl taint nodes --all node-role.kubernetes.io/master-
      使用kubeadm初始化的集群,出于安全考虑Pod不会被调度到Master Node上,也就是说Master Node不参与工作负载
    7. 所有节点安装flannel pod网络
      kubectl create -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel-rbac.yml
      kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
      serviceaccount "flannel" created
      configmap "kube-flannel-cfg" created
      daemonset "kube-flannel-ds" created
      ps -ef|grep kube|grep flannel
      使用kubectl get pod --all-namespaces -o wide确保所有的Pod都处于Running
    8. 安装Dashboard插件
      wget https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/kubernetes-dashboard.yaml
      kubectl create -f kubernetes-dashboard.yaml
      kubectl create -f kube-dashboard-rbac.yml
      kind: ClusterRoleBinding
      apiVersion: rbac.authorization.k8s.io/v1beta1
      metadata:
      name: dashboard-admin
      roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: ClusterRole
      name: cluster-admin
      subjects:
      - kind: ServiceAccount
      name: default
      namespace: kube-system
      kube-dashboard-rbac.yml

      kubectl create -f dashboard-rbac.yml

    9. 在集群中运行Heapster 
      wget https://github.com/kubernetes/heapster/archive/v1.3.0.tar.gz
      tar -zxvf v1.3.0.tar.gz
      cd heapster-1.3.0/deploy/kube-config/influxdb
      kubectl create -f ./
      deployment "monitoring-grafana" created
      service "monitoring-grafana" created
      deployment "heapster" created
      service "heapster" created
      deployment "monitoring-influxdb" created
      service "monitoring-influxdb" created
  • 相关阅读:
    人工智能与信息社会——人工智能发展简史
    人工智能与信息社会——新闻热点与身边的人工智能
    蓝桥杯——入门训练
    Android Studio安装虚拟机步骤
    Android开发环境搭建教程
    Android系统架构(图解)
    第6.7节 stack 1982 问题 B: Problem E
    Matlab高级教程_第二篇:MATLAB和C#对应数据类型的讲解(多讲一点儿C#的矩阵运算)
    Matlab高级教程_第二篇:一个简单的混编例子
    Matlab高级教程_第二篇:Matlab2016a和VS2013混合
  • 原文地址:https://www.cnblogs.com/Mrhuangrui/p/7805555.html
Copyright © 2020-2023  润新知