Home 쿠버네티스 - exr12 - Multiple Schedulers
Post
Cancel

쿠버네티스 - exr12 - Multiple Schedulers

kubernetes exr12 Multiple Schedulers

1
2
3
4
5
# What is the name of the POD that deploys the default kubernetes scheduler in this environment?

k get pods -n kube-system

kube-scheduler-controlplane
1
2
3
4
5
6
7
8
9
10
11
12
13
# What is the image used to deploy the kubernetes scheduler?
# Inspect the kubernetes scheduler pod and identify the image

kubectl describe pod kube-scheduler-controlplane -n kube-system

...
Containers:
  kube-scheduler:
    Container ID:  docker://98ecf5b07fda8d18afcf60964413960e4f95e0387d8919a4cc7e552ded601735
    Image:         k8s.gcr.io/kube-scheduler:v1.23.0
    Image ID:      docker-pullable://k8s.gcr.io/kube-scheduler@sha256:af8166ce28baa7cb902a2c0d16da865d5d7c892fe1b41187fd4be78ec6291c23
    Port:          <none>
    Host Port:     <none>ㅌ
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# We have already created the ServiceAccount and ClusterRoleBinding that our custom scheduler will make use of.

# Checkout the following kubernetes objects:

# ServiceAccount: my-scheduler (kube-system namespace)
# ClusterRoleBinding: my-scheduler-as-kube-scheduler
# ClusterRoleBinding: my-scheduler-as-volume-scheduler

kubectl get sa -n kube-system | grep my-scheduler


--------
--------
# Let's create a configmap that the new scheduler will employ using the concept of ConfigMap as a volume.
# Create a configmap with name my-scheduler-config using the content of file /root/my-scheduler-config.yaml

kubectl get configmaps -n kube-system

kubectl create -n kube-system configmap my-scheduler-config --from-file=/root/my-scheduler-config.yaml

# my-scheduler-config.yaml
apiVersion: kubescheduler.config.k8s.io/v1beta2
kind: KubeSchedulerConfiguration
profiles:
  - schedulerName: my-scheduler
leaderElection:
  leaderElect: false
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# Deploy an additional scheduler to the cluster following the given specification.
# Use the manifest file provided at /root/my-scheduler.yaml. Use the same image as used by the default kubernetes scheduler.

Name: my-scheduler
Status: Running
Correct image used?

apiVersion: v1
kind: Pod
metadata:
  labels:
    run: my-scheduler
  name: my-scheduler
  namespace: kube-system
spec:
  serviceAccountName: my-scheduler
  containers:
  - command:
    - /usr/local/bin/kube-scheduler
    - --config=/etc/kubernetes/my-scheduler/my-scheduler-config.yaml
    image: k8s.gcr.io/kube-scheduler:v1.23.0 # 이미지 수정
    livenessProbe:
      httpGet:
        path: /healthz
        port: 10259
        scheme: HTTPS
      initialDelaySeconds: 15
    name: kube-second-scheduler
    readinessProbe:
      httpGet:
        path: /healthz
        port: 10259
        scheme: HTTPS
    resources:
      requests:
        cpu: '0.1'
    securityContext:
      privileged: false
    volumeMounts:
      - name: config-volume
        mountPath: /etc/kubernetes/my-scheduler
  hostNetwork: false
  hostPID: false
  volumes:
    - name: config-volume
      configMap:
        name: my-scheduler-config

# 생성해 준다
kubectl create -f my-scheduler.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# A POD definition file is given. Use it to create a POD with the new custom scheduler.
# File is located at /root/nginx-pod.yaml

piVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  containers:
  - image: nginx
    name: nginx

# 스케쥴러 이름을 추가해 준다

apiVersion: v1
kind: Pod
metadata:
  name: nginx
spec:
  schedulerName: my-scheduler
  containers:
  - image: nginx
    name: nginx

# pod 생성
kubectl create -f nginx-pod.yaml
This post is licensed under CC BY 4.0 by the author.