简体   繁体   English

如何将服务和 traefik 入口添加到 EKS 集群?

[英]How do I add a service and traefik ingress to an EKS cluster?

Notes笔记

I am trying to deploy a service and ingress for a demo service (from 'Kubernetes in Action') to an AWS EKS cluster in which the traefik ingress controller has been Helm installed.我正在尝试将演示服务的服务和入口(来自“Kubernetes in Action”)部署到安装了 Helm 的traefik入口控制器的 AWS EKS 集群。

I am able to access the traefik dashboard from the traefik.example.com hostname after manually adding the IP address of the AWS ELB provisioned by traefik to that hostname in my local /etc/hosts file.在我的本地/etc/hosts文件中手动将traefik提供的 AWS ELB 的 IP 地址添加到该主机名后,我能够从traefik.example.com主机名访问 traefik 仪表板。

If I describe the service and ingress of the traefik-dashboard :如果我描述traefik-dashboard的服务和入口:

$ kubectl describe svc -n kube-system traefik-dashboard
Name:              traefik-dashboard
Namespace:         kube-system
Labels:            app=traefik
                   chart=traefik-1.52.6
                   heritage=Tiller
                   release=traefik
Annotations:       <none>
Selector:          app=traefik,release=traefik
Type:              ClusterIP
IP:                10.100.164.81
Port:              <unset>  80/TCP
TargetPort:        8080/TCP
Endpoints:         172.31.27.70:8080
Session Affinity:  None
Events:            <none>

$ kubectl describe ing -n kube-system traefik-dashboard
Name:             traefik-dashboard
Namespace:        kube-system
Address:
Default backend:  default-http-backend:80 (<none>)
Rules:
Host                 Path  Backends
----                 ----  --------
traefik.example.com
                        traefik-dashboard:80 (172.31.27.70:8080)
Annotations:
Events:  <none>

The service and ingress controller seem to be using the running traefik-575cc584fb-v4mfn pod in the kube-system namespace.服务和入口控制器似乎在kube-system命名空间中使用正在运行的traefik-575cc584fb-v4mfn pod。

Given this info and looking at the traefik docs, I try to expose a demo service through its ingress with the following YAML:鉴于此信息并查看 traefik 文档,我尝试使用以下 YAML 通过其入口公开演示服务:

apiVersion: apps/v1beta2
kind: ReplicaSet
metadata:
name: kubia
spec:
replicas: 3
selector:
    matchLabels:
    app: kubia
template:
    metadata:
    labels:
        app: kubia
    spec:
    containers:
    - name: kubia
        image: luksa/kubia

---

apiVersion: v1
kind: Service
metadata:
name: kubia
namespace: default
spec:
selector:
    app: traefik
    release: traefik
ports:
- name: web
    port: 80
    targetPort: 8080

---

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: kubia
namespace: default
spec:
rules:
- host: kubia.int
    http:
    paths:
    - path: /
        backend:
        serviceName: kubia
        servicePort: web

After applying this, I am unable to access the kubia service from the kubia.int hostname after manually adding the IP address of the AWS ELB provisioned by traefik to that hostname in my local /etc/hosts file.应用此之后,我无法访问kubia从服务kubia.int后手动添加AWS ELB的IP地址配置的主机通过traefik在我的地方,以该主机名/etc/hosts的文件。 Instead, I get a Service Unavailable in the response.相反,我在响应中得到了Service Unavailable Describing the created resources shows some differing info.描述创建的资源会显示一些不同的信息。

$ kubectl describe svc kubia
Name:              kubia
Namespace:         default
Labels:            <none>
Annotations:       kubectl.kubernetes.io/last-applied-configuration:
                    {"apiVersion":"v1","kind":"Service","metadata":{"annotations":{},"name":"kubia","namespace":"default"},"spec":{"ports":[{"name":"web","por...
Selector:          app=traefik,release=traefik
Type:              ClusterIP
IP:                10.100.142.243
Port:              web  80/TCP
TargetPort:        8080/TCP
Endpoints:         <none>
Session Affinity:  None
Events:            <none>

$ kubectl describe ing kubia
Name:             kubia
Namespace:        default
Address:
Default backend:  default-http-backend:80 (<none>)
Rules:
Host       Path  Backends
----       ----  --------
kubia.int
            /   kubia:web (<none>)
Annotations:
kubectl.kubernetes.io/last-applied-configuration:  {"apiVersion":"extensions/v1beta1","kind":"Ingress","metadata":{"annotations":{},"name":"kubia","namespace":"default"},"spec":{"rules":[{"host":"kubia.int","http":{"paths":[{"backend":{"serviceName":"kubia","servicePort":"web"},"path":"/"}]}}]}}

Events:  <none>

I also notice that the demo kubia service has no endpoints, and the corresponding ingress shows no available backends.我还注意到演示kubia服务没有端点,相应的入口显示没有可用的后端。

Another thing I notice is that the demo kubia service and ingress is in the default namespace, while the traefik-dashboard service and ingress are in the kube-system namespace.我注意到的另一件事是演示kubia服务和入口位于default命名空间中,而traefik-dashboard服务和入口位于kube-system命名空间中。

Does anything jump out to anyone?有什么东西会跳出来给任何人吗? Any suggestions on the best way to diagnose it?关于诊断它的最佳方法有什么建议吗?

Many thanks in advance!提前谢谢了!

It would seem that you are missing the kubernetes.io/ingress.class: traefik that tells your Traefik ingress controller to serve for that Ingress definition.您似乎缺少kubernetes.io/ingress.class: traefik ,它告诉您的 Traefik 入口控制器为该入口定义服务。

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: kubia
  namespace: default
  annotations:
    kubernetes.io/ingress.class: traefik
spec:
rules:
- host: kubia.int
    http:
    paths:
    - path: /
        backend:
        serviceName: kubia
        servicePort: web

If you look at the examples in the docs you can see that the only Ingress that doesn't have annotation is traefik-web-ui that points to the Traefik Web UI.如果您查看文档中的示例,您会发现唯一没有注释的 Ingress 是指向 Traefik Web UI 的traefik-web-ui

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 用于Kubernetes(AWS EKS)的Traefik入口控制器 - Traefik Ingress Controller for Kubernetes (AWS EKS) 在 AWS EKS 上使用 keycloak 身份验证的 traefik 入口 - traefik ingress with keycloak authentication on AWS EKS 如何通过 CDK 创建带节点的 EKS 集群? - How do I create an EKS cluster with nodes via CDK? 如何使用 Helm 但使用 ALB 而不是 ELB 在 EKS 上安装 Traefik? - How do I install Traefik on EKS using Helm but with an ALB instead of an ELB? 如何让 traefik.ingress.kubernetes.io/rule-type: PathPrefixStrip 工作? - How do I get traefik.ingress.kubernetes.io/rule-type: PathPrefixStrip to work? 如何向 EKS 集群实例添加自定义标签 - How to add custom tag to the EKS cluster instance 如何通过kubernetes上的traefik入口控制器使cockroachdb的管理ui公开可用? - How do I make my admin ui of cockroachdb publicly available via traefik ingress controller on kubernetes? EKS 集群未在 Ingress controller 上显示我的 IP - EKS cluster is not showing my an IP on the Ingress controller 如何在 eks 中将内容安全策略添加到 nginx 入口 controller - How to add content-security-policy to nginx ingress controller in eks 如何向 Traefik Ingress Controller 后面的微服务添加缓存? - how to add caching to Microservices behind Traefik Ingress Controller?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM