Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

kube-proxy config configmap missing - where is it ? needed for Prometheus operator #2652

Closed
sd2302 opened this issue Jan 30, 2020 · 19 comments
Closed
Labels
bug Something isn't working stale

Comments

@sd2302
Copy link

sd2302 commented Jan 30, 2020

Describe the bug

Per https://github.com/helm/charts/tree/master/stable/prometheus-operator

for Prometheus to scrape kubelet, we need to change kublet config as below

kubectl -n kube-system edit cm kube-proxy

But in aks-engine this cm for kube-proxy is missing

So where is the config for kubelet ?

we need change the following metricsBindAddress for prometheus to work correctly

apiVersion: v1
data:
config.conf: |-
apiVersion: kubeproxy.config.k8s.io/v1alpha1
kind: KubeProxyConfiguration
# ...
# metricsBindAddress: 127.0.0.1:10249
metricsBindAddress: 0.0.0.0:10249
# ...
kubeconfig.conf: |-

Steps To Reproduce

Expected behavior

kubectl -n kube-system edit cm kube-proxy should work ?

AKS Engine version

Version: v0.45.0

Kubernetes version

15.4

Additional context

Deploying prometheus operator for K8 monitoring for aks-engine

@sd2302 sd2302 added the bug Something isn't working label Jan 30, 2020
@jackfrancis
Copy link
Member

@jackfrancis
Copy link
Member

Actually the >= 1.16 kube-proxy specs have a kube-proxy-config ConfigMap defined.

On a 1.16 cluster I just built w/ aks-engine:

$ kubectl get nodes
NAME                                 STATUS   ROLES    AGE     VERSION
k8s-agentpool1-31548157-vmss000000   Ready    agent    2m59s   v1.16.6
k8s-agentpool1-31548157-vmss000001   Ready    agent    99s     v1.16.6
k8s-master-31548157-0                Ready    master   2m59s   v1.16.6
$ k get configmap kube-proxy-config -n kube-system -o yaml
apiVersion: v1
data:
  config.yaml: |
    apiVersion: kubeproxy.config.k8s.io/v1alpha1
    kind: KubeProxyConfiguration
    clientConnection:
      kubeconfig: /var/lib/kubelet/kubeconfig
    clusterCIDR: "10.240.0.0/12"
    mode: "iptables"
    featureGates:
      {}
kind: ConfigMap
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"v1","data":{"config.yaml":"apiVersion: kubeproxy.config.k8s.io/v1alpha1\nkind: KubeProxyConfiguration\nclientConnection:\n  kubeconfig: /var/lib/kubelet/kubeconfig\nclusterCIDR: \"10.240.0.0/12\"\nmode: \"iptables\"\nfeatureGates:\n  {}\n"},"kind":"ConfigMap","metadata":{"annotations":{},"labels":{"addonmanager.kubernetes.io/mode":"Reconcile","component":"kube-proxy","k8s-app":"kube-proxy","kubernetes.io/cluster-service":"true","tier":"node"},"name":"kube-proxy-config","namespace":"kube-system"}}
  creationTimestamp: "2020-01-30T23:10:47Z"
  labels:
    addonmanager.kubernetes.io/mode: Reconcile
    component: kube-proxy
    k8s-app: kube-proxy
    kubernetes.io/cluster-service: "true"
    tier: node
  name: kube-proxy-config
  namespace: kube-system
  resourceVersion: "389"
  selfLink: /api/v1/namespaces/kube-system/configmaps/kube-proxy-config
  uid: 18fb07d4-6a46-49f4-a414-261c54f98b6d

Note that ConfigMap is named kube-proxy-config. The prometheus docs suggest that's normal.

Depending on the cluster, the relevant part config.conf will be in ConfigMap kube-system/kube-proxy or kube-system/kube-proxy-config

Ref:

https://github.com/helm/charts/tree/master/stable/prometheus-operator#kubeproxy

@sd2302
Copy link
Author

sd2302 commented Jan 31, 2020

@jackfrancis
Thanks.

I am on 1.15.4

Where would I put the metricsBindAddress: 0.0.0.0:10249 in the daemonset.apps/kube-proxy ?

@jackfrancis
Copy link
Member

You'll have to add the configmap yourself on 1.15.4, as aks-engine didn't create one on cluster creation.

@sd2302
Copy link
Author

sd2302 commented Jan 31, 2020

Thanks, even in 1.16, where exactly would i put the metricsBindAddress: 0.0.0.0:1024 ?

I dont see kind: KubeProxyConfiguration in the 1.16 configmaps

@jackfrancis
Copy link
Member

Looks like it wants it in the config.conf data key. There isn't one in the aks-engine-provided ConfigMap in >= 1.16, so you'll have to add it (probably via vi) when you do kubectl -n kube-system edit cm kube-proxy-config.

@sd2302
Copy link
Author

sd2302 commented Jan 31, 2020

Thanks.

In 1.15.4, i tried to add --metrics-bind-address=0.0.0.0:10249 in the kube-proxy spec as below but the deamonset is not taking it

spec:
containers:
- command:
- /hyperkube
- kube-proxy
- --kubeconfig=/var/lib/kubelet/kubeconfig
- --cluster-cidr=10.240.0.0/12
- --feature-gates=ExperimentalCriticalPodAnnotation=true
- --proxy-mode=iptables
- --metrics-bind-address=0.0.0.0:10249

https://kubernetes.io/docs/reference/command-line-tools-reference/kube-proxy/

@jackfrancis
Copy link
Member

Right, the above is adding an additional arg --metrics-bind-address to the kube-proxy runtime; I assume that the kube-proxy runtime doesn't expect that argument.

@sd2302
Copy link
Author

sd2302 commented Jan 31, 2020

Per this https://kubernetes.io/docs/reference/command-line-tools-reference/kube-proxy/

it support it but unsure why the aks-engine deamon-set not taking it ?

--metrics-bind-address 0.0.0.0     Default: 127.0.0.1:10249

  | The IP address for the metrics server to serve on (set to 0.0.0.0 for all IPv4 interfaces and :: for all IPv6 interfaces)

@jackfrancis
Copy link
Member

Those are the 1.17 docs, perhaps it was introduced after 1.15?

FWIW, there's nothing special about the kube-proxy that aks-engine delivers, it's the vanilla, upstream package.

@sd2302
Copy link
Author

sd2302 commented Jan 31, 2020

i am going to deploy aks 1.17 tomorrow and test this out. i really need to deploy prometheus-operator helm chart and prometheus is not discovering the targets b/c of the --metrics-bind-address issue

@jackfrancis
Copy link
Member

Thanks for sticking it out, let us know how that goes!

@sd2302
Copy link
Author

sd2302 commented Feb 3, 2020

I re-deployed using 16.4 and tried to update the kube-proxy-config configmap and it immediately removes it

Is that a aks-engine issue ?

i really need to have kube-proxy-config persist the value of metricsBindAddress: 0.0.0.0:10249

sysdev@imabvlsys-496:~/aks-engine/aksengine-testbluev2/_output/tdcmastertestbluev2-5e38750b$ kubectl describe cm/kube-proxy-config -n kube-system
Name: kube-proxy-config
Namespace: kube-system
Labels: addonmanager.kubernetes.io/mode=Reconcile
component=kube-proxy
k8s-app=kube-proxy
kubernetes.io/cluster-service=true
tier=node
Annotations: kubectl.kubernetes.io/last-applied-configuration:
{"apiVersion":"v1","data":{"config.yaml":"apiVersion: kubeproxy.config.k8s.io/v1alpha1\nkind: KubeProxyConfiguration\nclientConnection:\n ...

Data

config.yaml:

apiVersion: kubeproxy.config.k8s.io/v1alpha1
kind: KubeProxyConfiguration
clientConnection:
kubeconfig: /var/lib/kubelet/kubeconfig
clusterCIDR: "10.240.0.0/12"
metricsBindAddress: 0.0.0.0:10249
mode: "iptables"
featureGates:
{}

Events:
sysdev@imabvlsys-496:~/aks-engine/aksengine-testbluev2/_output/tdcmastertestbluev2-5e38750b$ kubectl describe cm/kube-proxy-config -n kube-system
Name: kube-proxy-config
Namespace: kube-system
Labels: addonmanager.kubernetes.io/mode=Reconcile
component=kube-proxy
k8s-app=kube-proxy
kubernetes.io/cluster-service=true
tier=node
Annotations: kubectl.kubernetes.io/last-applied-configuration:
{"apiVersion":"v1","data":{"config.yaml":"apiVersion: kubeproxy.config.k8s.io/v1alpha1\nkind: KubeProxyConfiguration\nclientConnection:\n ...

Data

config.yaml:

apiVersion: kubeproxy.config.k8s.io/v1alpha1
kind: KubeProxyConfiguration
clientConnection:
kubeconfig: /var/lib/kubelet/kubeconfig
clusterCIDR: "10.240.0.0/12"
mode: "iptables"
featureGates:
{}

Events:

@jackfrancis
Copy link
Member

Ah, yes. That's because:

addonmanager.kubernetes.io/mode: Reconcile

in the ConfigMap spec.

in the kube-proxy spec. You could do this right now. On each master vm:

$ sudo vi /etc/kubernetes/addons/kube-proxy-daemonset.yaml

Change the above to this in the ConfigMap spec:

addonmanager.kubernetes.io/mode: EnsureExists

Then, kick the kube-addon-manager pod to pick up the new settings:

$ k delete pod kube-addon-manager-k8s-master-19456504-0 -n kube-system

(kube-addon-manager-k8s-master-19456504-0 was the running kube-addon-manager pod on my single master cluster, you'll want to find the pod(s) particular to your cluster)

You should then be able to modify the ConfigMap.

I've filed this issue to make this less difficult going forward:

#2672

@sd2302
Copy link
Author

sd2302 commented Feb 4, 2020

@jackfrancis

Thanks. that worked.

With 16.4 K8 version, we are getting the metrics from Prom/Grafana helm operators and stack but yet the kubelet shows down in Prom configs. I need to open a bug with the Prom operator team. and i will update here how that goes. Right now even after setting metricsBindAddress: 0.0.0.0:10249, it is prom is scraping to internal-node-ip:10249

@jackfrancis
Copy link
Member

Thanks for keeping us up-to-date. Bon courage

@stale
Copy link

stale bot commented Apr 7, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Apr 7, 2020
@stale stale bot closed this as completed Apr 14, 2020
@dbrennand
Copy link

dbrennand commented Jul 14, 2020

Hey @jackfrancis

I just ran into this issue with my k8s cluster deployed on Azure Stack Hub.

Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.5", GitCommit:"e6503f8d8f769ace2f338794c914a96fc335df0f", GitTreeState:"clean", BuildDate:"2020-06-26T03:47:41Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"windows/amd64"}
Server Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.9", GitCommit:"d2ea02d7bcf37724adabbdb9d37ede0cf2c0d627", GitTreeState:"clean", BuildDate:"2020-04-24T22:59:19Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"}

I am deploying the bitnami/prometheus-operator and realised kube-proxy metrics were not being collected.
When I attempt to alter the configmap by adding the metricsBindAddress it also keeps being altered back.

The workaround provided isn't ideal and I see a enchancement was raised #2672 but never acted upon. Is there any way to make this process easier going forward?

Many Thanks.

@jackfrancis
Copy link
Member

Hi @dbrennand, I've re-opened #2672 so we can track enabling the kube-addon-manager mode.

Just FYI, you'll want to ensure that your kubectl client is running the same version as the cluster you're managing (I see you're managing a 1.16.9 cluster w/ the 1.18.5 client). You may not run into any issues, but any API breaking changes between minor versions will affect you here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working stale
Projects
None yet
Development

No branches or pull requests

3 participants