【原】二进制部署 k8s 1.18.3 (6)

将文件拷贝至对应位置

ansible k8s -m copy -a "src=./bootstrap.kubeconfig dest=http://www.likecs.com/opt/kubernetes/cfg" ansible k8s -m copy -a "src=./kube-proxy.kubeconfig dest=http://www.likecs.com/opt/kubernetes/cfg" ansible k8s -m copy -a "src=./token.csv dest=http://www.likecs.com/opt/kubernetes/cfg" 3.4 安装 kube-apiserver

Masters 节点安装

此处可以使用 tmux 打开三个终端窗口进行,并行输入

【原】二进制部署 k8s 1.18.3

也可以在三台机器上分开执行

[root@centos7-a ~]# mkdir k8s-scripts [root@centos7-a k8s-scripts]# vim install-apiserver.sh [root@centos7-a k8s-scripts]# IP=`ip addr | grep ens33 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'|head -1` && echo $IP 10.10.10.128 [root@centos7-a k8s-scripts]# bash install-apiserver.sh $IP https://10.10.10.128:2379,https://10.10.10.129:2379,https://10.10.10.130:2379

脚本内容如下:

#!/bin/bash # MASTER_ADDRESS 写本机 MASTER_ADDRESS=${1:-"10.10.10.128"} ETCD_SERVERS=${2:-"http://127.0.0.1:2379"} cat <<EOF >/opt/kubernetes/cfg/kube-apiserver KUBE_APISERVER_OPTS="--logtostderr=false \\ --v=2 \\ --log-dir=http://www.likecs.com/opt/kubernetes/logs/kube-apiserver \\ --etcd-servers=${ETCD_SERVERS} \\ --bind-address=0.0.0.0 \\ --secure-port=6443 \\ --advertise-address=${MASTER_ADDRESS} \\ --allow-privileged=true \\ --service-cluster-ip-range=10.96.0.0/12 \\ --enable-admission-plugins=NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,DefaultTolerationSeconds,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota,NodeRestriction \\ --authorization-mode=RBAC,Node \\ --kubelet-https=true \\ --enable-bootstrap-token-auth=true \\ --token-auth-file=http://www.likecs.com/opt/kubernetes/cfg/token.csv \\ --service-node-port-range=30000-50000 \\ --kubelet-client-certificate=http://www.likecs.com/opt/kubernetes/ssl/server.pem \\ --kubelet-client-key=http://www.likecs.com/opt/kubernetes/ssl/server-key.pem \\ --tls-cert-file=http://www.likecs.com/opt/kubernetes/ssl/server.pem \\ --tls-private-key-file=http://www.likecs.com/opt/kubernetes/ssl/server-key.pem \\ --client-ca-file=http://www.likecs.com/opt/kubernetes/ssl/ca.pem \\ --service-account-key-file=http://www.likecs.com/opt/kubernetes/ssl/ca-key.pem \\ --etcd-cafile=http://www.likecs.com/opt/kubernetes/ssl/ca.pem \\ --etcd-certfile=http://www.likecs.com/opt/kubernetes/ssl/server.pem \\ --etcd-keyfile=http://www.likecs.com/opt/kubernetes/ssl/server-key.pem \\ --requestheader-client-ca-file=http://www.likecs.com/opt/kubernetes/ssl/ca.pem \\ --requestheader-extra-headers-prefix=X-Remote-Extra- \\ --requestheader-group-headers=X-Remote-Group \\ --requestheader-username-headers=X-Remote-User \\ --proxy-client-cert-file=http://www.likecs.com/opt/kubernetes/ssl/metrics-server.pem \\ --proxy-client-key-file=http://www.likecs.com/opt/kubernetes/ssl/metrics-server-key.pem \\ --runtime-config=api/all=true \\ --audit-log-maxage=30 \\ --audit-log-maxbackup=3 \\ --audit-log-maxsize=100 \\ --audit-log-truncate-enabled=true \\ --audit-log-path=http://www.likecs.com/opt/kubernetes/logs/k8s-audit.log" EOF cat <<EOF >/usr/lib/systemd/system/kube-apiserver.service [Unit] Description=Kubernetes API Server Documentation=https://github.com/kubernetes/kubernetes [Service] EnvironmentFile=-/opt/kubernetes/cfg/kube-apiserver ExecStart=http://www.likecs.com/opt/kubernetes/bin/kube-apiserver \$KUBE_APISERVER_OPTS Restart=on-failure [Install] WantedBy=multi-user.target EOF systemctl daemon-reload systemctl enable kube-apiserver systemctl restart kube-apiserver 3.5 安装 kube-scheduler

Masters 节点安装

此处可以使用 tmux 打开三个终端窗口进行,并行输入,也可以在三台机器上分开执行

[root@centos7-a ~]# cd k8s-scripts [root@centos7-a k8s-scripts]# vim install-scheduler.sh [root@centos7-a k8s-scripts]# bash install-scheduler.sh 127.0.0.1

脚本内容如下

#!/bin/bash MASTER_ADDRESS=${1:-"127.0.0.1"} cat <<EOF >/opt/kubernetes/cfg/kube-scheduler KUBE_SCHEDULER_OPTS="--logtostderr=false \\ --v=2 \\ --log-dir=http://www.likecs.com/opt/kubernetes/logs/kube-scheduler \\ --master=${MASTER_ADDRESS}:8080 \\ --address=0.0.0.0 \\ --leader-elect" EOF cat <<EOF >/usr/lib/systemd/system/kube-scheduler.service [Unit] Description=Kubernetes Scheduler Documentation=https://github.com/kubernetes/kubernetes [Service] EnvironmentFile=-/opt/kubernetes/cfg/kube-scheduler ExecStart=http://www.likecs.com/opt/kubernetes/bin/kube-scheduler \$KUBE_SCHEDULER_OPTS Restart=on-failure [Install] WantedBy=multi-user.target EOF systemctl daemon-reload systemctl enable kube-scheduler systemctl restart kube-scheduler 3.6 安装 kube-controller-manager

Masters 节点安装

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zzyxyd.html