我有一个本地 Kubernetes 集群。根据 traefik 给出的示例,我在集群中运行了 traefik。它绑定到一个节点,这将是我的负载均衡器。我可以通过使用路由点击节点端口来访问正在运行的服务(通过入口)。例如http://build.mydomain.com:NODEPORT会将我路由到我的 Jenkins。
但我希望能够通过简单地输入http://build.mydomain.com来访问我的 Jenkins
这是可能的还是我必须在集群外运行 traefik ?
基本上我只希望负载均衡器上的所有内容都达到 80 以访问 traefik 入口控制器,该控制器应该根据入口来路由请求。
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: traefik-ingress-controller
namespace: kube-system
---
kind: Deployment
apiVersion: extensions/v1beta1
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
nodeSelector:
node-role.kubernetes.io/worker: loadbalancer
---
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