Kubernetes v1.9.1スタンドアロンバージョンワンタッチインストールスクリプト


#!/bin/bash
# ----------------------------------------
# kubernetes v1.9.1  
#  
# CentOS 7.2.1511 OK
# Powered by Jerry Wong
# 2018-03-15 [email protected]
# ----------------------------------------

function get_local_ip() {
    IP_ADDR=`ip addr | grep inet | grep -Ev '127|inet6' | awk '{print $2}' | awk -F'/' '{print $1}'`
    export NODE_IP=${IP_ADDR}
}

function basic_settings() {
    getenforce  | grep Disabled > /dev/null
    if [ $? -ne 0 ]; then
        sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
    fi
    systemctl stop firewalld
    systemctl disable firewalld
}

function install_docker() {
    yum -y install yum-utils device-mapper-persistent-data lvm2
    yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
    yum -y install docker-ce

    systemctl start docker
    systemctl status docker
    systemctl enable docker

    #  ( ) 
    sed -i 's#ExecStart=/usr/bin/dockerd#ExecStart=/usr/bin/dockerd --registry-mirror=https://mirror.ccs.tencentyun.com#' /usr/lib/systemd/system/docker.service 
    systemctl daemon-reload
    systemctl restart docker
}

function install_etcd() {
    chmod +x etcd etcdctl
    mv etcd etcdctl /usr/bin/
}

#  Kubernetes
function install_kubernetes() {
    chmod +x kube*
    mv kube{ctl,-apiserver,-scheduler,-controller-manager,let,-proxy} /usr/bin/       

    #  
    kube-apiserver --version
}

#  flanneld
function install_flanneld() {
    chmod +x flanneld mk-docker-opts.sh
    mv flanneld /usr/bin/
    mkdir /usr/libexec/flannel/
    mv mk-docker-opts.sh /usr/libexec/flannel/

    #  
    flanneld --version
}

#  etcd
function config_etcd() {
cat > /usr/lib/systemd/system/etcd.service < /etc/etcd/etcd.conf < /etc/systemd/system/flanneld.service < /usr/bin/flanneld-start < /etc/sysconfig/flanneld < /etc/docker/daemon.json < /etc/kubernetes/config < /etc/systemd/system/kube-apiserver.service < /etc/kubernetes/apiserver < /etc/systemd/system/kube-controller-manager.service < /etc/kubernetes/controller-manager < /usr/lib/systemd/system/kube-scheduler.service < /etc/kubernetes/scheduler < /usr/lib/systemd/system/kubelet.service < "${KUBECONFIG_DIR}/kubelet.kubeconfig" < /etc/kubernetes/kubelet < /etc/systemd/system/kube-proxy.service < /etc/kubernetes/proxy < kube-dns.yaml < heapster-rbac.yaml < grafana.yaml < heapster.yaml < influxdb.yaml < kubernetes-dashboard.yaml <

アクセスkubernetes-dashboardhttp://localhost:8080/api/v1/namespaces/kube-system/services/kubernetes-dashboard/proxy/
文書に含まれるファイルリンク:https://share.weiyun.com/229533b44fef0ba8506d8073a76cc426パスワード:fmkczc