Estou executando um cluster kubernetes e tenho um TestApplication que roda no TestPort (3000 na verdade). Consegui colocar o Traefik v3.2.1 em funcionamento e o CertManager 1.16.1 com desafio http para letsencrypt em funcionamento. Gostaria de proteger o TestApplication fazendo com que as pessoas passem pela porta 443 do TraefiK e cheguem ao TestApplication:TestPort. Como crio um recurso Ingress apropriado para meu aplicativo? até agora eu fiz:
#001-app-deployment.yml
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
kompose.cmd: kompose convert -f compose.yml
kompose.version: 1.34.0 (HEAD)
labels:
io.kompose.service: app-frontend
name: app-frontend
spec:
replicas: 1
selector:
matchLabels:
io.kompose.service: app-frontend
template:
metadata:
annotations:
kompose.cmd: kompose convert -f compose.yml
kompose.version: 1.34.0 (HEAD)
labels:
io.kompose.service: app-frontend
spec:
containers:
- env:
- name: API_GATEWAY_BASE_URL
value: http://edge-thinghy:9000
image: my-image-I-test
name: app-frontend
ports:
- name: app-frontend
containerPort: 3000
protocol: TCP
imagePullSecrets:
- name: ghcr-secret
restartPolicy: Always
#010-app-service.yml
apiVersion: v1
kind: Service
metadata:
name: app-frontend
spec:
ports:
- name: app-frontend
port: 80
targetPort: 3000
selector:
app: app-frontend
#011-app-ingress.yml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: app-ingress
spec:
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: app-frontend
port:
name: app-frontend
#012-challenge.yml
apiVersion: cert-manager.io/v1
kind: Issuer
metadata:
name: app-challenge
namespace: default
spec:
acme:
email: [email protected]
server: https://acme-v02.api.letsencrypt.org/directory
privateKeySecretRef:
name: app-issuer-account-key
solvers:
- http01:
ingress:
class: traefik
#013-ingress-rule.yml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: app-ssl-ingress
namespace: default
annotations:
cert-manager.io/issuer: "app-challenge"
spec:
tls:
- hosts:
- app.domain.example
secretName: tls-app-ingress-http
rules:
- host: app.domain.example
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: app-frontend
port:
name: app-frontend
Como os certificados foram emitidos, eu esperava que o Traefik funcionasse automaticamente, mas o tempo limite é atingido quando vou para https://app.domain.example . Acho que estou fazendo algo errado. Se eu abrir os logs do pod do traefik, posso ver:
ERR Skipping service: no endpoints found ingress=app-ingress namespace=default providerName=kubernetes serviceName=app-frontend servicePort=&ServiceBackendPort{Name:app-frontend,Number:0,}
ERR Skipping service: no endpoints found ingress=app-ssl-ingress namespace=default providerName=kubernetes serviceName=app-frontend servicePort=&ServiceBackendPort{Name:app-frontend,Number:0,}
Eu posso, embora, chegar a http://app.domain.example, mas não a https se eu fizer isso
kubectl get ingress
NAME CLASS HOSTS ADDRESS PORTS
app-ingress traefik * 80
app-ssl-ingress traefik app.domain.example 80, 443
parece que você esqueceu o manifesto de implantação
aqui o exemplo: