[英]How do I add a service and traefik ingress to an EKS cluster?
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.