kubernetes容器集群管理部署master节点组件

集群部署获取k8s二进制包

[[email protected] ~]# wget https://dl.k8s.io/v1.15.0/kubernetes-server-linux-amd64.tar.gz
[[email protected] ~]# ls
kubernetes-server-linux-amd64.tar.gz
[[email protected] ~]# mkdir master
[[email protected] ~]# mv kubernetes-server-linux-amd64.tar.tar master/
[[email protected] ~]# cd master/
[[email protected] master]# tar -zxf kubernetes-server-linux-amd64.tar.gz
[[email protected] master]# ls
kubernetes  kubernetes-server-linux-amd64.tar.gz
[[email protected] master]# cd /root/master/kubernetes/server/bin
[[email protected] bin]# pwd
/root/master/kubernetes/server/bin
[[email protected] bin]# ls
apiextensions-apiserver              kube-controller-manager.tar
cloud-controller-manager             kubectl
cloud-controller-manager.docker_tag  kubelet
cloud-controller-manager.tar         kube-proxy
hyperkube                            kube-proxy.docker_tag
kubeadm                              kube-proxy.tar
kube-apiserver                       kube-scheduler
kube-apiserver.docker_tag            kube-scheduler.docker_tag
kube-apiserver.tar                   kube-scheduler.tar
kube-controller-manager              mounter
kube-controller-manager.docker_tag
[[email protected] bin]# cp kube-controller-manager kube-scheduler kube-apiserver /opt/kubernetes/bin/
[[email protected] bin]# chmod +x /opt/kubernetes/bin/*
[[email protected] bin]# ls /opt/kubernetes/bin/
etcd     flanneld        kube-controller-manager  kube-scheduler
etcdctl  kube-apiserver  kubectl                  mk-docker-opts.sh
[[email protected] bin]# cat apiserver.sh
#!/bin/bash

MASTER_ADDRESS=${1:-"192.168.230.130"}
ETCD_SERVERS=${2:-"http://127.0.0.01:2379"}

cat <<EOF >/opt/kubernetes/cfg/kube-apiserver
KUBE_APISERVER_OPTS="--logtostderr=true \--v=4 \--etcd-servers=${ETCD_SERVERS} \--insecure-bind-address=127.0.0.1 \--bind-address=${MASTER_ADDRESS} \--insecure-port=8080 \--secure-port=6443 \--advertise-address=${MASTER_ADDRESS} \--allow_privileged=true \--service-cluster-ip-range=10.10.10.0/24 \--admission-control=NamespaceLifecycle,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota,NodeRestriction --authorization-mode=RBAC,Node \--kubelet-https=true \--enable-bootstrap-token-auth \--token-auth-file=/opt/kubernetes/cfg/token.csv \--service-node-port-range=30000-50000 \--tls-cert-file=/opt/kubernetes/ssl/server.pem \--tls-private-key-file=/opt/kubernetes/ssl/server-key.pem \--client-ca-file=/opt/kubernetes/ssl/ca.pem \--service-account-key-file=/opt/kubernetes/ssl/ca-key.pem \--etcd-cafile=/opt/kubernetes/ssl/ca.pem \--etcd-certfile=/opt/kubernetes/ssl/server.pem \--etcd-keyfile=/opt/kubernetes/ssl/server-key.pem"
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=/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
[[email protected] bin]# sh apiserver.sh 192.168.238.130 https://192.168.238.130:2379,https://192.168.238.129:2379,https://192.168.238.128:2379
Created symlink from /etc/systemd/system/multi-user.target.wants/kube-apiserver.service to /usr/lib/systemd/system/kube-apiserver.service.
[[email protected] bin]# cat /opt/kubernetes/cfg/kube-apiserver
KUBE_APISERVER_OPTS=“--logtostderr=true --v=4 --etcd-servers=https://192.168.238.130:2379,https://192.168.238.129:2379,https://192.168.238.128:2379 --insecure-bind-address=127.0.0.1 --bind-address=192.168.238.130 --insecure-port=8080 --secure-port=6443 --advertise-address=192.168.238.130 --allow_privileged=true --service-cluster-ip-range=10.10.10.0/24 --admission-control=NamespaceLifecycle,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota,NodeRestriction --authorization-mode=RBAC,Node --kubelet-https=true --enable-bootstrap-token-auth --token-auth-file=/opt/kubernetes/cfg/token.csv --service-node-port-range=30000-50000 --tls-cert-file=/opt/kubernetes/ssl/server.pem --tls-private-key-file=/opt/kubernetes/ssl/server-key.pem --client-ca-file=/opt/kubernetes/ssl/ca.pem --service-account-key-file=/opt/kubernetes/ssl/ca-key.pem --etcd-cafile=/opt/kubernetes/ssl/ca.pem --etcd-certfile=/opt/kubernetes/ssl/server.pem --etcd-keyfile=/opt/kubernetes/ssl/server-key.pem"
[[email protected] bin]# cat /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=/opt/kubernetes/bin/kube-apiserver $KUBE_APISERVER_OPTS
Restart=on-failure

[Install]
WantedBy=multi-user.target
[[email protected] bin]# cp /root/token.csv /opt/kubernetes/cfg/
[[email protected] bin]# systemctl daemon-reload
[[email protected] bin]# systemctl start kube-apiserver
[[email protected] bin]# systemctl status kube-apiserver
● kube-apiserver.service - Kubernetes API Server
   Loaded: loaded (/usr/lib/systemd/system/kube-apiserver.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-07-08 00:19:12 CST; 5s ago
     Docs: https://github.com/kubernetes/kubernetes
 Main PID: 9389 (kube-apiserver)
   Memory: 237.0M
   CGroup: /system.slice/kube-apiserver.service
           └─9389 /opt/kubernetes/bin/kube-apiserver --logtostderr=true --v=4 --etcd-servers=https://192.168.238.130:2379,https://...

Jul 08 00:19:17 master kube-apiserver[9389]: I0708 00:19:17.303440    9389 wrap.go:42] GET /apis/rbac.authorization.k8s.io/v...40304]
Jul 08 00:19:17 master kube-apiserver[9389]: I0708 00:19:17.306232    9389 wrap.go:42] POST /apis/rbac.authorization.k8s.io/...40304]
Jul 08 00:19:17 master kube-apiserver[9389]: I0708 00:19:17.306446    9389 storage_rbac.go:208] created clusterrole.rbac.aut...o-edit
Jul 08 00:19:17 master kube-apiserver[9389]: I0708 00:19:17.312507    9389 wrap.go:42] GET /apis/rbac.authorization.k8s.io/v...40304]
Jul 08 00:19:17 master kube-apiserver[9389]: I0708 00:19:17.315463    9389 wrap.go:42] POST /apis/rbac.authorization.k8s.io/...40304]
Jul 08 00:19:17 master kube-apiserver[9389]: I0708 00:19:17.315628    9389 storage_rbac.go:208] created clusterrole.rbac.aut...o-view
Jul 08 00:19:17 master kube-apiserver[9389]: I0708 00:19:17.317279    9389 wrap.go:42] GET /apis/rbac.authorization.k8s.io/v...40304]
Jul 08 00:19:17 master kube-apiserver[9389]: I0708 00:19:17.320248    9389 wrap.go:42] POST /apis/rbac.authorization.k8s.io/...40304]
Jul 08 00:19:17 master kube-apiserver[9389]: I0708 00:19:17.320381    9389 storage_rbac.go:208] created clusterrole.rbac.aut...apster
Jul 08 00:19:17 master kube-apiserver[9389]: I0708 00:19:17.321952    9389 wrap.go:42] GET /apis/rbac.authorization.k8s.io/v...40304]
Hint: Some lines were ellipsized, use -l to show in full.

[[email protected] bin]# cat controller-manager.sh
#!/bin/bash
MASTER_ADDRESS=${1:-"127.0.0.1"}
cat <<EOF >/opt/kubernetes/cfg/kube-controller-manager
KUBE_CONTROLLER_MANAGER_OPTS="--logtostderr=true \--v=4 \--master=${MASTER_ADDRESS}:8080 \--leader-elect=true \--address=127.0.0.1 \--service-cluster-ip-range=10.10.10.0/24 \--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"
EOF

cat <<EOF >>/usr/lib/systemd/system/kube-controller-manager.service
[Unit]
Description=Kubernetes Controller Manager
Documentation=https://github.com/kubernetes/kubernetes

[Service]
EnvironmentFile=-/opt/kubernetes/cfg/kube-controller-manager
ExecStart=/opt/kubernetes/bin/kube-controller-manager \$KUBE_CONTROLLER_MANAGER_OPTS
Restart=on-failure
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable kube-controller-manager
systemctl restart kube-controller-manager
[[email protected] bin]# sh controller-manager.sh 127.0.0.1
Created symlink from /etc/systemd/system/multi-user.target.wants/kube-controller-manager.service to /usr/lib/systemd/system/kube-controller-manager.service.
[[email protected] bin]# systemctl status kube-controller-manager
● kube-controller-manager.service - Kubernetes Controller Manager
   Loaded: loaded (/usr/lib/systemd/system/kube-controller-manager.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-07-08 01:11:38 CST; 52s ago
     Docs: https://github.com/kubernetes/kubernetes
 Main PID: 9647 (kube-controller)
   Memory: 125.4M
   CGroup: /system.slice/kube-controller-manager.service
           └─9647 /opt/kubernetes/bin/kube-controller-manager --logtostderr=true --v=4 --master=127.0.0.1:8080 --leader-elect=true...

Jul 08 01:12:29 master kube-controller-manager[9647]: I0708 01:12:29.568788    9647 cronjob_controller.go:128] Found 0 jobs
Jul 08 01:12:29 master kube-controller-manager[9647]: I0708 01:12:29.568802    9647 cronjob_controller.go:134] Found 0 groups
Jul 08 01:12:29 master kube-controller-manager[9647]: I0708 01:12:29.795439    9647 reflector.go:160] Listing and watching *v...o:133
Jul 08 01:12:29 master kube-controller-manager[9647]: E0708 01:12:29.796578    9647 reflector.go:125] k8s.io/client-go/inform...ource
Jul 08 01:12:29 master kube-controller-manager[9647]: I0708 01:12:29.801372    9647 reflector.go:160] Listing and watching *v...o:133
Jul 08 01:12:29 master kube-controller-manager[9647]: E0708 01:12:29.801927    9647 reflector.go:125] k8s.io/client-go/inform...s.io)
Jul 08 01:12:30 master kube-controller-manager[9647]: I0708 01:12:30.797753    9647 reflector.go:160] Listing and watching *v...o:133
Jul 08 01:12:30 master kube-controller-manager[9647]: E0708 01:12:30.798917    9647 reflector.go:125] k8s.io/client-go/inform...ource
Jul 08 01:12:30 master kube-controller-manager[9647]: I0708 01:12:30.802656    9647 reflector.go:160] Listing and watching *v...o:133
Jul 08 01:12:30 master kube-controller-manager[9647]: E0708 01:12:30.803446    9647 reflector.go:125] k8s.io/client-go/inform...s.io)
Hint: Some lines were ellipsized, use -l to show in full.
[[email protected] bin]# cat scheduler.sh
#!/bin/bash
MASTER_ADDRESS=${1:-"127.0.0.1"}
cat <<EOF >/opt/kubernetes/cfg/kube-scheduler
KUBE_SCHEDULER_OPTS="--logtostderr=true \--v=4 \--master=${MASTER_ADDRESS}:8080 \--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=/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
[[email protected] bin]# sh scheduler.sh 127.0.0.1
Created symlink from /etc/systemd/system/multi-user.target.wants/kube-scheduler.service to /usr/lib/systemd/system/kube-scheduler.service.
[[email protected] bin]# systemctl status kube-scheduler
● kube-scheduler.service - Kubernetes Scheduler
   Loaded: loaded (/usr/lib/systemd/system/kube-scheduler.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2019-07-08 01:19:33 CST; 20s ago
     Docs: https://github.com/kubernetes/kubernetes
 Main PID: 9717 (kube-scheduler)
   Memory: 41.8M
   CGroup: /system.slice/kube-scheduler.service
           └─9717 /opt/kubernetes/bin/kube-scheduler --logtostderr=true --v=4 --master=127.0.0.1:8080 --leader-elect

Jul 08 01:19:35 master kube-scheduler[9717]: I0708 01:19:35.039679    9717 shared_informer.go:176] caches populated
Jul 08 01:19:35 master kube-scheduler[9717]: I0708 01:19:35.140505    9717 shared_informer.go:176] caches populated
Jul 08 01:19:35 master kube-scheduler[9717]: I0708 01:19:35.241452    9717 shared_informer.go:176] caches populated
Jul 08 01:19:35 master kube-scheduler[9717]: I0708 01:19:35.342335    9717 shared_informer.go:176] caches populated
Jul 08 01:19:35 master kube-scheduler[9717]: I0708 01:19:35.443425    9717 shared_informer.go:176] caches populated
Jul 08 01:19:35 master kube-scheduler[9717]: I0708 01:19:35.543503    9717 shared_informer.go:176] caches populated
Jul 08 01:19:35 master kube-scheduler[9717]: I0708 01:19:35.643839    9717 shared_informer.go:176] caches populated
Jul 08 01:19:35 master kube-scheduler[9717]: I0708 01:19:35.643976    9717 leaderelection.go:235] attempting to acquire lead...ler...
Jul 08 01:19:35 master kube-scheduler[9717]: I0708 01:19:35.653106    9717 leaderelection.go:245] successfully acquired leas...eduler
Jul 08 01:19:35 master kube-scheduler[9717]: I0708 01:19:35.754649    9717 shared_informer.go:176] caches populated
Hint: Some lines were ellipsized, use -l to show in full.
[[email protected] bin]# cat /opt/kubernetes/cfg/kube-controller-manager
KUBE_CONTROLLER_MANAGER_OPTS="--logtostderr=true --v=4 --master=127.0.0.1:8080 --leader-elect=true --address=127.0.0.1 --service-cluster-ip-range=10.10.10.0/24 --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"
[[email protected] bin]# cat /opt/kubernetes/cfg/kube-scheduler
KUBE_SCHEDULER_OPTS="--logtostderr=true --v=4 --master=127.0.0.1:8080 --leader-elect"
查看状态
[[email protected] bin]# kubectl get cs
NAME                 STATUS    MESSAGE              ERROR
scheduler            Healthy   ok
controller-manager   Healthy   ok
etcd-1               Healthy   {"health": "true"}
etcd-2               Healthy   {"health": "true"}
etcd-0               Healthy   {"health": "true"}

原文地址:https://www.cnblogs.com/yinshoucheng-golden/p/11147886.html

时间: 2024-11-05 19:03:23

kubernetes容器集群管理部署master节点组件的相关文章

Kubernetes容器集群管理环境 - Node节点的移除与加入

一.如何从Kubernetes集群中移除Node 比如从集群中移除k8s-node03这个Node节点,做法如下: 1)先在master节点查看Node情况 [[email protected]-master01 ~]# kubectl get nodes NAME STATUS ROLES AGE VERSION k8s-node01 Ready <none> 47d v1.14.2 k8s-node02 Ready <none> 47d v1.14.2 k8s-node03 R

kubeadm部署k8s1.9高可用集群--4部署master节点

部署master节点 kubernetes master 节点包含的组件: kube-apiserver kube-scheduler kube-controller-manager 本文档介绍部署一个三节点高可用 master 集群的步骤,分别命名为k8s-host1.k8s-host2.k8s-host3: k8s-host1:172.16.120.154 k8s-host2:172.16.120.155 k8s-host3:172.16.120.156 安装docker 在每台主机安装do

kubernetes容器集群管理启动一个测试示例

创建nginx 创建3个nginx副本 [[email protected] bin]# kubectl run nginx --image=nginx --replicas=3 kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create inste

Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列之部署master/node节点组件(四)

0.前言 整体架构目录:ASP.NET Core分布式项目实战-目录 k8s架构目录:Kubernetes(k8s)集群部署(k8s企业级Docker容器集群管理)系列目录 1.部署master组件 master 服务器的组件有:kube-apiserver.kube-controller-manager.kube-scheduler 因此需要下载k8s master,下载地址:https://github.com/kubernetes/kubernetes/blob/master/CHANGE

Docker&Kubernetes沙龙干货集锦:容器集群管理利器kubernetes详谈-CSDN.NET

Docker&Kubernetes沙龙干货集锦:容器集群管理利器kubernetes详谈-CSDN.NET undefined Package - crawler undefined Docker&Kubernetes沙龙干货集锦:容器集群管理利器kubernetes详谈-CSDN.NET

容器集群管理平台的比较

容器化和微服务是当前最热话题,不久之前,笔者(据说因为现在都不用笔了,"笔者"的称谓已经不合适了,因为输入用键盘,叫"键人"更为合适)参加QCon上海一个微服务监控的Session,场面爆棚,我不得不在拥挤的过道听完了整个session.随着要管理的容器越来越多,容器的集群管理平台成为了刚需! Docker Swarm Swarm是Docker公司在2014年12月初新发布的容器集群管理工具.它可以把多个主机变成一个虚拟的Docker主机来管理.Swarm使用Go语

Kubernetes(K8s)(二)——搭建Kubernetes容器集群管理系统

(1).配置说明 节点角色 IP地址 CPU 内存 master.etcd 192.168.128.110 4核 2G node1/minion1 192.168.128.111 4核 2G node2/minion2 192.168.128.112 4核 2G (2).搭建Kubernetes容器集群管理系统 1)三台主机安装常用的软件包 bash-completion可以使得按<Tab>键补齐,vim是vi编辑器的升级版,wget用于下载阿里云的yum源文件. # yum -y insta

Cassandra集群管理-替换异常节点

Cassandra集群管理-替换异常节点 替换异常集群节点,使用JVM启动标志 Dcassandra.replace_address_first_boot = <dead_node_ip>启动.一旦启用此属性,节点将在休眠状态中启动,在此期间所有其他节点将看到此节点关闭.替换节点将立即开始从集群中的其余节点引导数据. 新节点的正常引导的主要区别在于此新节点在此阶段不会接受任何写入.一旦引导完成,节点将被标记为"UP",我们依赖于隐性启动保障新节点数据独立存在.(因为自引导开

Swarm容器集群管理(介绍)

一.Swarm介绍 Swarm是Docker公司自研发的容器集群管理系统, Swarm在早期是作为一个独立服务存在, 在Docker Engine v1.12中集成了Swarm的集群管理和编排功能.可以通过初始化Swarm或加入现有Swarm来启用Docker引擎的Swarm模式. Docker Engine CLI和API包括了管理Swarm节点命令,比如添加.删除节点,以及在Swarm中部署和编排服务.也增加了服务栈(Stack).服务(Service).任务(Task)概念. 二.Swar