k8s 集群搭建 kubernetes v1.5
基于yum 安装可以参考上一篇文章yum源配置节点:master: 10.10.1.104node1: 10.10.1.105node2: 10.10.1.106一初始化 所有节点操作cat /etc/hosts10.10.1.104master10.10.1.105node110.10.1.106node2 61.91.161.217 googl
基于yum 安装 可以参考上一篇文章yum源配置
节点:
master: 10.10.1.104
node1: 10.10.1.105
node2: 10.10.1.106
一 初始化 所有节点操作
cat /etc/hosts
10.10.1.104 master
10.10.1.105 node1
10.10.1.106 node2
61.91.161.217 google.com
61.91.161.217 gcr.io
61.91.161.217 www.gcr.io
61.91.161.217 console.cloud.google.com
61.91.161.217 storage.googleapis.com
vi /etc/selinux/config
SELINUX=permissive
setenforce 0
systemctl stop firewalld
systemctl disable firewalld
二 安装kubernetes
yum -y install kubernetes etcd flannel 所有节点
配置下docker
cat /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target docker-containerd.service
Wants=docker-storage-setup.service
Requires=docker-containerd.service rhel-push-plugin.socket
[Service]
Type=notify
EnvironmentFile=-/etc/sysconfig/docker
EnvironmentFile=-/etc/sysconfig/docker-storage
EnvironmentFile=-/etc/sysconfig/docker-network
Environment=GOTRACEBACK=crash
ExecStart=/usr/bin/dockerd-current \
–add-runtime oci=/usr/libexec/docker/docker-runc-current \
–log-driver=syslog \
–default-runtime=oci \
–registry-mirror=https://8l5bep5r.mirror.aliyuncs.com \
–authorization-plugin=rhel-push-plugin \
–containerd /run/containerd.sock \
–exec-opt native.cgroupdriver=systemd \
–userland-proxy-path=/usr/libexec/docker/docker-proxy-current \
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
TimeoutStartSec=0
Restart=on-abnormal
[Install]
WantedBy=multi-user.target
vi /etc/sysconfig/docker
OPTIONS=’–selinux-enabled –log-driver=journald –graph=/data/env/docker –insecure-registry 私有仓库地址
mkdir -p /data/env/docker
systemctl enable docker && systemctl restart docker
systemctl status docker
三 配置kubernetes
所有节点配置
vi /etc/kubernetes/config
KUBE_ETCD_SERVERS=”–etcd-servers=http://10.10.1.104:2379”
KUBE_LOGTOSTDERR=”–logtostderr=true”
KUBE_LOG_DIR=”–log-dir=/data/logs/kubernetes”
KUBE_LOG_LEVEL=”–v=1”
KUBE_ALLOW_PRIV=”–allow-privileged=false”
KUBE_MASTER=”–master=http://10.10.1.104:8080”
master 配置:
vi /etc/etcd/etcd.conf
[member]
ETCD_NAME=default
ETCD_DATA_DIR=”/var/lib/etcd/default.etcd”
ETCD_LISTEN_CLIENT_URLS=”http://0.0.0.0:2379”
[cluster]
ETCD_ADVERTISE_CLIENT_URLS=”http://0.0.0.0:2379”
vi /etc/kubernetes/apiserver
KUBE_API_ADDRESS=”–address=0.0.0.0”
KUBE_ETCD_SERVERS=”–etcd-servers=http://10.10.1.104:2379”
KUBE_SERVICE_ADDRESSES=”–service-cluster-ip-range=10.254.0.0/16”
KUBE_ADMISSION_CONTROL=”–admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota”
KUBE_API_ARGS=”“
systemctl start etcd
etcdctl mkdir /kube-centos/network
etcdctl mk /kube-centos/network/config “{ \”Network\”: \”172.20.0.0/16\”, \”SubnetLen\”: 24, \”Backend\”: { \”Type\”: \”vxlan\” } }”
vi /etc/sysconfig/flanneld
FLANNEL_ETCD_ENDPOINTS=”http://10.10.1.104:2379”
FLANNEL_ETCD_PREFIX=”/kube-centos/network”
systemctl restart etcd kube-apiserver kube-controller-manager kube-scheduler flanneld
systemctl enable etcd kube-apiserver kube-controller-manager kube-scheduler flanneld
node 节点配置
vi /etc/kubernetes/kubelet
KUBELET_ADDRESS=”–address=0.0.0.0”
KUBELET_HOSTNAME=”–hostname-override=node1”
KUBELET_API_SERVER=”–api-servers=http://10.10.1.104:8080”
KUBELET_ARGS=”“
vi /etc/sysconfig/flanneld
FLANNEL_ETCD_ENDPOINTS=”http://10.10.1.104:2379”
FLANNEL_ETCD_PREFIX=”/kube-centos/network”
systemctl restart kube-proxy kubelet flanneld docker
systemctl enable kube-proxy kubelet flanneld docker
ps -ef | grep kube
master 操作
kubectl cluster-info
kubectl get nodes
NAME STATUS AGE
node1 Ready 45d
node2 Ready 45d
ok
更多推荐
所有评论(0)