how to enable api flags in kubernetes
Asked Answered
I

4

6

The below screenshot shows the kubernetes document to enable API server flags, but no clear instructions were given on where to change these API server flags. I'm using kubernetes on digital ocean cloud. I can not use hpa. enter image description here kubernetes version is: enter image description here

Inquiline answered 11/12, 2018 at 12:8 Comment(0)
S
3

This depends on how your api-server is running. If it's as a service on the master node, @kishorebjv may have your answer, but if the api-server runs as a pod in kubernetes you should only have to add the flags to the args for that deployment/daemonset.

Synge answered 29/4, 2019 at 19:7 Comment(1)
Thanks, in my case since is a pod owned by control plane, I had to modify the file from within the node and that allowed me to change the configuration.Dungdungan
B
1

you can create a apiserver.conf file in master node & mount it in /etc/kubernetes/ directory of apiserver container. This will help you to customize your API server. here is the sample code for this.

Bushing answered 11/12, 2018 at 13:43 Comment(0)
G
0

I believe you need to get working HPA in your kubernetes cluster. I have written a step by step answer for that, how can you achieve it:

How to Enable KubeAPI server for HPA Autoscaling Metrics

Please have a look. Hope this helps

Greater answered 11/12, 2018 at 15:22 Comment(13)
i followed your answer and I installed metrics server. after I created my hpa the TARGETS stuck in <unknown>/50%. What am I missing? @prafullInquiline
Result for kubectl get events: Warning FailedGetResourceMetric HorizontalPodAutoscaler unable to get metrics for resource cpu: unable to fetch metrics from resource metrics API: the server is currently unable to handle the request (get pods.metrics.k8s.io) Warning FailedComputeMetricsReplicas HorizontalPodAutoscaler failed to get cpu utilization: unable to get metrics for resource cpu: unable to fetch metrics from resource metrics API: the server is currently unable to handle the request (get pods.metrics.k8s.io)Inquiline
Did you kubectl apply -f all the files in metrics-server/deploy/1.8+ folder. If yes this should have worked.Greater
i did everything exactly as you mentioned, but not working. metric server pod status is "CrashLoopsBackOff" @prafullInquiline
I have updated my original answer, Kindly try that and let me know if you face any issue?Greater
hey @prafull I added authentication-token-webhook: true horizontal-pod-autoscaler-use-rest-clients: true in /var/lib/kubelet/config.yaml still i'm unable to get it work. Here is what im getting for kubectl get apiservices v1beta1.metrics.k8s.io kube-system/metrics-server False (MissingEndpoints)Inquiline
Did you followed replaced the metrics-server-deployment file from the yaml file I have provided in the answer? If yes metrics-server pod is in running state?Greater
horizontal-pod-autoscaler-use-rest-clients: true should not be there, that flag is not of kubelet. Please remove that flag from kubelet conf and restart the kubeletGreater
yes i followed metrics-server-deployment given by you. metrics-server is not in running state, it's in CrashLoopBackOff state @prafullInquiline
I have removed that flag horizontal-pod-autoscaler-use-rest-clients: true and restarted the kubeletInquiline
Let us continue this discussion in chat.Greater
one more doubt @prafull!! systemctl status kubelet showing Dec 12 12:31:01 kube-master kubelet[8529]: E1212 12:31:01.885511 8529 azure_dd.go:147] failed to get azure cloud in GetVolumeLimits, plugin.host: kube-master. I'm not using azure, I'm using Digital ocean cloud. why this error is showing?Inquiline
I am not familiar with digitial ocean kubernetes cluster. I am not sure what that means.Greater
L
0

The kube-apiserver usually runs as a static pod. This means it is managed directly by the kubelet on a specific node, without the API server observing it and therefore it cannot be updated using kubectl commands.

Most of the times you can find the kube-apiserver pod running in the kube-system namespace.

kubectl get pods -n kube-system

The kubelet loads its config and then starts watching the static pods manifests directory. The path where you are most likely to find the kube-apiserver.yaml definition is /etc/kubernetes/manifests on the K8s node. Here is a unit test for this action in the K8s source code.

Updating /etc/kubernetes/manifests/kube-apiserver.yaml will automatically redeploy the pod with the new config, including the flags you need.

Langsyne answered 16/1 at 15:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.