systemctl stop firewalld
systemctl disable firewalld
setenforce 0
vim /etc/selinux/config
SELINUX=disabled
echo "192.168.1.33 centos-master" >> /etc/hosts
echo "192.168.1.134 centos-minion " >> /etc/hosts
ping centos-minion
ping centos-master
cd /etc/yum.repos.d
vim kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=0
repo_gpgcheck=0
gpgkey=http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
yum -y install kubernetes flannel
vim /etc/kubernetes/config
# How the controller-manager, scheduler, and proxy find the apiserver
KUBE_MASTER="--master=http://centos-master:8080"
vim /etc/sysconfig/flanneld
FLANNEL_ETCD_ENDPOINTS="http://centos-master:2379"
yum install etcd -y
vi /etc/etcd/etcd.conf
ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379,http://0.0.0.0:4001"
ETCD_ADVERTISE_CLIENT_URLS="http://centos-master:2379,http://centos-master:4001"
systemctl start etcd
etcdctl set testdir/testkey0 0
etcdctl get testdir/testkey0
etcdctl -C http://etcd:4001 cluster-health
etcdctl -C http://etcd:2379 cluster-health
etcdctl mk /atomic.io/network/config '{ "Network": "10.0.0.0/16" }'
Master节点上
vim /etc/kubernetes/apiserver
# The address on the local server to listen to.
KUBE_API_ADDRESS="--address=0.0.0.0"
KUBE_API_PORT="--port=8080"
# Comma separated list of nodes in the etcd cluster
KUBE_ETCD_SERVERS="--etcd_servers=http://127.0.0.1:2379"
KUBE_ADMISSION_CONTROL="-admission_control=NamespaceLifecycle,NamespaceExists,LimitRanger,Secu rityContextDeny,ResourceQuota"
systemctl restart etcd kube-apiserver kube-scheduler kube-controller-manager flanneld
systemctl enable etcd kube-apiserver kube-scheduler kube-controller-manager flanneld
systemctl status etcd kube-apiserver kube-scheduler kube-controller-manager flanneld
ps -ef|grep kube
vim /etc/kubernetes/kubelet
###
# kubernetes kubelet (minion) config
KUBELET_ADDRESS="--address=0.0.0.0"
KUBELET_PORT="--port=10250"
KUBELET_HOSTNAME="--hostname_override=centos-minion"
KUBELET_API_SERVER="--api_servers=http://centos-master:8080"
# Add your own!
KUBELET_ARGS=""
vim /etc/sysconfig/docker
linux的内核中的SELinux不支持 overlay2 graph driver ,在docker里禁用selinux,–selinux-enabled=false
systemctl restart kube-proxy kubelet docker flanneld
systemctl enable kube-proxy kubelet docker flanneld
systemctl status kube-proxy kubelet docker flanneld
tail -f /var/log/messages |grep kube
kubectl get nodes
kubectl cluster-info
vi nginx-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
containers:
- name: nginx
image: nginx
ports:
- containerPort: 80
kubectl create -f nginx-pod.yaml
kubectl get pods
bug
解决k8s出现pod服务一直处于ContainerCreating状态的问题的过程
从节点上执行
yum remove *rhsm* -y
wget http://mirror.centos.org/centos/7/os/x86_64/Packages/python-rhsm-certificates-1.19.10-1.el7_4.x86_64.rpm
rpm2cpio python-rhsm-certificates-1.19.10-1.el7_4.x86_64.rpm | cpio -iv --to-stdout ./etc/rhsm/ca/redhat-uep.pem | tee /etc/rhsm/ca/redhat-uep.pem