一.安裝前提條件node
1.關閉防火牆
#systemctl disable firewalld
#systemctl stop firewalldlinux
2.關閉selinux
#setenforce 0
#vi /etc/selinux/config
SELINUX=disabledgit
3.安裝docker 17.03.2
#yum install https://download.docker.com/linux/centos/7/x86_64/stable/Packages/docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch.rpm
#yum install docker-ce-17.03.2.ce-1.el7.centos
#systemctl enable docker
#systemctl start dockergithub
4.配置系統路由參數,防止kubeadm報路由警告
#echo "
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
" >> /etc/sysctl.conf
#sysctl -pdocker
5.下載k8s二進制文件(v1.9.0)版本
https://github.com/kubernetes/kubernetes/blob/master/CHANGELOG-1.9.md#v190
文件名:
kubernetes-server-linux-amd64.tar.gz 數據庫
6.下載etcd二進制文件(v3.3.5)版本centos
文件名:etcd-v3.3.5-linux-amd64.tar.gzapi
二.開始安裝 ide
reference: https://blog.csdn.net/chen798213337/article/details/78501042
https://blog.csdn.net/carter115/article/details/50986531ui
1.master節點操做
#############################部署etcd集羣數據庫##############################
#cp etcd etcdctl /usr/bin/
#vi /etc/etcd/etcd.conf
ETCD_NAME=ETCD Server
ETCD_DATA_DIR="/var/lib/etcd/"
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"
ETCD_ADVERTISE_CLIENT_URLS="http://172.16.68.11:2379"
建立/usr/lib/systemd/system/etcd.service系統服務
[Unit]
Description=Etcd Server
After=network.target
[Service]
Type=simple
WorkingDirectory=/var/lib/etcd
EnvironmentFile=-/etc/etcd/etcd.conf
ExecStart=/usr/bin/etcd
[Install]
WantedBy=multi-user.target
#############################部署kube-apiserver#############################
#cp kube-apiserver kube-controller-manager kube-scheduler kubectl /usr/bin/
#vi /etc/kubernetes/apiserver
KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0"
KUBE_API_PORT="--insecure-port=8080"
KUBE_ETCD_SERVERS="--etcd-servers=http://172.16.68.11:2379"
KUBE_SERVICE_ADDRESSES="--service-cluster-ip-range=169.169.0.0/16"
KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota"
KUBE_API_LOG="--logtostderr=false --log-dir=/var/log/kubernets --v=2"
KUBE_API_ARGS=" "
#建立/usr/lib/systemd/system/kube-apiserver.service系統服務
[Unit]
Description=Kubernetes API Server
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=etcd.service
Wants=etcd.service
[Service]
EnvironmentFile=/etc/kubernetes/apiserver
ExecStart=/usr/bin/kube-apiserver \
$KUBE_ETCD_SERVERS \
$KUBE_API_ADDRESS \
$KUBE_API_PORT \
$KUBE_SERVICE_ADDRESSES \
$KUBE_ADMISSION_CONTROL \
$KUBE_API_LOG \
$KUBE_API_ARGS
Restart=on-failure
Type=notify
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
#systemctl enable kube-apiserver
#systemctl start kube-apiserver
#############################部署kube-controller-manager#############################
建立/usr/lib/systemd/system/kube-controller-manager.service系統服務
[Unit]
Description=Kubernetes Controller Manager
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=kube-apiserver.service
Wants=kube-apiserver.service
[Service]
EnvironmentFile=-/etc/kubernetes/controller-manager
ExecStart=/usr/bin/kube-controller-manager \
$KUBE_MASTER \
$KUBE_CONTROLLER_MANAGER_ARGS
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
#vi /etc/kubernetes/controller-manager --建立配置文件
KUBE_MASTER="--master=http://172.16.68.11:8080"
KUBE_CONTROLLER_MANAGER_ARGS=" "
#systemctl enable kube-controller-manager
#systemctl start kube-controller-manager
#############################部署kube-scheduler#############################
建立/usr/lib/systemd/system/kube-scheduler.service系統服務
[Unit]
Description=Kubernetes Scheduler
After=kube-apiserver.service
Requires=kube-apiserver.service
[Service]
EnvironmentFile=-/etc/kubernetes/scheduler
ExecStart=/usr/bin/kube-scheduler \
$KUBE_MASTER \
$KUBE_SCHEDULER_ARGS
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
#vi /etc/kubernetes/scheduler --建立配置文件
KUBE_MASTER="--master=http://172.16.68.11:8080"
KUBE_SCHEDULER_ARGS="--logtostderr=false --log-dir=/var/log/kubernetes --v=2"
#systemctl enable kube-scheduler
#systemctl start kube-scheduler
##################至此,master上的全部服務配置啓動完成######################
2.node節點操做
#############################部署kubelet#############################
#cp /tmp/kubernetes/server/bin/kubelet kube-proxy /usr/bin/ 將二進制執行文件複製到/usr/bin下
#vi /etc/kubernetes/config
KUBE_LOGTOSTDERR="--logtostderr=false"
KUBE_LOG_LEVEL="--v=3"
KUBE_ALLOW_PRIV="--allow-privileged=false"
#vi /etc/kubernetes/kubelet
KUBELET_HOSTNAME="--hostname-override=172.16.68.11"
KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"
KUBELET_ARGS="--enable-server=true --enable-debugging-handlers=true --fail-swap-on=false --kubeconfig=/var/lib/kubelet/kubeconfig"
K8S 1.9版本中 kubelet須要注意, kubelet和apiserver鏈接方式改變,須要額外一個yaml的配置文件kubeconfig
#vi /var/lib/kubelet/kubeconfig
apiVersion: v1
kind: Config
users:
- name: kubelet
clusters:
- name: kubernetes
cluster:
server: http://172.16.68.11:8080
contexts:
- context:
cluster: kubernetes
user: kubelet
name: service-account-context
current-context: service-account-context
#建立/usr/lib/systemd/system/kubelet.service系統服務
[Unit]
Description=Kubernetes Kubelet Server
After=docker.service
Requires=docker.service
[Service]
WorkingDirectory=/var/lib/kubelet
EnvironmentFile=-/etc/kubernetes/config
EnvironmentFile=-/etc/kubernetes/kubelet
ExecStart=/usr/bin/kubelet \
$KUBE_LOGTOSTDERR \
$KUBE_LOG_LEVEL \
$KUBELET_HOSTNAME \
$KUBE_ALLOW_PRIV \
$KUBELET_POD_INFRA_CONTAINER \
$KUBELET_ARGS
Restart=on-failure
[Install]
WantedBy=multi-user.target
# systemctl enable kubelet
# systemctl start kubelet
#############################部署kube-proxy#############################
#vi /etc/kubernetes/proxy
KUBE_PROXY_ARGS="--master=http://172.16.68.11:8080"
s
#建立/usr/lib/systemd/system/kube-proxy.service系統服務
[Unit]
Description=Kubernetes Proxy
Documentation=https://github.com/GoogleCloudPlatform/kubernetes
After=network.target
[Service]
EnvironmentFile=-/etc/kubernetes/config
EnvironmentFile=-/etc/kubernetes/proxy
ExecStart=/usr/bin/kube-proxy \
$KUBE_LOGTOSTDERR \
$KUBE_LOG_LEVEL \
$KUBE_MASTER \
$KUBE_PROXY_ARGS
Restart=on-failure
LimitNOFILE=65536
[Install]
WantedBy=multi-user.target
#systemctl start kube-proxy#systemctl enable kube-proxy