k8s集群部署


安装docker

 sudo yum install -y docker-ce-20.10.14 docker-ce-cli-20.10.14 containerd.io

 systemctl enable docker &&  systemctl start docker

cat <<EOF > /etc/docker/daemon.json
{
  "registry-mirrors": [
   "自己的阿里云容器加速地址",
    "http://hub-mirror.c.163.com",
    "https://docker.mirrors.ustc.edu.cn",
    "https://registry.docker-cn.com"
  ],
  "exec-opts": ["native.cgroupdriver=systemd"]
}
EOF

设置阿里云k8s地址
cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
br_netfilter
EOF

cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF

sudo sysctl --system


cat <<EOF > /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
EOF


 
yum install -y --nogpgcheck kubelet-1.21.11 kubeadm-1.21.11 kubectl-1.21.11

systemctl enable kubelet && systemctl start kubelet

kubeadm config images list



运行 master_images.sh   先下载好image
#!/bin/bash

images=(
    kube-apiserver:v1.21.11
    kube-controller-manager:v1.21.11
    kube-scheduler:v1.21.11
    kube-proxy:v1.21.11
    pause:3.4.1
    etcd:3.4.13-0
    coredns/coredns:v1.8.0
)

for imageName in ${images[@]} ; do
    docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/$imageName
done


kubeadm init \
--apiserver-advertise-address=192.168.56.11 \
--image-repository registry.cn-hangzhou.aliyuncs.com/google_containers \
--kubernetes-version   v1.21.11 \
--service-cidr=10.96.0.0/16  \
--pod-network-cidr=10.244.0.0/16


flannel插件
kubectl apply -f https://raw.githubusercontent.com/flannel-io/flannel/master/Documentation/kube-flannel.yml
kubectl apply -f kube-flannel.yml

openebs

kubectl apply -f https://openebs.github.io/charts/openebs-operator.yaml
kubectl create ns openebs
 kubectl apply -f openebs-operator.yaml
 kubectl get sc
kubectl patch storageclass openebs-hostpath -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
 
kubeadm join 192.168.56.11:6443 --token akjnrr.2x2dv28vqzf7emzi \
        --discovery-token-ca-cert-hash sha256:46cfe99dc7dc26dda8b208383cfc84e776d7ef74673065ce86c2fd337bdda845



kubectl apply -f https://github.com/kubesphere/ks-installer/releases/download/v3.1.1/kubesphere-installer.yaml
   
kubectl apply -f https://github.com/kubesphere/ks-installer/releases/download/v3.1.1/cluster-configuration.yaml


kubectl logs -n kubesphere-system $(kubectl get pod -n kubesphere-system -l app=ks-install -o jsonpath='{.items[0].metadata.name}') -f

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值