Kubernetes专用cockroachdb节点-通过traefik入口控制器访问管理ui失败-页面未正确重定向
我有一个运行cockroachdb的专用kubernetes节点。豆荚已安排好,一切就绪。我想从子域访问管理UI,例如:cockroachdb.hostname.com。我已经使用traefik仪表板和ceph仪表板完成了此操作,所以我知道我的入口设置正在工作。我什至运行cert-manager来启用https。我从浏览器中看到页面无法正确重定向的错误。
我必须在特殊的地方指定主机名吗?
我尝试添加失败,没有成功:--http-host cockroachdb.hostname.com
此专用节点具有其自己的公共IP,该IP未映射到hostname.com。我想我需要更改cockroachdb中的设置,但是我不知道是哪个,因为我是新手。
有人知道如何通过入口发布管理界面吗?
EDIT01:添加了入口和服务配置文件
入口:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: cockroachdb-public
annotations:
kubernetes.io/ingress.class: traefik
traefik.frontend.rule.type: PathPrefixStrip
certmanager.k8s.io/issuer: "letsencrypt-prod"
certmanager.k8s.io/acme-challenge-type: http01
ingress.kubernetes.io/ssl-redirect: "true"
ingress.kubernetes.io/ssl-temporary-redirect: "true"
ingress.kubernetes.io/ssl-host: "cockroachdb.hostname.com"
traefik.frontend.rule: "Host:cockroachdb.hostname.com,www.cockroachdb.hostname.com"
traefik.frontend.redirect.regex: "^https://www.cockroachdb.hostname.com(.*)"
traefik.frontend.redirect.replacement: "https://cockroachdb.hostname.com/$1"
spec:
rules:
- host: cockroachdb.hostname.com
http:
paths:
- path: /
backend:
serviceName: cockroachdb-public
servicePort: http
- host: www.cockroachdb.hostname.com
http:
paths:
- path: /
backend:
serviceName: cockroachdb-public
servicePort: http
tls:
- hosts:
- cockroachdb.hostname.com
- www.cockroachdb.hostname.com
secretName: cockroachdb-secret
服务:
apiVersion: v1
kind: Service
metadata:
# This service is meant to be used by clients of the database. It exposes a ClusterIP that will
# automatically load balance connections to the different database pods.
name: cockroachdb-public
labels:
app: cockroachdb
spec:
ports:
# The main port, served by gRPC, serves Postgres-flavor SQL, internode
# traffic and the cli.
- port: 26257
targetPort: 26257
name: grpc
# The secondary port serves the UI as well as health and debug endpoints.
- port: 8080
targetPort: 8080
name: http
selector:
app: cockroachdb
EDIT02:
我现在可以访问Admin UI页面,但是只能通过使用端口8080的服务器的外部IP地址进行访问。我想我需要告诉服务器其IP地址已映射到正确的子域?
EDIT03:
在两个预定的traefik-inress吊舱上创建以下日志:
time="2019-04-29T04:31:42Z" level=error msg="Service not found for default/cockroachdb-public"
答案 0 :(得分:1)
您的引用在入口端看起来不错。您正在使用很多重定向,除非您真的知道每个人都在做什么,否则就不要使用它们,否则可能会陷入无限循环的重定向中。
您可以查看以下日志和调试方法:
运行@IBOutlet
并查看最后一批日志。
运行kubectl logs <traefik pod>
,据我所知,这可能是您的主要问题。确保您的服务存在于默认名称空间中。
运行kubectl get service
,然后尝试通过kubectl port-forward svc/cockroachdb-public 8080:8080
连接到它,并查看终端以获取潜在的错误消息。
运行localhost:8080
并查看事件,这应该为您提供一些帮助。
尝试从运行kubectl describe ingress cockroachdb-public
的另一个Pod中访问服务,并查看它是否解析IP地址。
看看您的clusterrolebindings和serviceaccount,它可能受到限制并且没有权限在默认名称空间中列出服务:ping cockroachdb-public.default.svc.cluster.local