Search code examples
traefikcockroachdb

Trying to get Traefik to recognise the CockroachDB dashboard


  • UsingMiniKube on Windows 10
  • I have Traefik installed using a Daemonset as per the instructions here

I installed CockroachDB (CD) using:

helm install --name my-release-cockroachdb stable/cockroachdb

As this created services I was expecting Traefik to find the CockroachDB dashboard but it did not. The services created were:

{
  "kind": "Service",
  "apiVersion": "v1",
  "metadata": {
    "name": "my-release-cockroachdb-cockroachdb",
    "namespace": "default",
    "selfLink": "/api/v1/namespaces/default/services/my-release-cockroachdb-cockroachdb",
    "uid": "00316801-a468-11e8-8b41-00155d296111",
    "resourceVersion": "16247",
    "creationTimestamp": "2018-08-20T10:58:42Z",
    "labels": {
      "chart": "cockroachdb-1.2.2",
      "component": "my-release-cockroachdb-cockroachdb",
      "heritage": "Tiller",
      "release": "my-release-cockroachdb"
    },
    "annotations": {
      "prometheus.io/path": "_status/vars",
      "prometheus.io/port": "8080",
      "prometheus.io/scrape": "true",
      "service.alpha.kubernetes.io/tolerate-unready-endpoints": "true"
    }
  },
  "spec": {
    "ports": [
      {
        "name": "grpc",
        "protocol": "TCP",
        "port": 26257,
        "targetPort": 26257
      },
      {
        "name": "http",
        "protocol": "TCP",
        "port": 8081,
        "targetPort": 8081
      }
    ],
    "selector": {
      "component": "my-release-cockroachdb-cockroachdb"
    },
    "clusterIP": "None",
    "type": "ClusterIP",
    "sessionAffinity": "None",
    "publishNotReadyAddresses": true
  },
  "status": {
    "loadBalancer": {}
  }
}

and

{
  "kind": "Service",
  "apiVersion": "v1",
  "metadata": {
    "name": "my-release-cockroachdb-cockroachdb-public",
    "namespace": "default",
    "selfLink": "/api/v1/namespaces/default/services/my-release-cockroachdb-cockroachdb-public",
    "uid": "002ec344-a468-11e8-8b41-00155d296111",
    "resourceVersion": "16186",
    "creationTimestamp": "2018-08-20T10:58:42Z",
    "labels": {
      "chart": "cockroachdb-1.2.2",
      "component": "my-release-cockroachdb-cockroachdb",
      "heritage": "Tiller",
      "release": "my-release-cockroachdb"
    }
  },
  "spec": {
    "ports": [
      {
        "name": "grpc",
        "protocol": "TCP",
        "port": 26257,
        "targetPort": 26257
      },
      {
        "name": "http",
        "protocol": "TCP",
        "port": 8081,
        "targetPort": 8081
      }
    ],
    "selector": {
      "component": "my-release-cockroachdb-cockroachdb"
    },
    "clusterIP": "10.105.70.122",
    "type": "ClusterIP",
    "sessionAffinity": "None"
  },
  "status": {
    "loadBalancer": {}
  }
}

which ultimately tells me that I can use:

kubectl port-forward my-release-cockroachdb-cockroachdb-0 8080

to access the CD dashboard. As I figured Traefik was already consuming 8080 I edited the services (to what you see above to use 8081) and then:

kubectl port-forward my-release-cockroachdb-cockroachdb-0 8081

but that produces:

E0820 21:33:59.676164  432152 portforward.go:331] an error occurred forwarding 8081 -> 8081: error forwarding port 8081 to pod 8b7db5a2feed08f1bc329db69f9623a0c548d5ffae002236c5d7a4181ba326d3, uid : exit status 1: 2018/08/20 11:33:57 socat[44354] E connect(5, AF=2 127.0.0.1:8081, 16): Connection refused
E0820 21:33:59.681160  432152 portforward.go:331] an error occurred forwarding 8081 -> 8081: error forwarding port 8081 to pod 8b7db5a2feed08f1bc329db69f9623a0c548d5ffae002236c5d7a4181ba326d3, uid : exit status 1: 2018/08/20 11:33:57 socat[44355] E connect(5, AF=2 127.0.0.1:8081, 16): Connection refused

So my questions are:

  1. How do I get Traefik to automatically detect the CockroachDB services in particular the CockroachDB Admin GUI
  2. How do I connect to the Cockroach Admin GUI which is behind Traefik?

Solution

  • The cockroach-statefulset.yaml from the helm chart never sets the http port in the start command.

    You'll need to either:

    • keep the port for the CockroachDB UI at :8080
    • or: properly pass a custom port all the way down to the cockroach start command line. This can be done through the --http-port flag.