'Digital Ocean Kubernetes one load balancer for two different namespaces
I have an small kubernetes (3 small nodes) on Digital Ocean. I already configured production an it is working, but for development purposes I want to create a second environment (staging).
I have been working on and almost everything is working, but I can't get the network to work.
For example, I own the domain example.com
production will run on www.example.com and api.example.com. Then I have staging on a different kubernetes namespace staging-www.example.com and staging-api.example.com.
The only thing that this two environments are sharing are the load balancer. The issue I am facing is I cant go to staging-www.example.com and staging-api.example.com. I misconfigured something, I am trying to reach where is the misconfiguration
These two files are the ones I have for staging / ingress / network. As I wrote, for production is working, but there is something wrong for staging and I couldn't get where is the problem
apiVersion: v1
kind: Service
metadata:
annotations:
kubernetes.digitalocean.com/load-balancer-id: "8ce613ac-a217-4537-b6ce-d26b0eef0939"
service.beta.kubernetes.io/do-loadbalancer-enable-proxy-protocol: "true"
service.beta.kubernetes.io/do-loadbalancer-hostname: "example.com"
labels:
helm.sh/chart: ingress-nginx-4.1.0
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/version: 1.0.0
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/component: controller
name: ingress-nginx-controller
namespace: ingress-nginx
spec:
type: LoadBalancer
externalTrafficPolicy: Local
ports:
- name: http
port: 80
protocol: TCP
targetPort: http
- name: https
port: 443
protocol: TCP
targetPort: https
selector:
app.kubernetes.io/name: ingress-nginx
app.kubernetes.io/instance: ingress-nginx
app.kubernetes.io/component: controller
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
namespace: staging
name: example-ingress
annotations:
kubernetes.io/ingress.class: nginx
cert-manager.io/issuer: "letsencrypt-prod"
spec:
tls:
- hosts:
- staging-www.example.com
- staging-api.example.com
secretName: example-tls
defaultBackend:
service:
name: examplecatalogo-svc
port:
number: 80
rules:
- host: staging-www.example.com
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: examplecatalogo-svc
port:
number: 80
- host: staging-api.example.com
http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: examplenodeapi-svc
port:
number: 80
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
