######安装kube-apiserver######
1.下载并解压文件(https://storage.googleapis.com/kubernetes-release/release/v1.22.2/kubernetes-server-linux-amd64.tar.gz)
neo@master01:/usr/src$ sudo tar -xf kubernetes-server-linux-amd64.tar.gz
neo@master01:/usr/src$ cd kubernetes/server/bin/
neo@master01:/usr/src/kubernetes/server/bin$ sudo cp kube-scheduler kube-apiserver kube-controller-manager kubectl /k8s/kubernetes/bin/
2.编辑kube-apiserver的配置文件
neo@master01:/k8s/kubernetes/cfg$ sudo vim kube-apiserver.conf
KUBE_APISERVER_OPTS="--logtostderr=true \
--v=4 \
--etcd-servers=https://192.168.63.148:2379,https://192.168.63.149:2379,https://192.168.63.150:2379 \
--bind-address=192.168.63.151 \
--secure-port=6443 \
--insecure-port=0 \
--advertise-address=192.168.63.151 \
--allow-privileged=true \
--service-cluster-ip-range=10.254.0.0/16 \
--enable-admission-plugins=NamespaceLifecycle,LimitRanger,ServiceAccount,ResourceQuota,NodeRestriction \
--authorization-mode=RBAC,Node \
--enable-bootstrap-token-auth \
--token-auth-file=/k8s/kubernetes/cfg/token.csv \
--service-node-port-range=30000-50000 \
--tls-cert-file=/k8s/kubernetes/ssl/server.pem \
--tls-private-key-file=/k8s/kubernetes/ssl/server-key.pem \
--client-ca-file=/k8s/kubernetes/ssl/ca.pem \
--service-account-key-file=/k8s/kubernetes/ssl/ca-key.pem \
--etcd-cafile=/k8s/etcd/ssl/ca.pem \
--etcd-certfile=/k8s/etcd/ssl/server.pem \
--service-account-signing-key-file=/k8s/kubernetes/ssl/ca-key.pem \
--service-account-issuer=https://kubernetes.default.svc.cluster.local \
--etcd-keyfile=/k8s/etcd/ssl/server-key.pem"
参数记录:
--logtostderr:启用日志
--v:日志等级
--log-dir:日志目录
--etcd-servers:etcd集群地址
--bind-address:监听地址
--secure-port:https安全端口
--advertise-address:集群通告地址
--allow-privileged:启用授权
--service-cluster-ip-range:Service虚拟IP地址段
--enable-admission-plugins:准入控制模块
--authorization-mode:认证授权,启用RBAC授权和节点自管理
--enable-bootstrap-token-auth:启用TLS bootstrap机制
--token-auth-file:bootstrap token文件
--service-node-port-range:Service nodeport类型默认分配端口范围
--kubelet-client-xxx:apiserver访问kubelet客户端证书
--tls-xxx-file:apiserver https证书
--etcd-xxxfile:连接Etcd集群证书
--audit-log-xxx:审计日志
3.编辑kube-apiserver的服务文件
neo@master01:/k8s/kubernetes/cfg$ sudo vim /usr/lib/systemd/system/kube-apiserver.service
[Unit]
Description=Kubernetes API Server
Documentation=https://github.com/kubernetes/kubernetes
[Service]
EnvironmentFile=-/k8s/kubernetes/cfg/kube-apiserver.conf
ExecStart=/k8s/kubernetes/bin/kube-apiserver $KUBE_APISERVER_OPTS
Restart=on-failure
[Install]
WantedBy=multi-user.target
4.配置服务
neo@master01:/k8s/kubernetes/cfg$ sudo systemctl enable kube-apiserver
neo@master01:/k8s/kubernetes/cfg$ sudo systemctl start kube-apiserve
######安装kube-scheduler######
//配置配置文件
neo@master01:/k8s/kubernetes/cfg$ sudo vim kube-scheduler.conf
KUBE_SCHEDULER_OPTS="--logtostderr=true --v=4 --master=127.0.0.1:8080 --leader-elect"
//配置服务文件
neo@master01:/k8s/kubernetes/cfg$ sudo cat /usr/lib/systemd/system/kube-scheduler.service
[Unit]
Description=Kubernetes Scheduler
Documentation=https://github.com/kubernetes/kubernetes
[Service]
EnvironmentFile=-/k8s/kubernetes/cfg/kube-scheduler.conf
ExecStart=/k8s/kubernetes/bin/kube-scheduler $KUBE_SCHEDULER_OPTS
Restart=on-failure
[Install]
WantedBy=multi-user.target
//配置服务
neo@master01:/k8s/kubernetes/cfg$ sudo systemctl enable kube-scheduler.service
neo@master01:/k8s/kubernetes/cfg$ sudo systemctl start kube-scheduler.service
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。