伍佰目录 短网址
  当前位置:海洋目录网 » 站长资讯 » 站长资讯 » 文章详细 订阅RssFeed

K8S ingress控制器 (三)

来源:本站原创 浏览:222次 时间:2021-05-11
认识traefik

参考: https://traefik.cn/
是一个为了让部署微服务更加便捷而诞生的现代HTTP反向代理、负载均衡工具。 它支持多种后台 (Docker, Swarm, Kubernetes, Marathon, Mesos, Consul, Etcd, Zookeeper, BoltDB, Rest API, file…) 来自动化、动态的应用它的配置文件设置。

traefik部署

mkdir traefik/
cd traefik/

编排ConfigMap

vim traefik-config.yaml

apiVersion: v1kind: ConfigMapmetadata:  name: traefik-config  namespace: kube-systemdata:  traefik.toml: |    defaultEntryPoints = ["http","https"]    debug = false    logLevel = "INFO"    InsecureSkipVerify = true    [entryPoints]      [entryPoints.http]      address = ":80"      compress = true      [entryPoints.https]      address = ":443"        [entryPoints.https.tls]      address = ":8080"    [kubernetes]    [metrics]      [metrics.prometheus]      buckets=[0.1,0.3,1.2,5.0]      entryPoint = "traefik"    [ping]    entryPoint = "http"
编排SA与DaemonSet

vim traefik-ds.yaml

apiVersion: v1kind: ServiceAccountmetadata:  name: traefik-ingress-controller  namespace: kube-system---kind: DaemonSetapiVersion: apps/v1metadata:  name: traefik-ingress-controller-v2  namespace: kube-system  labels:    k8s-app: traefik-ingress-lbspec:  selector:    matchLabels:      name: traefik-ingress-lb-v2  template:    metadata:      labels:        k8s-app: traefik-ingress-lb        name: traefik-ingress-lb-v2    spec:      serviceAccountName: traefik-ingress-controller      terminationGracePeriodSeconds: 60      containers:      - image: traefik:2.1.6        name: traefik-ingress-lb-v2        ports:        - name: http          containerPort: 80          hostPort: 80        - name: admin          containerPort: 8080          hostPort: 8080        securityContext:          capabilities:            drop:            - ALL            add:            - NET_BIND_SERVICE        args:        - --api        - --api.insecure=true        - --providers.kubernetesingress=true        - --log.level=INFO      volumes:      - configMap:          name: traefik-config        name: config---kind: ServiceapiVersion: v1metadata:  name: traefik-ingress-service-v2  namespace: kube-system  labels:    k8s-app: traefik-ingress-lb-v2spec:  selector:    k8s-app: traefik-ingress-lb-v2  ports:    - protocol: TCP      port: 80      name: web    - protocol: TCP      port: 8080      name: admin
编排rbac

[root@master1 traefik]# vim traefik-rbac.yaml

kind: ClusterRoleapiVersion: rbac.authorization.k8s.io/v1beta1metadata:  name: traefik-ingress-controllerrules:  - apiGroups:      - ""    resources:      - services      - endpoints      - secrets    verbs:      - get      - list      - watch  - apiGroups:      - extensions    resources:      - ingresses    verbs:      - get      - list      - watch  - apiGroups:    - extensions    resources:    - ingresses/status    verbs:    - update---kind: ClusterRoleBindingapiVersion: rbac.authorization.k8s.io/v1beta1metadata:  name: traefik-ingress-controllerroleRef:  apiGroup: rbac.authorization. k8s.io  kind: ClusterRole  name: traefik-ingress-controllersubjects:- kind: ServiceAccount  name: traefik-ingress-controller  namespace: kube-system
编排dashborad

vim traefik-dashboard.yaml

apiVersion: v1kind: Servicemetadata:  name: traefik-web-ui  namespace: kube-systemspec:  selector:    k8s-app: traefik-ingress-lb  ports:  - name: web    port: 80    targetPort: 8080---apiVersion: extensions/v1beta1kind: Ingressmetadata:  name: traefik-web-ui  namespace: kube-systemspec:  rules:  - host: traefik-daniel.com                    # 这里换成自己的域名(实验环境模拟一个就OK)    http:      paths:      - path: /        backend:          serviceName: traefik-web-ui          servicePort: 80
应用YAML

ls

kubectl apply -f .

验证

kubectl get pods -n kube-system |grep traefik

[root@master1 traefik]# kubectl get svc -n kube-system |grep traefik

访问

1.用宿主机模拟客户端
vim /etc/hosts

192.168.154.139 traefik-daniel.com # 添加域名与任意k8s集群节点的绑定

2.客户端firefox访问traefik-daniel.com

3.或者使用任意k8s集群节点IP:8080访问

  推荐站点

  • At-lib分类目录At-lib分类目录

    At-lib网站分类目录汇集全国所有高质量网站,是中国权威的中文网站分类目录,给站长提供免费网址目录提交收录和推荐最新最全的优秀网站大全是名站导航之家

    www.at-lib.cn
  • 中国链接目录中国链接目录

    中国链接目录简称链接目录,是收录优秀网站和淘宝网店的网站分类目录,为您提供优质的网址导航服务,也是网店进行收录推广,站长免费推广网站、加快百度收录、增加友情链接和网站外链的平台。

    www.cnlink.org
  • 35目录网35目录网

    35目录免费收录各类优秀网站,全力打造互动式网站目录,提供网站分类目录检索,关键字搜索功能。欢迎您向35目录推荐、提交优秀网站。

    www.35mulu.com
  • 就要爱网站目录就要爱网站目录

    就要爱网站目录,按主题和类别列出网站。所有提交的网站都经过人工审查,确保质量和无垃圾邮件的结果。

    www.912219.com
  • 伍佰目录伍佰目录

    伍佰网站目录免费收录各类优秀网站,全力打造互动式网站目录,提供网站分类目录检索,关键字搜索功能。欢迎您向伍佰目录推荐、提交优秀网站。

    www.wbwb.net