my-scheduler.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: my-scheduler
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: my-scheduler-as-kube-scheduler
subjects:
- kind: ServiceAccount
name: my-scheduler
namespace: kube-system
roleRef:
kind: ClusterRole
name: system:kube-scheduler
apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: my-scheduler-as-volume-scheduler
subjects:
- kind: ServiceAccount
name: my-scheduler
namespace: kube-system
roleRef:
kind: ClusterRole
name: system:volume-scheduler
apiGroup: rbac.authorization.k8s.io
---
apiVersion: v1
kind: ConfigMap
metadata:
name: my-scheduler-config
namespace: kube-system
data:
my-scheduler-config.yaml: |
apiVersion: kubescheduler.config.k8s.io/v1beta2
kind: KubeSchedulerConfiguration
profiles:
- schedulerName: my-scheduler
leaderElection:
leaderElect: false
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
component: scheduler
tier: control-plane
name: my-scheduler
namespace: kube-system
spec:
selector:
matchLabels:
component: scheduler
tier: control-plane
replicas: 1
template:
metadata:
labels:
component: scheduler
tier: control-plane
version: second
spec:
serviceAccountName: my-scheduler
containers:
- command:
- /usr/local/bin/kube-scheduler
- --config=/etc/kubernetes/my-scheduler/my-scheduler-config.yaml
image: gcr.io/my-gcp-project/my-kube-scheduler:1.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
멜티 스케줄러를 사용해 두 포드를 스케줄
schedulerName에 default-scheduluer를 작성하거나 아무 서술이 없는 경우 default-scheduler로 실행됨
세 번째 포드는 my-scheduler 사용
pod2.yaml
apiVersion: v1
kind: Pod
metadata:
name: annotation-default-scheduler
labels:
name: multischeduler-example
spec:
schedulerName: default-scheduler
containers:
- name: pod-with-default-annotation-container
image: registry.k8s.io/pause:2.0
pod3.yaml
apiVersion: v1
kind: Pod
metadata:
name: annotation-second-scheduler
labels:
name: multischeduler-example
spec:
schedulerName: my-scheduler
containers:
- name: pod-with-second-annotation-container
image: registry.k8s.io/pause:2.0
kubectl edit clusterrole system:kube-scheduler
resourceNames:
- kube-scheduler
- my-scheduler
연습문제
What is the name of the POD that deploys the default kubernetes scheduler in this environment?
-> kube-scheduler-controlplane
controlplane ~ ✖ kubectl get pods -A -o wide
NAMESPACE NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
kube-flannel kube-flannel-ds-rvnw9 1/1 Running 0 12m 192.4.66.9 controlplane <none> <none>
kube-system coredns-5d78c9869d-gnxjj 1/1 Running 0 12m 10.244.0.2 controlplane <none> <none>
kube-system coredns-5d78c9869d-lgqkz 1/1 Running 0 12m 10.244.0.3 controlplane <none> <none>
kube-system etcd-controlplane 1/1 Running 0 13m 192.4.66.9 controlplane <none> <none>
kube-system kube-apiserver-controlplane 1/1 Running 0 13m 192.4.66.9 controlplane <none> <none>
kube-system kube-controller-manager-controlplane 1/1 Running 0 13m 192.4.66.9 controlplane <none> <none>
kube-system kube-proxy-hx94t 1/1 Running 0 12m 192.4.66.9 controlplane <none> <none>
kube-system kube-scheduler-controlplane 1/1 Running 0 13m 192.4.66.9 controlplane <none> <none>
What is the image used to deploy the kubernetes scheduler?
-> registry.k8s.io/kube-scheduler:v1.27.0
controlplane ~ ✖ kubectl describe pod kube-scheduler-controlplane -n kube-system
Name: kube-scheduler-controlplane
Namespace: kube-system
Priority: 2000001000
Priority Class Name: system-node-critical
Node: controlplane/192.4.66.9
Start Time: Mon, 07 Aug 2023 21:21:40 -0400
Labels: component=kube-scheduler
tier=control-plane
Annotations: kubernetes.io/config.hash: db6b3451d765dd210f8e4065f082b37f
kubernetes.io/config.mirror: db6b3451d765dd210f8e4065f082b37f
kubernetes.io/config.seen: 2023-08-07T21:21:38.999465344-04:00
kubernetes.io/config.source: file
Status: Running
SeccompProfile: RuntimeDefault
IP: 192.4.66.9
IPs:
IP: 192.4.66.9
Controlled By: Node/controlplane
Containers:
kube-scheduler:
Container ID: containerd://d5bc333dbd18ab1e80a0025937bcc6dede595d43867831661e996c26b3b36a42
Image: registry.k8s.io/kube-scheduler:v1.27.0
Image ID: registry.k8s.io/kube-scheduler@sha256:939d0c6675c373639f53f05d61b5035172f95afb47ecffee6baf4e3d70543b66
Port: <none>
Host Port: <none>
Command:
kube-scheduler
--authentication-kubeconfig=/etc/kubernetes/scheduler.conf
--authorization-kubeconfig=/etc/kubernetes/scheduler.conf
--bind-address=127.0.0.1
--kubeconfig=/etc/kubernetes/scheduler.conf
--leader-elect=true
State: Running
Started: Mon, 07 Aug 2023 21:21:30 -0400
Ready: True
Restart Count: 0
Requests:
cpu: 100m
Liveness: http-get https://127.0.0.1:10259/healthz delay=10s timeout=15s period=10s #success=1 #failure=8
Startup: http-get https://127.0.0.1:10259/healthz delay=10s timeout=15s period=10s #success=1 #failure=24
Environment: <none>
Mounts:
/etc/kubernetes/scheduler.conf from kubeconfig (ro)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
kubeconfig:
Type: HostPath (bare host directory volume)
Path: /etc/kubernetes/scheduler.conf
HostPathType: FileOrCreate
QoS Class: Burstable
Node-Selectors: <none>
Tolerations: :NoExecute op=Exists
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Pulled 15m kubelet Container image "registry.k8s.io/kube-scheduler:v1.27.0" already present on machine
Normal Created 15m kubelet Created container kube-scheduler
Normal Started 15m kubelet Started container kube-scheduler