1. What is the name of the POD that deploys the default kubernetes scheduler in this environment?
% controlplane ~ ➜ k get pods -A
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-flannel kube-flannel-ds-wkmwp 1/1 Running 0 3m18s
kube-system coredns-768b85b76f-blx82 1/1 Running 0 3m17s
kube-system coredns-768b85b76f-p4qf4 1/1 Running 0 3m17s
kube-system etcd-controlplane 1/1 Running 0 3m32s
kube-system kube-apiserver-controlplane 1/1 Running 0 3m32s
kube-system kube-controller-manager-controlplane 1/1 Running 0 3m32s
kube-system kube-proxy-txbqd 1/1 Running 0 3m18s
kube-system kube-scheduler-controlplane 1/1 Running 0 3m35s
answer : kube-scheduler-controlplane
2. What is the image used to deploy the kubernetes scheduler? Inspect the kubernetes scheduler pod and identify the image
$ controlplane ~ ➜ k describe pod kube-scheduler-controlplane -n kube-system
...
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Pulled 5m38s kubelet Container image "registry.k8s.io/kube-scheduler:v1.30.0" already present on machine
Normal Created 5m37s kubelet Created container kube-scheduler
Normal Started 5m37s kubelet Started container kube-scheduler
...
answer : registry.k8s.io/kube-scheduler:v1.30.0
3. 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
Run the command: kubectl get serviceaccount -n kube-system and kubectl get clusterrolebinding
Note: - Don't worry if you are not familiar with these resources. We will cover it later on.
4. Let's create a configmap that the new scheduler will employ using the concept of ConfigMap as a volume.
We have already given a configMap definition file called my-scheduler-configmap.yaml at /root/ path that will create a configmap with name my-scheduler-config using the content of file /root/my-scheduler-config.yaml.
$ controlplane ~ ➜ kubectl create -f /root/my-scheduler-configmap.yaml
configmap/my-scheduler-config created
5. 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.
---
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: registry.k8s.io/kube-scheduler:v1.30.0 # changed
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
---
$ controlplane ~ ➜ k apply -f /root/my-scheduler.yaml
pod/my-scheduler created
6. 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
$ controlplane ~ ➜ vi nginx-pod.yaml
---
apiVersion: v1
kind: Pod
metadata:
name: nginx
spec:
schedulerName: my-scheduler # scheduler 이름을 명시함
containers:
- image: nginx
name: nginx
---
$ controlplane ~ ➜ k apply -f nginx-pod.yaml
pod/nginx created
'IT 기술 > k8s' 카테고리의 다른 글
[cka] Managing Application Logs (0) | 2024.06.24 |
---|---|
[cka] Monitor Cluster Components (0) | 2024.06.24 |
[cka] Resource Limits (0) | 2024.06.22 |
[cka] Node Affinity (0) | 2024.06.08 |
[cka] Taints and Tolerations (0) | 2024.06.08 |
댓글