Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

[stable/gocd] GoCD Ingress default template #10750

Closed
colachg opened this issue Jan 18, 2019 · 8 comments · Fixed by #10983
Closed

[stable/gocd] GoCD Ingress default template #10750

colachg opened this issue Jan 18, 2019 · 8 comments · Fixed by #10983

Comments

@colachg
Copy link
Contributor

colachg commented Jan 18, 2019


Is this a BUG REPORT or FEATURE REQUEST? (choose one):

FEATURE REQUEST

Version of Helm and Kubernetes:

helm v2.12.1
kubernetes v1.12.4

Which chart:

stable/gocd

Anything else we need to know:

In file "gocd/templates/ingress.yaml":
I would like to change spec
from

  backend:
    serviceName: {{ template "gocd.fullname" . }}-server
    servicePort: {{ .Values.server.service.httpPort }}
  rules:
    {{- range $host := .Values.server.ingress.hosts }}
    - host: {{ $host }}
    {{- end -}}
  {{- if .Values.server.ingress.tls }}
  tls:
{{ toYaml .Values.server.ingress.tls | indent 4 }}
  {{- end -}}
{{- end -}}
{{- end -}}

to

  rules:
    {{- range $host := .Values.server.ingress.hosts }}
    - host: {{ $host }}
      http:
        paths:
        - path: /
          backend:
            serviceName: {{ template "gocd.fullname" . }}-server
            servicePort: {{ .Values.server.service.httpPort }}
    {{- end -}}
  {{- if .Values.server.ingress.tls }}
  tls:
{{ toYaml .Values.server.ingress.tls | indent 4 }}
  {{- end -}}
{{- end -}}
{{- end -}}

Because when I use the default ingress config I can not access gocd by the hostname that I defined in values.yaml.
I deploy gocd behind traefik.
Here is the error log: "level":"warning","msg":"Error in ingress: HTTP is nil"

@varshavaradarajan Could you check this? Thanks.

@colachg colachg changed the title [stable/gocd] GoCD Ingress [stable/gocd] GoCD Ingress default Template Jan 18, 2019
@colachg colachg changed the title [stable/gocd] GoCD Ingress default Template [stable/gocd] GoCD Ingress default template Jan 18, 2019
@varshavaradarajan
Copy link
Collaborator

varshavaradarajan commented Jan 18, 2019

@colachg - I believe its a bug in traefik which does not allow default backends in ingress. See traefik/traefik#1073 and traefik/traefik#1051.

Edit: According to the above issues, default backends should now be supported. But it doesn't seem to be. May be I am missing something in the configuration.

What you suggest works except for

serviceName: {{ template "gocd.fullname" . }}-server
servicePort: {{ .Values.server.service.httpPort }}

So because you are in a range block, . no longer refers to the top level scope. You should store the context of . before beginning rules by doing

{{ $dot := .}}
 and using that in the backend:
serviceName: {{ template "gocd.fullname" $dot }}-server
servicePort: {{ $dot.Values.server.service.httpPort }}

I have been unable to verify the fix though. Not sure if its because I am using minikube. Here's what I did:

minikube stop; minikube delete; minikube start --bootstrapper kubeadm --memory 4096; minikube addons enable ingress; helm init

Edit traefik/values.yaml to have dashboard.enabled: true and dashboard.domain: traefik-ui.minikube. Add <minikube ip> traefik-ui.minikube to /etc/hosts
helm install stable/traefik (tried both with LoadBalancer and NodePort svc types)

Changed ingress annotations in gocd/values.yaml to kubernetes.io/ingress.class: traefik
Added host test.go.cd in gocd/values.yaml for ingress and added <minikube ip> test.go.cd to /etc/hosts

helm install stable/gocd

Let me know if I am missing something.

The proposed fix to make ingress work with traefik does not affect anything when used with the default ingress controller that comes with minikube, which is nginx.

/cc @arvindsv , @GaneshSPatil

@colachg
Copy link
Contributor Author

colachg commented Jan 20, 2019

@varshavaradarajan Thanks for your time. I also think it's a bug in traefik. My proposal can be compatible with traefik so could we use this before traefik works(or regardless of traefik)?

@varshavaradarajan
Copy link
Collaborator

varshavaradarajan commented Jan 20, 2019

@colachg - which version of traefik did you try it with? I used the helm chart, which had the app version 1.7.6 which is supposed to contain the fix for default backends. But, as I said, been unable to do so on minikube. It just brings up the page with default backend - 404.

Even for the proposed fix.

On the traefik dashboard, I see that the test.go.cd backend (with the fix) shows up as healthy unlike the global default backend which appears as an error. But I still can't access test.go.cd.

@colachg
Copy link
Contributor Author

colachg commented Jan 21, 2019

@varshavaradarajan em... Did you change your hosts file to make the host in ingress point to minikube ip:)?

@varshavaradarajan
Copy link
Collaborator

varshavaradarajan commented Jan 21, 2019

@colachg - yes. Here's what my hosts file has:

127.0.0.1	localhost
255.255.255.255	broadcasthost
::1             localhost
192.168.99.100  test.go.cd
192.168.99.100 traefik-ui.minikube

If I didn't have the entry, it should have shown could not connect instead of the default backed -404 page. :)

@colachg
Copy link
Contributor Author

colachg commented Jan 21, 2019

@varshavaradarajan Haha, thanks for your quick respose. Do you have some IM channels(like discord or slack)? we can talk immediately there. Gocd server also have some errors in my environment.Maybe you can help me.

@varshavaradarajan
Copy link
Collaborator

@colachg - mind using gitter? Join https://gitter.im/gocd/gocd and DM me?

@varshavaradarajan
Copy link
Collaborator

Update: The proposed fix works with traefik.

The error default http backend - 404 was coming from the default nginx ingress controller. Ideally, this should not have happened, as the annotation kubernetes.io/ingress.class was set to traefik. But as indicated in traefik/traefik#2633 (comment), the ingress.class annotation is not respected in minikube. The fix was working for @colachg because the minikube setup specifically involved minikube addons disable ingress, which terminated the nginx ingress controller.

@colachg - can you please submit a PR so that this can be verified with GKE?

I think that this issue should be fixed as it does not affect the way requests are handled when used with nginx or gce ingress controllers and allows for gocd to work with traefik, another ingress controller till traefik can support single service ingress properly.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants