k8s实战

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

etcd -name etcd  -data-dir /var/lib/etcd -listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 -advertise-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001 >> /var/log/etcd.log 2>&1 &

[root@mhc1 etcd-v2.2.0-linux-amd64]# etcdctl -C http://etcd:4001 cluster-health
member ce2a822cea30bfca is healthy: got healthy result from http://0.0.0.0:2379
cluster is healthy

wget https://github.com/kubernetes/kubernetes/releases/download/v1.1.1/kubernetes.tar.gz

 ./kube-apiserver --logtostderr --v=0 --etcd_servers=http://etcd:4001 --insecure-bind-address=0.0.0.0 --insecure-port=8080 --service-cluster-ip-range=10.254.0.0/16 >> /var/log/kube-apiserver.log 2>&1 &

./kube-controller-manager --logtostderr --v=0 --master=http://kube-master:8080 >> /var/log/kube-controller-manager.log 2>&1 &

./kube-scheduler --logtostderr --v=0 --master=http://kube-master:8080 >> /var/log/kube-scheduler.log 2>&1 &

./kubelet --logtostderr=true --v=0 --config=/etc/kubernetes/manigests --address=0.0.0.0 --api-servers=http://kube-master:8080 >> /var/log/kubelet.log 2>&1 &

./kube-proxy --logtostderr --v=0 --master=http://kube-master:8080 >> /var/log/kube-proxy.log 2>&1 &

./kubelet --logtostderr=true --v=0 --config=/etc/kubernetes/manigests --address=0.0.0.0 --api-servers=http://kube-master:8080 --cluster-dns=10.254.10.2 --cluster-domain=cluster.local   >> /var/log/kubelet.log 2>&1 &

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

flanneld -etcd-endpoints=http://etcd:4001 >> /var/log/flanneld.log 2>&1 &

[root@mhc flannel-0.5.4]# iptables -t nat -F
[root@mhc flannel-0.5.4]# ifconfig docker0 down
[root@mhc flannel-0.5.4]# brctl delbr docker0
[root@mhc flannel-0.5.4]# source /run/flannel/subnet.env

[root@mhc sysconfig]# echo $FLANNEL_SUBNET
10.0.54.1/24
[root@mhc sysconfig]# echo ${FLANNEL_MTU}
1472

[root@mhc sysconfig]# vim /lib/systemd/system/docker.service

[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target
Wants=docker-storage-setup.service
Requires=docker-cleanup.timer

[Service]
Type=notify
NotifyAccess=all
EnvironmentFile=-/run/containers/registries.conf
EnvironmentFile=-/etc/sysconfig/docker
EnvironmentFile=-/etc/sysconfig/docker-storage
EnvironmentFile=-/etc/sysconfig/docker-network
Environment=GOTRACEBACK=crash
Environment=DOCKER_HTTP_HOST_COMPAT=1
Environment=PATH=/usr/libexec/docker:/usr/bin:/usr/sbin
ExecStart=/usr/bin/dockerd-current
--add-runtime docker-runc=/usr/libexec/docker/docker-runc-current
--default-runtime=docker-runc
--exec-opt native.cgroupdriver=systemd
--userland-proxy-path=/usr/libexec/docker/docker-proxy-current
$OPTIONS
$DOCKER_STORAGE_OPTIONS
$DOCKER_NETWORK_OPTIONS
$ADD_REGISTRY
$BLOCK_REGISTRY
$INSECURE_REGISTRY
$REGISTRIES
-H unix:///var/run/docker.sock -H tcp://0.0.0.0:2375
--bip=10.0.54.1/24 --mtu=1472

[root@mhc sysconfig]# systemctl daemon-reload
[root@mhc sysconfig]# systemctl restart docker.service

原文地址:https://www.cnblogs.com/mhc-fly/p/7631701.html