1. 博客/

k8s1.14.6集群搭建之scheduler部署

·192 字·1 分钟
Kubernetes
k8s1.14.6集群部署 - This article is part of a series.
Part 4: This Article

1. 创建kubeconfig
#

创建scheduler访问的apiserver的kubeconfig

$ cd /root/k8s-1.14.6/conf
$ cat create-scheduler-kubeconfig.sh 
KUBE_APISERVER="https://192.168.18.142:6443"
kubectl config set-cluster kubernetes \
    --certificate-authority=/root/k8s-1.14.6/ssl/ca.pem \
    --embed-certs=true \
    --server=${KUBE_APISERVER} \
    --kubeconfig=scheduler.conf
kubectl config set-credentials system:kube-scheduler \
    --client-certificate=/root/k8s-1.14.6/ssl/apiserver-kubelet-client.pem \
    --client-key=/root/k8s-1.14.6/ssl/apiserver-kubelet-client-key.pem \
    --embed-certs=true \
    --kubeconfig=scheduler.conf
kubectl config set-context system:kube-scheduler@kubernetes \
    --cluster=kubernetes \
    --user=system:kube-scheduler \
    --kubeconfig=scheduler.conf
kubectl config use-context system:kube-scheduler@kubernetes --kubeconfig=scheduler.conf
$ sh create-scheduler-kubeconfig.sh

2. 部署kube-scheduler
#

2.1 二进制方式启动

kube-scheduler \
  --logtostderr=false \
  --v=2 \
  --log-file=/root/k8s-1.14.6/logs/kube-scheduler.log \
  --bind-address=127.0.0.1 \
  --kubeconfig=/root/k8s-1.14.6/conf/scheduler.conf \
  --leader-elect=true

默认监听10251、10259端口

2.2 StaticPod方式部署

创建静态pod文件kube-scheduler-pod.yaml

$ cd /root/k8s-1.14.6/manifests
apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    component: kube-scheduler
    tier: control-plane
  name: kube-scheduler
  namespace: kube-system
spec:
  containers:
  - command:
    - kube-scheduler
    - --logtostderr=false
    - --v=2
    - --log-file=/var/log/kube-scheduler.log
    - --bind-address=127.0.0.1
    - --kubeconfig=/etc/kubernetes/scheduler.conf
    - --leader-elect=true
    image: k8s.gcr.io/kube-scheduler:v1.14.6
    imagePullPolicy: IfNotPresent
    livenessProbe:
      failureThreshold: 8
      httpGet:
        host: 127.0.0.1
        path: /healthz
        port: 10251
        scheme: HTTP
      initialDelaySeconds: 15
      timeoutSeconds: 15
    name: kube-scheduler
    resources:
      requests:
        cpu: 100m
    volumeMounts:
    - mountPath: /etc/kubernetes/scheduler.conf
      name: kubeconfig
      readOnly: true
    - mountPath: /var/log
      name: logs
  hostNetwork: true
  priorityClassName: system-cluster-critical
  volumes:
  - hostPath:
      path: /root/k8s-1.14.6/conf/scheduler.conf
      type: FileOrCreate
    name: kubeconfig
  - hostPath:
      path: /root/k8s-1.14.6/logs
    name: logs
status: {}

3. 查看集群状态
#

$ kubectl get cs
NAME                     STATUS    MESSAGE             ERROR
scheduler                Healthy     ok                  
controller-manager       Healthy     ok                  
etcd-0                   Healthy    {"health":"true"}
k8s1.14.6集群部署 - This article is part of a series.
Part 4: This Article

Related

k8s1.14.6集群搭建之controller-manager部署
·286 字·2 分钟
Kubernetes
k8s1.14.6集群搭建之ETCD集群部署
·319 字·2 分钟
Kubernetes Etcd
k8s1.14.6集群搭建之apiserver部署
·972 字·5 分钟
Kubernetes