centos7의kubernetes 집단 구축

6424 단어 서버

 


kubeadm 기반 Kubernetes 클러스터 구축


1 모든 노드가 구성해야 하는 작업


1.1 방화벽 닫기

# systemctl stop firewalld
# systemctl disable firewalld

1.2 selinux 닫기

# sed -i 's/enforcing/disabled/' /etc/selinux/config

1.3 swap 사용 안 함

# swapoff -a
# vim /etc/fstab
		#  swap , 

1.3 호스트 이름 및 /etc/hosts 파일 수정

# hostnamectl set-hostname {k8s-m|k8s-node1|k8s-node2}
# vim /etc/hosts
10.120.10.190   k8s-m
10.120.10.191   k8s-node1
10.120.10.192   k8s-node2
10.120.10.193   k8s-node3

1.4 호스트 재부팅

# reboot

1.5 라우팅 전달 켜기

# echo "net.ipv4.ip_forward = 1">>/etc/sysctl.conf
# sysctl -p

1.6 창고를 아리운 창고로 설치

# cd /etc/yum.repos.d/
# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup # 
# wget -O /etc/yum.repos.d/CentOS-Base.repo  http://mirrors.aliyun.com/repo/Centos-7.repo
# yum clean all
# yum makecache
# yum install -y epel-release

1.7 Docker의 Ali운 yum 설치 소스를 구성하고 설치

# cd /etc/yum.repos.d/
# wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# yum clean all
# yum makecache

1.8 각 노드에docker-ce-18.06.0을 설치하고 전원을 켜서 시작합니다.

# yum install docker-ce-18.06.2.ce
# docker -v
# systemctl start docker
# systemctl enable docker
# systemctl status docker

1.9 bridge-nf-call-iptables 및 bridge-nf-call-ip6tables 활성화

# echo 'net.bridge.bridge-nf-call-iptables = 1'>>/etc/sysctl.conf
# echo 'net.bridge.bridge-nf-call-ip6tables = 1'>>/etc/sysctl.conf
# sysctl -p

1.10 쿠버넷의 아리운 apt 설치원 설정

# vim /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
# yum clean all
# yum makecache

1.11 각 노드에kubeadm,kubelet,kubectl을 설치하고 kubelet을 설치하여 시작합니다

# yum install kubelet-1.12.1-0 kubeadm-1.12.1-0 kubectl-1.12.1-0
# kubeadm version
# systemctl enable kubelet

2 마스터 노드:


2.1 kube-apiserver,kube-proxy 등kubernetes1.12.1 버전의docker 렌즈 가져오기

docker pull registry.aliyuncs.com/google_containers/coredns:1.2.2
docker tag be0e8485fd78 k8s.gcr.io/coredns:1.2.2
docker pull registry.aliyuncs.com/google_containers/etcd:3.2.24
 docker tag dcf9f4b0065d k8s.gcr.io/etcd:3.2.24
docker pull registry.aliyuncs.com/google_containers/pause:3.1
docker tag 97bc1dcec76a k8s.gcr.io/pause:3.1
docker pull registry.aliyuncs.com/google_containers/kube-apiserver:v1.12.1
docker tag dcb029b5e3ad k8s.gcr.io/kube-apiserver:v1.12.1
docker pull registry.aliyuncs.com/google_containers/kube-controller-manager:v1.12.1
docker tag aa2dd57c7329 k8s.gcr.io/kube-controller-manager:v1.12.1
docker pull registry.aliyuncs.com/google_containers/kube-proxy:v1.12.1
docker tag 68987659c19a k8s.gcr.io/kube-proxy:v1.12.1
docker pull registry.aliyuncs.com/google_containers/kube-scheduler:v1.12.1
docker tag af194c06e677 k8s.gcr.io/kube-scheduler:v1.12.1
docker pull quay-mirror.qiniu.com/coreos/flannel:v0.10.0-amd64
docker tag f0fad859c909 quay.io/coreos/flannel:v0.10.0-amd64

2.2 마스터 초기화

# kubeadm init --kubernetes-version=1.12.1 --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=10.120.10.190
##  , :
Your Kubernetes master has initialized successfully!

To start using your cluster, you need to run the following as a regular user:

  mkdir -p $HOME/.kube
  sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
  sudo chown $(id -u):$(id -g) $HOME/.kube/config

You should now deploy a pod network to the cluster.
Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at:
  https://kubernetes.io/docs/concepts/cluster-administration/addons/

You can now join any number of machines by running the following on each node
as root:

  kubeadm join 10.120.10.190:6443 --token d4557c.fh4vjxkiyoj2zt5y --discovery-token-ca-cert-hash sha256:b17d4618ab1149934f69582c727f58e53cd51f89dd9844fd3f7b776a0e3d389a

2.3 마스터 노드는 루트 사용자 관리 그룹을 구성합니다.


2.3.1 루트 사용자를 사용하여kubernetes 실행
# mkdir -p $HOME/.kube
# sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config

2.3.2 다운로드 flannel 파일 다운로드 경로https://download.csdn.net/download/twjjava/12458299
flannel 설치
kubectl apply -f kube-flannel.yml

 
2.3.3 클러스터 상태 보기
# kubectl get nodes

3 Node 노드:


3.1 kube-proxy,pause,flannel,kubernetes1.12.1 버전의 docker 렌즈 가져오기

##  :(\\10.120.1.100\ \Kubernetes-1.12.1\kubernetes-1.12.1 \ " ")
docker pull registry.aliyuncs.com/google_containers/kube-proxy:v1.12.1
docker pull registry.aliyuncs.com/google_containers/pause:3.1
docker pull quay-mirror.qiniu.com/coreos/flannel:v0.10.0-amd64
kubeadm init --kubernetes-version=1.12.1 --pod-network-cidr=10.244.0.0/16 --apiserver-advertise-address=192.168.192.128

3.1 마스터 노드 가입:

kubeadm join 10.120.10.190:6443 --token s5gi75.o950l49ripas5e0y --discovery-token-ca-cert-hash sha256:b17d4618ab1149934f69582c727f58e53cd51f89dd9844fd3f7b776a0e3d389a

3.1 마스터에서 클러스터 상태 보기

# kubectl get nodes

좋은 웹페이지 즐겨찾기