I am trying a Basic Local Configuration using still a Kubernates Ingress leveraging on Traefik 2.2.
I am deploying on my local cluster environment using K8S on DockerForMac with Kind as Cluster Provider.
Well, I am aware that this is a pretty cumbersome configuration and all the issues related to MacOS with ports missing docker bridge. But apparently everything works correctly, even exposing Dashboard works.
What is strange is that.
When I use this kind of configuration:
- path: /play
backend:
serviceName: kind-play-svc
servicePort: 3000
If I access from browser:
http://localhost:<tricky_port_on_host>/play
I receive a Cannot GET
But if i change path to:
- path: /
backend:
serviceName: kind-play-svc
servicePort: 3000
And I apply that change. Everything is working smootly, and I can access my service at:
http://localhost:<tricky_port_on_host>/
or either service subroutes works, as
http://localhost:<tricky_port_on_host>/firebase
The service is a simple ExpressJs Router of few Backend Api route paths.
I will post my configuration... Apparently the configuration is working, probably I am misunderstanding something?
Thank you for driving me toward the right path!
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: traefik-ingress-controller
rules:
- apiGroups:
- ""
resources:
- services
- endpoints
- secrets
verbs:
- get
- list
- watch
- apiGroups:
- extensions
- networking.k8s.io
resources:
- ingresses
verbs:
- get
- list
- watch
- apiGroups:
- extensions
- networking.k8s.io
resources:
- ingresses/status
verbs:
- update
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: traefik-ingress-controller
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: traefik-ingress-controller
subjects:
- kind: ServiceAccount
name: traefik-ingress-controller
namespace: default
---
kind: ServiceAccount
apiVersion: v1
metadata:
name: traefik-ingress-controller
---
kind: Deployment
apiVersion: apps/v1
metadata:
name: traefik
labels:
app: traefik
spec:
replicas: 1
selector:
matchLabels:
app: traefik
template:
metadata:
labels:
app: traefik
spec:
serviceAccountName: traefik-ingress-controller
containers:
- name: traefik
image: traefik:v2.2
args:
- --log.level=DEBUG
- --api
- --api.insecure
- --entrypoints.web.address=:80
- "--providers.kubernetesingress=true"
ports:
- name: web
containerPort: 80
- name: admin
containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: traefik
spec:
selector:
app: traefik
ports:
- name: web
protocol: TCP
port: 80
targetPort: 80
nodePort: 30081
- name: admin
protocol: TCP
port: 8080
targetPort: 8080
nodePort: 31808
type: NodePort
---
#Ingress
kind: Ingress
apiVersion: networking.k8s.io/v1beta1
metadata:
name: traefik-basic
annotations:
traefik.ingress.kubernetes.io/router.entrypoints: web
spec:
rules:
# - host: example.com
- http:
paths:
- path: /play
backend:
serviceName: kind-play-svc
servicePort: 3000