我使用以下方法安装了CockroachDB(CD):
helm install --name my-release-cockroachdb stable/cockroachdb
在创建服务时,我期望Traefik找到CockroachDB仪表板,但没有找到。创建的服务是:
{
"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": {}
}
}
和
{
"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": {}
}
}
这最终告诉我可以使用:
kubectl port-forward my-release-cockroachdb-cockroachdb-0 8080
访问CD仪表板。当我发现Traefik已经使用了8080时,我编辑了服务(使用8081,您可以看到上面的内容),然后:
kubectl port-forward my-release-cockroachdb-cockroachdb-0 8081
但是会产生:
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
所以我的问题是:
答案 0 :(得分:1)
掌舵图中的cockroach-statefulset.yaml从未在start command中设置http端口。
您需要:
:8080
保留CockroachDB UI的端口cockroach start
命令行。这可以通过--http-port
标志来完成。