码迷,mamicode.com
首页 > 其他好文 > 详细

k8s安装

时间:2019-09-01 21:36:18      阅读:127      评论:0      收藏:0      [点我收藏+]

标签:pause   version   grep -E   blog   rgs   lun   ystemd   docker   set   

k8s安装:
cat /etc/hosts
127.0.0.1 localhost
10.26.3.182 kuber-node1
10.26.3.184 kuber-master
1、关闭防火墙
systemctl stop firewalld.service
2、关闭selinux
setenforce 0
3.创建/etc/sysctl.d/k8s.conf文件,添加如下内容:
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
4.
cat > /etc/sysconfig/modules/ipvs.modules <<EOF
#!/bin/bash
modprobe -- ip_vs
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- ip_vs_sh
modprobe -- nf_conntrack_ipv4
EOF
chmod 755 /etc/sysconfig/modules/ipvs.modules && bash /etc/sysconfig/modules/ipvs.modules && lsmod | grep -e ip_vs -e nf_conntrack_ipv4
5.安装docker的yum源:
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo

yum makecache fast
yum install -y --setopt=obsoletes=0 docker-ce-18.06.1.ce-3.el7
systemctl start docker
systemctl enable docker

6.
cat <<EOF > /etc/yum.repos.d/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
EOF
7.安装kubelet kubeadm klubectl 【master和node都需要执行】
yum makecache fast
yum install -y kubelet kubeadm kubectl
systemctl enable kubelet.service
8.vi push.sh
主节点初始化
初始化的时候,需要×××下载镜像,可以使用下面脚本下载镜像

echo ""
echo "=========================================================="
echo "Pull Kubernetes v1.14.1 Images from aliyuncs.com ......"
echo "=========================================================="
echo ""
MY_REGISTRY=registry.cn-hangzhou.aliyuncs.com/openthings
## 拉取镜像
docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-apiserver:v1.14.1
docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-controller-manager:v1.14.1
docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-scheduler:v1.14.1
docker pull ${MY_REGISTRY}/k8s-gcr-io-kube-proxy:v1.14.1
docker pull ${MY_REGISTRY}/k8s-gcr-io-etcd:3.3.10
docker pull ${MY_REGISTRY}/k8s-gcr-io-pause:3.1
docker pull ${MY_REGISTRY}/k8s-gcr-io-coredns:1.3.1
## 添加Tag
docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-apiserver:v1.14.1 k8s.gcr.io/kube-apiserver:v1.14.1
docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-scheduler:v1.14.1 k8s.gcr.io/kube-scheduler:v1.14.1
docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-controller-manager:v1.14.1 k8s.gcr.io/kube-controller-manager:v1.14.1
docker tag ${MY_REGISTRY}/k8s-gcr-io-kube-proxy:v1.14.1 k8s.gcr.io/kube-proxy:v1.14.1
docker tag ${MY_REGISTRY}/k8s-gcr-io-etcd:3.3.10 k8s.gcr.io/etcd:3.3.10
docker tag ${MY_REGISTRY}/k8s-gcr-io-pause:3.1 k8s.gcr.io/pause:3.1
docker tag ${MY_REGISTRY}/k8s-gcr-io-coredns:1.3.1 k8s.gcr.io/coredns:1.3.1
echo ""
echo "=========================================================="
echo "Pull Kubernetes v1.14.1 Images FINISHED."
echo "into registry.cn-hangzhou.aliyuncs.com/openthings, "
echo " by openthings@https://my.oschina.net/u/2306127."
echo "=========================================================="
echo ""

9.我们现在要把kuber-node1 添加进来了。
在kuber-node1上输入以下命令
每个token只有24小时的有效期,如果没有有效的token,可以使用如下命令创建
kubeadm token create
获取token:
master:kubeadm token list 2ubuk7.357s4vsfxdyqw1kz
Kubernetes认证的SHA256加密字符串是多少,这里可以使用这个命令查看到:openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed ‘s/^.* //‘
9725bcd4fc6bc7bb0dfaf7781da359eb607deb2f642cf2bfdfb5d1f951fa75ea

[root@kuber-node1 ~]# kubeadm join 139.159.27.18:6443 --token 2ubuk7.357s4vsfxdyqw1kz--discovery-token-ca-cert-hash sha256:9725bcd4fc6bc7bb0dfaf7781da359eb607deb2f642cf2bfdfb5d1f951fa75ea


打印node中日志 journalctl -f
kubectl get nodes

1 ip a
2 docker ps
3 ls
4 ll
11 kubeadm init --kubernetes-version=v1.14.1 --apiserver-advertise-address=139.159.27.62 --pod-network-cidr=10.244.0.0/16 --ignore-preflight-errors=Swap
12 echo ‘Environment="KUBELET_EXTRA_ARGS=--fail-swap-on=false"‘ >> /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
13 kubeadm init --kubernetes-version=v1.14.1 --apiserver-advertise-address=139.159.27.62 --pod-network-cidr=10.244.0.0/16 --ignore-preflight-errors ‘Swap‘
14 kubeadm init --kubernetes-version=v1.14.1 --apiserver-advertise-address=139.159.27.62 --pod-network-cidr=10.244.0.0/16 --ignore-preflight-errors=‘Swap‘
15 swapoff -a
16 kubeadm init --kubernetes-version=v1.14.1 --apiserver-advertise-address=139.159.27.62 --pod-network-cidr=10.244.0.0/16 --ignore-preflight-errors=‘Swap‘
17 kubeadm init --kubernetes-version=v1.14.1 --apiserver-advertise-address=139.159.27.62 --pod-network-cidr=10.244.0.0/16
18 ip a
19 kubeadm init --apiserver-advertise-address=139.159.27.62 --pod-network-cidr=139.159.0.0/29 -ignore-preflight-errors ‘Swap‘
20 kubeadm init --apiserver-advertise-address=139.159.27.62 --pod-network-cidr=139.159.0.0/29 --ignore-preflight-errors ‘Swap‘
21* kubeadm init --apiserver-advertise-address=139.159.27.62 --pod-network-cidr=139.159.0.0 --ignore-preflight-errors ‘Swap‘
24 systemctl stop firewalld
25 setenforce 0
26 systemctl disable firewalld
27 kubeadm init --apiserver-advertise-address=139.159.27.62 --pod-network-cidr=139.159.0.0/24 --ignore-preflight-errors ‘Swa
kubeadm init --apiserver-advertise-address=139.159.27.62 --pod-network-cidr=139.159.0.0/29 -ignore-preflight-errors ‘Swap‘
28 kubeadm init --apiserver-advertise-address=139.159.27.62 --pod-network-cidr=139.159.0.0/24 --ignore-preflight-errors ‘Swap‘
29 ping packages.cloud.google.com
30 kubeadm init --apiserver-advertise-address=139.159.27.62 --pod-network-cidr=139.159.0.0/24 --ignore-preflight-errors ‘Swap‘
31 vi /etc/yum.repos.d/kubernetes.repo
32 kubeadm config images pull
33 docker iamges
34 docker images
35 kubeadm init --apiserver-advertise-address=139.159.27.62 --pod-network-cidr=10.244.0.0/16 --ignore-preflight-errors ‘Swap‘
36 docker images
37 kubeadm init
41 docker Images
42 docker images
43 docker version
44 kubeadm init --kubernetes-version=v1.40 --pod-network-cidr=10.244.0.0/16
45 kubeadm init --kubernetes-version=v1.12 --pod-network-cidr=10.244.0.0/16
46 kubeadm init --kubernetes-version=v1.15.3 --pod-network-cidr=10.244.0.0/16
47 kubectl nodes
48 kubelet nodes
49 kubelet node
50 kubectl get nodes
51 ls
52 kubeadm init --apiserver-advertise-address=139.159.27.62 --image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.15.3 --pod-network-cidr=10.244.0.0/16
53 netstat -tlunp
54 yum -y install net-tools
55 netstat -tlunp
56 docker ps
57 ls
58 ll
59 mkdir -p $HOME/.kube
60 cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
61 chown $(id -u):$(id -g) $HOME/.kube/config
62 kubectl get nodes
63 ip a
64 kubectl get nodes
65 ip a
66 ls
67 ll
68 hisotry
69 history
70 history > history.txt
https://www.cnblogs.com/panwenbin-logs/p/9866109.html
https://blog.51cto.com/nhylovezyh/2377982(重要)

k8s安装

标签:pause   version   grep -E   blog   rgs   lun   ystemd   docker   set   

原文地址:https://www.cnblogs.com/zpaixx/p/11443525.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!