开发者社区> 问答> 正文

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

当我设置一个入口控制器指向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

展开
收起
k8s小能手 2019-02-22 16:11:28 2863 0
1 条回答
写回答
取消 提交回答
  • 整合最优质的专家资源和技术资料,问答解疑

    您正在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。

    2019-07-17 23:29:13
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
《应用型负载均衡ALB产品解读》 立即下载
阿里云网络-SLB负载均衡产品介绍 立即下载
负载均衡SLB热点问题解答 立即下载