如何在Google Container Engine上运行kubernetes后面的traefik?

时间:2016-12-01 01:56:41

标签: kubernetes devops google-kubernetes-engine

所以我有Traefik"跑步"在Kubernetes:

apiVersion: v1
kind: Service
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: '{"kind":"Service","apiVersion":"v1","metadata":{"name":"traefik","namespace":"kube-system","creationTimestamp":null,"labels":{"k8s-app":"traefik-ingress-lb"}},"spec":{"ports":[{"name":"http","port":80,"targetPort":80},{"name":"https","port":443,"targetPort":443}],"selector":{"k8s-app":"traefik-ingress-lb"},"type":"LoadBalancer"},"status":{"loadBalancer":{}}}'
  creationTimestamp: 2016-11-30T23:15:49Z
  labels:
    k8s-app: traefik-ingress-lb
  name: traefik
  namespace: kube-system
  resourceVersion: "9672"
  selfLink: /api/v1/namespaces/kube-system/services/traefik
  uid: ee07b957-b752-11e6-88fa-42010af00083
spec:
  clusterIP: 10.11.251.200
  ports:
  - name: http
    nodePort: 30297
    port: 80
    protocol: TCP
    targetPort: 80
  - name: https
    nodePort: 30247
    port: 443
    protocol: TCP
    targetPort: 443
  selector:
    k8s-app: traefik-ingress-lb
  sessionAffinity: None
  type: LoadBalancer
status:
  loadBalancer:
    ingress:
    - ip: # IP THAT IS ALLOCATED BY k8s BUT NOT ASSIGNED
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "1"
    kubectl.kubernetes.io/last-applied-configuration: '###'
creationTimestamp: 2016-11-30T22:59:07Z
  generation: 2
  labels:
    k8s-app: traefik-ingress-lb
  name: traefik-ingress-controller
  namespace: kube-system
  resourceVersion: "23438"
  selfLink: /apis/extensions/v1beta1/namespaces/kube-system/deployments/traefik-ingress-controller
  uid: 9919ff46-b750-11e6-88fa-42010af00083
spec:
  replicas: 1
  selector:
    matchLabels:
      k8s-app: traefik-ingress-lb
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        k8s-app: traefik-ingress-lb
        name: traefik-ingress-lb
        version: v1.1
    spec:
      containers:
      - args:
        - --web
        - --kubernetes
        - --configFile=/etc/config/traefik.toml
        - --logLevel=DEBUG
        image: gcr.io/myproject/traefik
        imagePullPolicy: Always
        name: traefik-ingress-lb
        ports:
        - containerPort: 80
          hostPort: 80
          protocol: TCP
        - containerPort: 8080
          protocol: TCP
        resources:
          limits:
            cpu: 200m
            memory: 30Mi
          requests:
            cpu: 100m
            memory: 20Mi
        terminationMessagePath: /dev/termination-log
        volumeMounts:
        - mountPath: /etc/config
          name: config-volume
        - mountPath: /etc/traefik
          name: traefik-volume
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      securityContext: {}
      terminationGracePeriodSeconds: 60
      volumes:
      - configMap:
          defaultMode: 420
          name: traefik-config
        name: config-volume
      - emptyDir: {}
        name: traefik-volume
status:
  observedGeneration: 2
  replicas: 1
  unavailableReplicas: 1
  updatedReplicas: 1

我的问题是Kubernetes分配的外部IP实际上没有转发给Traefik;实际上,分配的IP甚至没有显示在我的Google Cloud Platform控制台中。如何让Traefik在Google Container Engine上使用负载均衡器?

2 个答案:

答案 0 :(得分:0)

如果你这样做

kubectl describe svc/traefik

endpoints是否匹配以下IP:

kubectl get po -lk8s-app=traefik-ingress-lb -o wide

点击LB IP后会发生什么?是无限期加载,还是获得不同的服务?

答案 1 :(得分:0)

有一个新的Traefik分支,据说修复了一些kubernetes问题。然而,我做了进一步的阅读和谈论Traefik,并发现了一些(最近)潜在不稳定的建议。虽然在新软件中可以预料到这一点,但我决定切换到NGINX来处理我的反向代理。它工作得非常好,所以我将继续关闭这个问题。