Kubernetes安装系列之Master-scheduler安装

这篇文章整理以下Master节点的scheduler的安装与设定方法,本文以脚本的方式进行固化,内容仍然放在github的easypack上。

整体操作

  • https://blog.csdn.net/liumiaocn/article/details/88413428

scheduler的设定文件

[root@host131 shell]# cat /etc/k8s/kube-scheduler.conf 
KUBE_SCHEDULER_OPTS="--logtostderr=true \
--v=4 \
--log-dir=/var/log/kubernetes \
--master=127.0.0.1:8080 \
--leader-elect"
[root@host131 shell]#

Systemd服务配置文件

[root@host131 shell]# cat /usr/lib/systemd/system/kube-scheduler.service
[Unit]
Description=Kubernetes Scheduler
Documentation=https://github.com/kubernetes/kubernetes

[Service]
EnvironmentFile=-/etc/k8s/kube-scheduler.conf
ExecStart=/usr/local/bin/kube-scheduler $KUBE_SCHEDULER_OPTS
Restart=on-failure

[Install]
WantedBy=multi-user.target
[root@host131 shell]#

脚本示例

[root@host131 shell]# cat step4-install-scheduler.sh 
#!/bin/sh

. ./install.cfg

echo -e "\n##  kube-scheduler service"
systemctl stop kube-scheduler 2>/dev/null

mkdir -p ${ENV_KUBE_DIR_BIN} ${ENV_KUBE_DIR_ETC} ${ENV_KUBE_OPT_LOG_DIR}
chmod 755 ${ENV_HOME_K8S}/*
cp -p ${ENV_HOME_K8S}/kube-scheduler ${ENV_KUBE_DIR_BIN}
if [ $? -ne 0 ]; then
  echo "please check kube-scheduler binary files existed in ${ENV_HOME_K8S}/ or not"
  exit 
fi

# create kube-scheduler configuration file
cat >${ENV_KUBE_DIR_ETC}/${ENV_KUBE_SCH_ETC} <<EOF
KUBE_SCHEDULER_OPTS="--logtostderr=true \
--v=${ENV_KUBE_OPT_LOG_LEVEL} \
--log-dir=${ENV_KUBE_OPT_LOG_DIR} \
--master=${ENV_KUBE_MASTER_ADDR} \
--leader-elect"
EOF

# Create the kube-scheduler service.
cat >${ENV_KUBE_SCH_SERVICE} <<EOF
[Unit]
Description=Kubernetes Scheduler
Documentation=https://github.com/kubernetes/kubernetes

[Service]
EnvironmentFile=-${ENV_KUBE_DIR_ETC}/${ENV_KUBE_SCH_ETC}
ExecStart=${ENV_KUBE_DIR_BIN}/kube-scheduler \$KUBE_SCHEDULER_OPTS
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF

echo -e "\n##  daemon reload service "
systemctl daemon-reload
echo -e "\n##  start kube-scheduler service "
systemctl start kube-scheduler
echo -e "\n##  enable kube-scheduler service " 
systemctl enable kube-scheduler
echo -e "\n##  check  kube-scheduler status"
systemctl status kube-scheduler

# sleep 2 seconds for checking
sleep 2

echo -e "\n##  get cs"
kubectl get cs
[root@host131 shell]#

执行示例

[root@host131 shell]# sh step4-install-scheduler.sh 

##  kube-scheduler service

##  daemon reload service 

##  start kube-scheduler service 

##  enable kube-scheduler service 

##  check  kube-scheduler status
● kube-scheduler.service - Kubernetes Scheduler
   Loaded: loaded (/usr/lib/systemd/system/kube-scheduler.service; enabled; vendor preset: disabled)
   Active: active (running) since Sat 2019-03-23 16:35:18 CST; 277ms ago
     Docs: https://github.com/kubernetes/kubernetes
 Main PID: 10732 (kube-scheduler)
   CGroup: /system.slice/kube-scheduler.service
           └─10732 /usr/local/bin/kube-scheduler --logtostderr=true --v=4 --log-dir=/var/log/kubernetes --master=127.0.0.1:8080 --leader-elect...

Mar 23 16:35:19 host131 kube-scheduler[10732]: I0323 16:35:19.029064   10732 flags.go:33] FLAG: --tls-cert-file=""
Mar 23 16:35:19 host131 kube-scheduler[10732]: I0323 16:35:19.029070   10732 flags.go:33] FLAG: --tls-cipher-suites="[]"
Mar 23 16:35:19 host131 kube-scheduler[10732]: I0323 16:35:19.029074   10732 flags.go:33] FLAG: --tls-min-version=""
Mar 23 16:35:19 host131 kube-scheduler[10732]: I0323 16:35:19.029079   10732 flags.go:33] FLAG: --tls-private-key-file=""
Mar 23 16:35:19 host131 kube-scheduler[10732]: I0323 16:35:19.029083   10732 flags.go:33] FLAG: --tls-sni-cert-key="[]"
Mar 23 16:35:19 host131 kube-scheduler[10732]: I0323 16:35:19.029091   10732 flags.go:33] FLAG: --use-legacy-policy-config="false"
Mar 23 16:35:19 host131 kube-scheduler[10732]: I0323 16:35:19.029095   10732 flags.go:33] FLAG: --v="4"
Mar 23 16:35:19 host131 kube-scheduler[10732]: I0323 16:35:19.029100   10732 flags.go:33] FLAG: --version="false"
Mar 23 16:35:19 host131 kube-scheduler[10732]: I0323 16:35:19.029107   10732 flags.go:33] FLAG: --vmodule=""
Mar 23 16:35:19 host131 kube-scheduler[10732]: I0323 16:35:19.029112   10732 flags.go:33] FLAG: --write-config-to=""

##  get cs
NAME                 STATUS      MESSAGE                                                                                     ERROR
controller-manager   Unhealthy   Get http://127.0.0.1:10252/healthz: dial tcp 127.0.0.1:10252: connect: connection refused   
scheduler            Healthy     ok                                                                                          
etcd-0               Healthy     {"health":"true"}                                                                           
[root@host131 shell]#

安装之后可以通过kubectl get cs确认到scheduler的Status变成了Healthy状态,接下来只需要设定一下controller-manager,Master节点所需的主要部分就完成了。

你可能感兴趣的:(Kubernetes,深入浅出kubernetes)