Ubuntu下一键脚本部署k8s,代码如下

# 基于kebuadm 1.21#!/bin/bashdocker_install(){apt install apt-transport-https ca-certificates curl software-properties-common -y ; apt update -y ; apt install apt-transport-https ca-certificates curl software-properties-common -yapt install -y docker.iosudo mkdir -p /etc/dockercat > /etc/docker/daemon.json < /etc/sysctl.d/k8s.conf </etc/apt/sources.list.d/kubernetes.list /etc/sysctl.confsysctl -piptables -P FORWARD ACCEPTcurl -s https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | apt-key add -cat </etc/apt/sources.list.d/kubernetes.listdeb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial mainEOFapt update -yapt-get install -y kubelet=1.21.0-00 kubeadm=1.21.0-00 kubectl=1.21.0-00MY_REGISTRY=registry.aliyuncs.com/google_containersK8S_VERSION="1.21.0"docker pull ${MY_REGISTRY}/kube-apiserver:v$K8S_VERSIONdocker pull ${MY_REGISTRY}/kube-controller-manager:v$K8S_VERSIONdocker pull ${MY_REGISTRY}/kube-scheduler:v$K8S_VERSIONdocker pull ${MY_REGISTRY}/kube-proxy:v$K8S_VERSIONdocker pull ${MY_REGISTRY}/etcd:3.4.13-0docker pull ${MY_REGISTRY}/pause:3.2docker pull ${MY_REGISTRY}/coredns-arm64:1.7.0docker pull coredns/coredns:1.7.0docker tag ${MY_REGISTRY}/kube-apiserver:v$K8S_VERSION k8s.gcr.io/kube-apiserver:v$K8S_VERSIONdocker tag ${MY_REGISTRY}/kube-scheduler:v$K8S_VERSION k8s.gcr.io/kube-scheduler:v$K8S_VERSIONdocker tag ${MY_REGISTRY}/kube-controller-manager:v$K8S_VERSION k8s.gcr.io/kube-controller-manager:v$K8S_VERSIONdocker tag ${MY_REGISTRY}/kube-proxy:v$K8S_VERSION k8s.gcr.io/kube-proxy:v$K8S_VERSIONdocker tag ${MY_REGISTRY}/etcd:3.4.13-0 k8s.gcr.io/etcd:3.4.13-0docker tag ${MY_REGISTRY}/pause:3.2 k8s.gcr.io/pause:3.2docker tag ${MY_REGISTRY}/coredns-arm64:1.7.0 k8s.gcr.io/coredns:1.7.0docker tag coredns/coredns:1.7.0 k8s.gcr.io/coredns:1.7.0wget weget https://docs.projectcalico.org/v3.11/manifests/calico.yaml#kubectl apply -f calico.yamlsystemctl enable kubelet docker}run2(){# 根据实际情况设置ipkubeadm init –apiserver-advertise-address=192.168.0.50 –kubernetes-version v1.20.0 –service-cidr=10.1.0.0/16 –pod-network-cidr=10.244.0.0/16 –ignore-preflight-errors=all –image-repository registry.aliyuncs.com/google_containers}main(){docker_installrasp_kernel_setuprun1run2}main

欢迎试用

郑重声明:本文内容及图片均整理自互联网,不代表本站立场,版权归原作者所有,如有侵权请联系管理员(admin#wlmqw.com)删除。
上一篇 2022年6月26日 12:02
下一篇 2022年6月26日 12:02

相关推荐

联系我们

联系邮箱:admin#wlmqw.com
工作时间:周一至周五,10:30-18:30,节假日休息