k8s安装

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 [email protected]://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

[[email protected] ~]# 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(重要)

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

时间: 2024-10-08 20:58:57

k8s安装的相关文章

k8s安装 1.10.1

k8s版本 主机名 ip 配置 1.10 master 192.168.61.250 4C8G node1 192.168.61.251 4C8G node2 192.168.61.252 4C8G kubectl 命令补全 [email protected]:/# vim /etc/profile  #添加下面这句,再source source <(kubectl completion bash) [email protected]:/# source /etc/profile 修改主机名,时

k8s1.4.3安装实践记录(2)-k8s安装

前面一篇已经安装好了ETCD.docker与flannel(k8s1.4.3安装实践记录(1)),现在可以开始安装k8s了 1.K8S 目前centos yum上的kubernetes还是1.2.0,因此我们只能是使用下载的安装包,进行kubernetes的安装 [[email protected] system]# yum list |grep kubernetes cockpit-kubernetes.x86_64 0.114-2.el7.centos extras kubernetes.x

K8S安装部署在centos7下

所有节点操作 K8S的安装部署可以参考文档: 需要在每一台机器上执行的操作 l 各节点禁用防火墙 # systemctl stop firewalld # systemctl disable firewalld l 禁用SELINUX: # setenforce 0 # sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/g‘ /etc/selinux/config # SELINUX=disabled l 创建/etc/sysctl.d/k8s.conf文

k8s安装dashboard

1.Kubernetes Dashboard 是 k8s集群的?个 WEB UI管理?具,代码托管在 github 上,地址: https://github.com/kubernetes/dashboard 2.安装直接使用官方文件就行(如果地址失效去github 看一下) wget https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.

k8s安装之配置

配置 Configuration file details https://kubernetes.io/docs/reference/command-line-tools-reference/kube-apiserver/ Kubeconfig ###安装kubectl工具 wget https://dl.k8s.io/v1.11.0/kubernetes-client-linux-amd64.tar.gz tar -zxf kubernetes-client-linux-amd64.tar.g

k8s安装dashboard(未解决)

第一种,用helm安装 helm repo update Hang tight while we grab the latest from your chart repositories... ...Skip local chart repository ...Successfully got an update from the "stable" chart repository Update Complete. [root@k8s-master templates]# helm r

k8s安装nexus并导入第三方jar包

搭建k8s集群 Docker search nexus 编写yaml文件 注意,以下的service不是nodeport,而是LoadBalancer apiVersion: apps/v1kind: StatefulSetmetadata: name: nexus labels: app: nexusspec: serviceName: nexus replicas: 1 selector: matchLabels: app: nexus template: metadata: labels:

使用kubeadm离线下载k8s安装镜像

1.说明2.系统及软件版本3.安装kubeadm4.离线镜像5.打包镜像6.导入镜像 1.说明由于使用kubeadm安装 k8s 时需要从 k8s.gcr.io 拉取镜像,但是该网站被屏蔽了,国内没法正常访问导致无法正常进行k8s的安装.这里介绍从阿里云镜像平台拉取镜像并重新打tag的方式来绕过对 k8s.gcr.io 的访问. 2.系统及软件版本 # cat /etc/redhat-release CentOS Linux release 7.7.1908 (Core) # docker ve

Kubernetes(K8s) 安装(使用kubeadm安装Kubernetes集群)

概述: 这篇文章是为了介绍使用kubeadm安装Kubernetes集群(可以用于生产级别).使用了Centos 7系统. PS: 篇幅有点长,但是比较详细.比较全面 一.Centos7 配置说明 1.1   Firewalld(防火墙) CentOS Linux 7 默认开起来防火墙服务(firewalld),而Kubernetes的Master与工作Node之间会有大量的网络通信,安全的做法是在防火墙上配置Kbernetes各组件(api-server.kubelet等等)需要相互通信的端口