Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not use kubernetes-pods job #1693

Closed
rvrignaud opened this Issue May 31, 2016 · 5 comments

Comments

Projects
None yet
3 participants
@rvrignaud
Copy link

rvrignaud commented May 31, 2016

I'm using prometheus 0.19.2 in a Google Container Cluster (GKE) (Kubernetes 1.2.4).
'kubernetes-service-endpoints' discovery is working fine.
I'm trying to use 'kubernetes-pods' job but I don't get any target discovered.

My prometheus job definition is a copy/paste of 'kubernetes-pods' as defined in https://github.com/prometheus/prometheus/blob/master/documentation/examples/prometheus-kubernetes.yml

I have a deployment object defined with:

{
  "apiVersion": "extensions/v1beta1",
  "kind": "Deployment",
  "metadata": {
    "name": "telegraf",
    "namespace": "prd"
  },
  "spec": {
    "replicas": 1,
    "template": {
      "metadata": {
        "labels": {
          "name": "telegraf"
        },
        "annotations": {
          "prometheus.io/scrape": "true",
          "prometheus.io/port": "9126"
        }
      },
      "spec": {
        "containers": [
          {
            "name": "telegraf",
            "image": "xxx",
            "resources": {
              "limits": {
                "memory": "100Mi",
                "cpu": "10m"
              }
            },
            "livenessProbe": {
              "httpGet": {
                "path": "/metrics",
                "port": 9126
              },
              "initialDelaySeconds": 30
            },
            "readinessProbe": {
              "httpGet": {
                "path": "/metrics",
                "port": 9126
              }
            },
            "env": [
             ....
            ]
          }
        ]
      }
    }
  }
}

I have pods scheduled and running. But no target is discovered. I'm not sure how to debug this.
I see nothing in prometheus logs relevant.

Am I doing anything wrong ?

@matthiasr

This comment has been minimized.

Copy link
Contributor

matthiasr commented May 31, 2016

I'm not 100% sure but I think you need to declare named ports in your pod spec. At least port 9126 – so just adding "ports": { "name": "telemetry", "containerPort": 9126 } should do.

@rvrignaud

This comment has been minimized.

Copy link
Author

rvrignaud commented May 31, 2016

@matthiasr : thanks that fixed the problem. this may need to be specified in documentation ?
(ports must be an array not a map though)

@matthiasr

This comment has been minimized.

Copy link
Contributor

matthiasr commented May 31, 2016

Indeed! I filed prometheus/docs#455 for that.

@pdbogen

This comment has been minimized.

Copy link
Contributor

pdbogen commented May 31, 2016

FWIW, the issue here is not the name aspect, but that the port appears to not be declared at all.

Edit: On further consideration, the issue is that no port is declared; thus the pod discovery code declined to create a target for pod container a container that claims to provide no network services. I'm discussing in prometheus/docs#455 how to best address this.

@lock

This comment has been minimized.

Copy link

lock bot commented Mar 24, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked and limited conversation to collaborators Mar 24, 2019

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.