开发者社区> 问答> 正文

创建了无负载均衡器,并在GKE上为traefik ingress分配了静态IP

k8s小能手 2019-02-22 16:11:28 418

当我设置一个入口控制器指向traefik服务时,我希望能够以与LoadBalancer服务相同的方式为GKE上的入口控制器创建负载平衡器。然后我可以指向创建的静态IP。

但是,当我获得我的入口时,没有分配静态IP。

$ kubectl get ingresses -n kube-system
NAME HOSTS ADDRESS PORTS AGE
traefik-ingress traefik-ui.minikube 80 4m
traefik-ingress.yml

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: traefik-ingress
namespace: kube-system
annotations:

kubernetes.io/ingress.class: traefik

spec:
rules:

- host: traefik-ui.minikube
  http:
    paths:
      - path: "/"
        backend:
          serviceName: traefik-ingress-service
          servicePort: 80

traefik-deployment.yml


apiVersion: v1
kind: ServiceAccount
metadata:
name: traefik-ingress-controller

namespace: kube-system

kind: Deployment
apiVersion: apps/v1
metadata:
name: traefik-ingress-controller
namespace: kube-system
labels:

k8s-app: traefik-ingress-lb

spec:
replicas: 1
selector:

matchLabels:
  k8s-app: traefik-ingress-lb

template:

metadata:
  labels:
    k8s-app: traefik-ingress-lb
    name: traefik-ingress-lb
spec:
  serviceAccountName: traefik-ingress-controller
  terminationGracePeriodSeconds: 60
  containers:
    - image: traefik
      name: traefik-ingress-lb
      ports:
        - name: http
          containerPort: 80
        - name: admin
          containerPort: 8080
      args:
        - --api
        - --kubernetes
        - --logLevel=INFO

kind: Service
apiVersion: v1
metadata:
name: traefik-ingress-service
namespace: kube-system
spec:
selector:

k8s-app: traefik-ingress-lb

ports:

- protocol: TCP
  port: 80
  name: web
- protocol: TCP
  port: 8080
  name: admin

type: NodePort

Kubernetes 网络协议 API 容器
分享到
取消 提交回答
全部回答(1)
  • k8s小能手
    2019-07-17 23:29:13

    您正在Service为traefik部署创建一个对象,但您已使用该NodePort类型,该类型只能从集群内部访问。如果你想让Kubernetes为a创建一个LoadBalancer Service,你需要LoadBalancer在服务中指定类型,所以你的traefik Service看起来像

    kind: Service
    apiVersion: v1
    metadata:
    name: traefik-ingress-service
    namespace: kube-system
    spec:
    selector:

    k8s-app: traefik-ingress-lb

    ports:

    - protocol: TCP
      port: 80
      name: web
    - protocol: TCP
      port: 8080
      name: admin

    type: LoadBalancer
    这将与GKE API对话,并为您创建一个带有IP的LoadBalancer。

    0 0
+ 订阅

云原生时代,是开发者最好的时代

推荐文章
相似问题
推荐课程