Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nginx ingress controller not working with namespace #32

Closed
skoulouzis opened this issue Apr 28, 2020 · 1 comment
Closed

Nginx ingress controller not working with namespace #32

skoulouzis opened this issue Apr 28, 2020 · 1 comment

Comments

@skoulouzis
Copy link

Describe the bug
Following the tutorial at https://www.youtube.com/watch?v=2VUQ4WjLxDg everything works as expected. However, if we add namespace to the deployments we get '503 Service Temporarily Unavailable' on all paths: '/', '/green', '/blue'

How To Reproduce
create new namespace:

kubectl create namespace example

install nginx-ingress:

helm install my-conf-nginx --namespace example  stable/nginx-ingress

create resources:

kubectl create -f ingress-resource-3.yaml -f nginx-deploy-blue.yaml -f nginx-deploy-green.yaml -f nginx-deploy-main.yaml

Resources:
ingress-resource-3.yaml

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  namespace: example
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /
  name: ingress-resource-3
spec:
  rules:
  - host: fry.lab.uvalight.net
    http:
      paths:
      - path: /
        backend:
          serviceName: nginx-deploy-main
          servicePort: 80  
      - path: /blue
        backend:
          serviceName: nginx-deploy-blue
          servicePort: 80
      - path: /green
        backend:
          serviceName: nginx-deploy-green
          servicePort: 80

nginx-deploy-blue.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: example
  labels:
    run: nginx
  name: nginx-deploy-blue
spec:
  replicas: 1
  selector:
    matchLabels:
      run: nginx-blue
  template:
    metadata:
      labels:
        run: nginx-blue
    spec:
      volumes:
      - name: webdata
        emptyDir: {}
      initContainers:
      - name: web-content
        image: busybox
        volumeMounts:
        - name: webdata
          mountPath: "/webdata"
        command: ["/bin/sh", "-c", 'echo "<h1>I am <font color=blue>BLUE</font></h1>" > /webdata/index.html']
      containers:
      - image: nginx
        name: nginx
        volumeMounts:
        - name: webdata
          mountPath: "/usr/share/nginx/html"

nginx-deploy-green.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: example
  labels:
    run: nginx
  name: nginx-deploy-green
spec:
  replicas: 1
  selector:
    matchLabels:
      run: nginx-green
  template:
    metadata:
      labels:
        run: nginx-green
    spec:
      volumes:
      - name: webdata
        emptyDir: {}
      initContainers:
      - name: web-content
        image: busybox
        volumeMounts:
        - name: webdata
          mountPath: "/webdata"
        command: ["/bin/sh", "-c", 'echo "<h1>I am <font color=green>GREEN</font></h1>" > /webdata/index.html']
      containers:
      - image: nginx
        name: nginx
        volumeMounts:
        - name: webdata
          mountPath: "/usr/share/nginx/html"

nginx-deploy-main.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  namespace: example
  labels:
    run: nginx
  name: nginx-deploy-main
spec:
  replicas: 1
  selector:
    matchLabels:
      run: nginx-main
  template:
    metadata:
      labels:
        run: nginx-main
    spec:
      containers:
      - image: nginx
        name: nginx

Expose ports:

kubectl expose deploy nginx-deploy-blue --port 80 -n example
kubectl expose deploy nginx-deploy-green --port 80 -n example
kubectl expose deploy nginx-deploy-main --port 80 -n example

Expected behavior
For each path on the browser to show the corresponding nginx index.html

Screenshots (if any)

Environment (please complete the following information):

kubectl version --short
Client Version: v1.18.2
Server Version: v1.18.2
helm version --short
v3.2.0+ge11b7ce

Additional context
Add any other context about the problem here.

@justmeandopensource
Copy link
Owner

I will test it this weekend. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants