• Centos7 Install Kubernetes


    环境搭建
    配置官方 k8s yum 源:

    cat <<EOF > /etc/yum.repos.d/virt7-docker-common-release.repo
    [virt7-docker-common-release]
    name=virt7-docker-common-release
    baseurl=http://cbs.centos.org/repos/virt7-docker-common-release/x86_64/os/
    gpgcheck=0
    EOF
    virt7-docker-common-release.repo

    配置阿里云 yum 源:
    vim /etc/yum.repos.d/aliyun-docker-common-release.repo

    [base]
    name=CentOS-$releasever - Base - mirrors.aliyun.com
    failovermethod=priority
    baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
            http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
    #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
    gpgcheck=1
    gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
    #released updates
    [updates]
    name=CentOS-$releasever - Updates - mirrors.aliyun.com
    failovermethod=priority
    baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/        http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
    #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
    gpgcheck=1
    gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
    #additional packages that may be useful
    [extras]
    name=CentOS-$releasever - Extras - mirrors.aliyun.com
    failovermethod=priority
    baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
    http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
    #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
    gpgcheck=1
    gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
    #additional packages that extend functionality of existing packages
    [centosplus]
    name=CentOS-$releasever - Plus - mirrors.aliyun.com
    failovermethod=priority
    baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/    http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
    #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
    gpgcheck=1
    enabled=0
    gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
    #contrib - packages by Centos Users
    [contrib]
    name=CentOS-$releasever - Contrib - mirrors.aliyun.com
    failovermethod=priority
    baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
    http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
    #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
    gpgcheck=1
    enabled=0
    gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
    aliyun-docker-common-release.repo

    更新本地镜像源
    yum clean all
    yum makecache
    关闭 SELinux:
    setenforce 0
    关闭防火墙:
    systemctl stop firewalld.service
    systemctl disable firewalld.service

    安装 Kubernetes 环境 (Master)

    yum -y install --enablerepo=virt7-docker-common-release kubernetes etcd flannel
    编辑本地 host 文件,做好访问映射:vim /etc/hosts

    配置文件修改:
    vim /etc/kubernetes/config

    KUBE_LOGTOSTDERR="--logtostderr=true"
    KUBE_LOG_LEVEL="--v=0"
    KUBE_ALLOW_PRIV="--allow-privileged=false"
    KUBE_MASTER="--master=http://k8s-master:8080"
    config

    vim /etc/etcd/etcd.conf

    ETCD_NAME=default
    ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
    ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"
    ETCD_ADVERTISE_CLIENT_URLS="http://0.0.0.0:2379"
    etcd.conf

    vim /etc/kubernetes/apiserver
    需删除KUBE_ADMISSION_CONTROL项ServiceAccount参数

    KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0"
    KUBE_API_PORT="--port=8080"
    KUBELET_PORT="--kubelet-port=10250"
    KUBE_ETCD_SERVERS="--etcd-servers=http://k8s-master:2379"
    KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=10.254.0.0/16"
    KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota"
    KUBE_API_ARGS=""
    apiserver

    启动etcd
    systemctl start etcd
    systemctl enable etcd
    创建网络
    etcdctl mkdir /kube-centos/network
    etcdctl mk /kube-centos/network/config "{"Network":"172.30.0.0/16","SubnetLen":24,"Backend":{"Type":"vxlan"}}"
    vim /etc/sysconfig/flanneld

    FLANNEL_ETCD_ENDPOINTS="http://k8s-master:2379"
    FLANNEL_ETCD_PREFIX="/kube-centos/network"
    flanneld

    服务启动:
    for SERVICES in etcd kube-apiserver kube-controller-manager kube-scheduler flanneld; do systemctl restart $SERVICES; systemctl enable $SERVICES; systemctl status $SERVICES; done

    安装 Kubernetes 环境 (Minion/Node):

    hosts配置 
    vim /etc/hosts 同Master配置
    yum -y install --enablerepo=virt7-docker-common-release kubernetes flannel
    vi /etc/kubernetes/config

    KUBE_LOGTOSTDERR="--logtostderr=true"
    KUBE_LOG_LEVEL="--v=0"
    KUBE_ALLOW_PRIV="--allow-privileged=false"
    KUBE_MASTER="--master=http://k8s-master:8080"
    config

    vi /etc/kubernetes/kubelet

    KUBELET_ADDRESS="--address=0.0.0.0"
    KUBELET_PORT="--port=10250"
    KUBELET_HOSTNAME="--hostname-override=k8s-node-1"
    KUBELET_API_SERVER="--api-servers=http://k8s-master:8080"
    KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"
    KUBELET_ARGS=""
    kubelet

    vi /etc/sysconfig/flanneld

    FLANNEL_ETCD_ENDPOINTS="http://k8s-master:2379"
    FLANNEL_ETCD_PREFIX="/kube-centos/network"
    flanneld

    服务启动:
    for SERVICES in kube-proxy kubelet flanneld docker; do systemctl restart $SERVICES; systemctl enable $SERVICES; systemctl status $SERVICES; done
    配置参数:
    kubectl config set-cluster default-cluster --server=http://k8s-master:8080
    kubectl config set-context default-context --cluster=default-cluster --user=default-admin
    kubectl config use-context default-context

  • 相关阅读:
    GNU make manual 翻译(九十九)
    GNU make manual 翻译( 九十五)
    Shell的 for 循环小例子
    makefile中对目录遍历的小例子
    GNU make manual 翻译(九十三)
    GNU make manual 翻译( 一百)
    GNU make manual 翻译( 九十七)
    GNU make manual 翻译( 九十八)
    mapserver4.8.3 的readme.win32的中文翻译文件
    遥控器编程
  • 原文地址:https://www.cnblogs.com/Mrhuangrui/p/7246101.html
Copyright © 2020-2023  润新知