无法通过traefik反向代理访问我的Kubernetes服务

时间:2018-05-16 09:03:46

标签: kubernetes prometheus traefik

我在云openstack pf中部署kubernetes集群(1.8.8)(1个主公用IP地址/ 3个节点)。我想使用traefik(最新版本1.6.1)作为访问我的服务的反向代理。

Traefik作为守护进程部署得很好,我可以在端口8081上访问他的GUI。我的prometheus入口在traefik界面中正确显示但我无法访问我的prometheus服务器UI。

你告诉我我做错了吗?我错过了什么 ?

由于

我的普罗米修斯的入口:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: prometheus-ingress
  annotations:
    kubernetes.io/ingress.class: traefik
    traefik.frontend.rule.type: pathprefixstrip
spec:
  rules:
  - http:
      paths:
      - path: /prometheus
        backend:
          serviceName: prometheus-svc
          servicePort: prom

我的守护进程如下:

apiVersion: v1
kind: Namespace
metadata:
  name: traefik
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: traefik-ingress-controller
  namespace: traefik
---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
 name: traefik-ingress-controller
 namespace: traefik
 labels:
   k8s-app: traefik-ingress-lb
   kubernetes.io/cluster-service: "true"
spec:
 template:
   metadata:
     labels:
       k8s-app: traefik-ingress-lb
       name: traefik-ingress-lb
   spec:
     hostNetwork: true # workaround
     serviceAccountName: traefik-ingress-controller
     terminationGracePeriodSeconds: 60
     tolerations:
     - key: node-role.kubernetes.io/master
       effect: NoSchedule
     containers:
     - image: traefik:v1.6.1
       name: traefik-ingress-lb
       imagePullPolicy: Always
       volumeMounts:
         - mountPath: "/config"
           name: "config"
       resources:
         requests:
           cpu: 100m
           memory: 20Mi
       args:
       - --kubernetes
       - --configfile=/config/traefik.toml
     volumes:
     - name: config
       configMap:
         name: traefik-conf
---
apiVersion: v1
kind: Service
metadata:
  name: traefik-web-ui
  namespace: traefik
spec:
  selector:
    k8s-app: traefik-ingress-lb
  ports:
  - port: 80
    targetPort: 8080
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: traefik-web-ui
  namespace: traefik
  annotations:
    kubernetes.io/ingress.class: traefik
    traefik.frontend.rule.type: pathprefixstrip
spec:
  rules:
  - host: example.com
    http:
      paths:
      - backend:
          serviceName: traefik-web-ui
          servicePort: 80
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: traefik-ingress-controller
rules:
  - apiGroups:
      - ""
    resources:
      - services
      - endpoints
      - secrets
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - extensions
    resources:
      - ingresses
    verbs:
      - get
      - list
      - watch
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: traefik-ingress-controller
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: traefik-ingress-controller
subjects:
- kind: ServiceAccount
  name: traefik-ingress-controller
  namespace: kube-system
---
apiVersion: v1
kind: ConfigMap
metadata:
 name: traefik-conf
 namespace: traefik
data:
 traefik.toml: |-
   defaultEntryPoints = ["http"]

   [entryPoints]
     [entryPoints.http]
       address = ":80"

   [web]
     address = ":8081"

0 个答案:

没有答案