如何在CentOS7.3下二进制安装Kubernetes 1.16.0高可用集群

2023-04-14 04:11:00 集群 可用 安装

如何在CentOS7.3下二进制安装Kubernetes 1.16.0高可用集群

1、下载Kubernetes的二进制文件

下载地址:https://github.com/kubernetes/kubernetes/releases/download/v1.16.0/kubernetes.tar.gz

2、解压Kubernetes的二进制文件

tar -zxvf kubernetes.tar.gz

3、进入Kubernetes的二进制目录

cd kubernetes

4、创建安装目录

mkdir -p /opt/kubernetes/{bin,cfg,ssl}

5、将Kubernetes的二进制文件复制到安装目录

cp -r server/bin/{kube-apiserver,kube-controller-manager,kube-scheduler,kubectl,kubelet,kube-proxy} /opt/kubernetes/bin/

6、创建证书

cd /opt/kubernetes/ssl

cfssl gencert -initca ca-csr.json | cfssljson -bare ca

cfssl gencert -ca=ca.pem -ca-key=ca-key.pem -config=ca-config.json -profile=kubernetes apiserver-csr.json | cfssljson -bare apiserver

7、创建配置文件

cd /opt/kubernetes/cfg

vim kube-apiserver.yaml

vim kube-controller-manager.yaml

vim kube-scheduler.yaml

vim kube-proxy.yaml

vim kubelet.yaml

8、启动Kubernetes

cd /opt/kubernetes/bin

nohup ./kube-apiserver --log-dir=/opt/kubernetes/logs --v=2 --etcd-servers=https://127.0.0.1:2379 --bind-address=127.0.0.1 --secure-port=6443 --advertise-address=127.0.0.1 --allow-privileged=true --service-cluster-ip-range=10.1.0.0/16 --enable-admission-plugins=NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,ResourceQuota,NodeRestriction --authorization-mode=RBAC,Node --tls-cert-file=/opt/kubernetes/ssl/apiserver.pem --tls-private-key-file=/opt/kubernetes/ssl/apiserver-key.pem --client-ca-file=/opt/kubernetes/ssl/ca.pem --service-account-key-file=/opt/kubernetes/ssl/ca-key.pem &

nohup ./kube-controller-manager --log-dir=/opt/kubernetes/logs --v=2 --master=127.0.0.1:6443 --allocate-node-cidrs=true --cluster-cidr=10.1.0.0/16 --service-cluster-ip-range=10.1.0.0/16 --cluster-name=kubernetes --cluster-signing-cert-file=/opt/kubernetes/ssl/ca.pem --cluster-signing-key-file=/opt/kubernetes/ssl/ca-key.pem --service-account-private-key-file=/opt/kubernetes/ssl/ca-key.pem --root-ca-file=/opt/kubernetes/ssl/ca.pem --leader-elect=true &

nohup ./kube-scheduler --log-dir=/opt/kubernetes/logs --v=2 --master=127.0.0.1:6443 &

nohup ./kube-proxy --log-dir=/opt/kubernetes/logs --v=2 --master=127.0.0.1:6443 --cluster-cidr=10.1.0.0/16 &

nohup ./kubelet --log-dir=/opt/kubernetes/logs --v=2 --pod-infra-container-image=registry.cn-hangzhou.aliyuncs.com/google-containers/pause-amd64:3.1 --address=127.0.0.1 --port=10250 --hostname-override=127.0.0.1 --api-servers=http://127.0.0.1:6443 --cluster-dns=10.1.0.10 --cluster-domain=cluster.local --allow-privileged=true --cadvisor-port=0 --healthz-bind-address=127.0.0.1 --disk-pressure-transition-period=5m0s --eviction-hard=memory.available<100Mi,nodefs.available<10%,nodefs.inodesFree<5% --kubelet-cgroups=/systemd/system.slice --enable-controller-attach-detach=true --fail-swap-on=false --runtime-request-timeout=2m0s --max-pods=110 &

相关文章