k8s 的 traefik pod 如何暴露 80 443 端口? - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Flands
V2EX    Kubernetes

k8s 的 traefik pod 如何暴露 80 443 端口?

  •  
  •   Flands 2020-03-10 01:43:21 +08:00 6068 次点击
    这是一个创建于 2120 天前的主题,其中的信息可能已经有所发展或是发生改变。

    在 k8s 内搭建 traefik,想把 80\443 端口暴露到主机上,使用 helm 搭建时可以做到,但是自己配置添加了
    hostNetwork: true 无效。 helm 搭建的 traefik 的 service 里,在 k8s dashboard 里可以看到,外部端点是有显示

    localhost:80 localhost:443 

    并且在主机上可以直接访问

    traefik-deploy.yaml

    apiVersion: v1 kind: Service metadata: name: traefik namespace: kube-system spec: ports: - name: web protocol: TCP nodePort: 30080 port: 80 targetPort: http - name: websecure protocol: TCP nodePort: 30443 port: 443 - name: admin port: 8080 nodePort: 30880 selector: app: traefik type: NodePort --- apiVersion: apps/v1 kind: DaemonSet metadata: name: traefik-ingress-controller namespace: kube-system labels: app: traefik spec: selector: matchLabels: app: traefik template: metadata: name: traefik labels: app: traefik spec: serviceAccountName: traefik-ingress-controller terminationGracePeriodSeconds: 1 hostNetwork: true containers: - image: traefik:v2.1.6 name: traefik-ingress-lb ports: - name: http containerPort: 80 hostPort: 80 #hostPort 方式,将端口暴露到集群节点 - name: https containerPort: 443 hostPort: 443 #hostPort 方式,将端口暴露到集群节点 - name: admin containerPort: 8080 resources: limits: cpu: 2000m memory: 1024Mi requests: cpu: 1000m memory: 1024Mi securityContext: capabilities: drop: - ALL add: - NET_BIND_SERVICE args: - --cOnfigfile=/config/traefik.yaml volumeMounts: - mountPath: "/config" name: "config" volumes: - name: config configMap: name: traefik-config tolerations: #设置容忍所有污点,防止节点被设置污点 - operator: "Exists" nodeSelector: #设置 node 筛选器,在特定 label 的节点上启动 IngressProxy: "true" 

    搜了一圈文档都没发现怎么做到的,求助一下各位大佬。谢谢

    4 条回复    2020-03-10 15:10:57 +08:00
    binux
        1
    binux  
       2020-03-10 02:05:14 +08:00 via Android
    bind IP address
    hzfyjgw
        2
    hzfyjgw  
       2020-03-10 09:16:39 +08:00
    可以考虑用 nodeselector 的有特定标签的 daemonset 的形式部署 traefik
    Flands
        3
    Flands  
    OP
       2020-03-10 13:26:06 +08:00
    @hzfyjgw 看 yaml 是 DaemonSet 方式部署的
    Flands
        4
    Flands  
    OP
       2020-03-10 15:10:57 +08:00
    service 里 type: LoadBalancer 就好了。。
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     3018 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 25ms UTC 13:27 PVG 21:27 LAX 05:27 JFK 08:27
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86