纯手搭建kubernetes1.9.1,

环境:Ubuntu16.04 

kubernetes1.9.1:
client:
wget https://storage.googleapis.com/kubernetes-release/release/v1.9.1/kubernetes-client-linux-amd64.tar.gz

server:
wget https://storage.googleapis.com/kubernetes-release/release/v1.9.1/kubernetes-server-linux-amd64.tar.gz

node:
wget https://storage.googleapis.com/kubernetes-release/release/v1.9.1/kubernetes-node-linux-amd64.tar.gz

etcd:
wget https://github.com/coreos/etcd/releases/download/v3.1.10/etcd-v3.1.10-linux-amd64.tar.gz

flannel:
wget https://github.com/coreos/flannel/releases/download/v0.10.0/flannel-v0.10.0-linux-amd64.tar.gz


安装curl docker


配置docker(非必要)
--insecure-registry=MasterIP/32
--insecure-registry=0.0.0.0/0 --registry-mirror=https://wndy1wmh.mirror.aliyuncs.com

拷贝二进制到/usr/bin/

$启动etcd
etcd单点启动:
sudo etcd --name etcd \
          --data-dir /infra.etcd \
          --advertise-client-urls http://10.156.230.185:2379 \
          --listen-client-urls http://0.0.0.0:2379 \
          >/tmp/etcd.log 2>&1 &


etcd集群启动:                                                                 
/etcd --name $ETCD_NAME \
      --initial-cluster-token dtdream-ht706 \
      --data-dir /infra.etcd \
      --initial-cluster-state new \
      --initial-cluster $ETCD_CLUSTER \
      --initial-advertise-peer-urls $PEER_URL\
      --listen-peer-urls http://0.0.0.0:2380 \
      --advertise-client-urls $CLIENT_URL \
      --listen-client-urls http://0.0.0.0:2379


etcd端口:2379
etcd数据库测试
curl -L http://10.156.230.185:2379/v2/keys/coreos.com/network/config


curl -L http://10.156.230.185:2379/v2/keys/coreos.com/network/config -XPUT -d value="{\"Network\":\"172.16.0.0/16\", \"Backend\": {\"Type\": \"vxlan\"}}"

$启动ApiServer:
生成秘钥: sudo openssl genrsa -out /etc/kube-serviceaccount.key 2048 2>/dev/null

sudo kube-apiserver --insecure-bind-address=0.0.0.0 \
                --insecure-port=8080 \
                --etcd-servers=http://127.0.0.1:2379 \
                --logtostderr=true \
                --allow-privileged=true \
                --service-cluster-ip-range=192.168.1.0/24 \
                --admission-control=NamespaceLifecycle,LimitRanger,ResourceQuota,SecurityContextDeny \
                --service-node-port-range=30000-40000 \
                --advertise-address=10.156.230.185 \
                >/tmp/kube-apiserver.log 2>&1 &

创建Namespace(namespace.yaml):非必要
-------
apiVersion: v1  
kind: Namespace  
metadata:  
  name: kube-system  
--------
kubectl create -f namespace.yaml


$启动controller-manager

sudo kube-controller-manager --master=10.156.230.185:8080 \
                             --service-account-private-key-file=/etc/kube-serviceaccount.key \
                             >/tmp/kube-controller-manager.log 2>&1 &



$启动scheduler
sudo kube-scheduler --master=10.156.230.185:8080 \
                    >/tmp/kube-scheduler.log 2>&1 &
     


$启动flanneld
sudo flanneld --etcd-endpoints=http://10.156.230.185:2379 \
              --ip-masq \
              --iface=10.156.230.185 \
              --subnet-file=/run/flannel_subnet.env \
              >/tmp/flanneld.log 2>&1 &
              
查看 /run/flannel_subnet.env 配置docker重启
--bip=${FLANNEL_SUBNET} --mtu=${FLANNEL_MTU}
--bip=172.16.39.1/24 --mtu=1450




$启动kube-proxy
sudo kube-proxy --hostname-override=10.156.230.185 \
                --master=http://10.156.230.185:8080 \
                >/tmp/kube-proxy.log 2>&1 &



$启动kubelet
增加:vim /etc/default/kubelet.config
apiVersion: v1
kind: Config
clusters:
  - cluster:
      server: http://127.0.0.1:8080/
    name: local
contexts:
  - context:
      cluster: local
    name: local
current-context: local


sudo kubelet  --hostname-override=10.156.230.185 \
              --kubeconfig=/etc/default/kubelet.config \
              --allow-privileged=true \
              --cluster-dns=192.168.1.10 \
              --runtime-cgroups=/systemd/system.slice \
              --kubelet-cgroups=/systemd/system.slice \
              --image-gc-high-threshold=85 \
              --image-gc-low-threshold=80 \
              --minimum-image-ttl-duration=1h \
              --fail-swap-on=false \
              --node-labels=zone=controller \
              --pod-infra-container-image=kubernetes/pause \
              --cluster-domain=cluster.local \
              >/tmp/kubelet.log 2>&1 &









































你可能感兴趣的:(纯手搭建kubernetes1.9.1,)