Skip to content

Commit

Permalink
DRY up proxy_pass configuration (#1385)
Browse files Browse the repository at this point in the history
Suddenly, I couldn't get Kubeapps to start with `useHelm3: true`, making
me spend several hours trying various more or less random fixes. (I
thought I had messed something up with Docker or Minikube, so I didn't
think of bisecting or inspecting the YAML files.) The reason turned out
to be this unconditional proxy_pass directive introduced in #1347:

https://github.com/kubeapps/kubeapps/pull/1347/files#diff-b0b5b871c8bf5a72f95d417c97266ae0R100

I fixed it in #1382. This commit is intended to prevent something
similar from happening again; it's not at all obvious that the
proxy_pass directives must be conditional.
  • Loading branch information
SimonAlling authored and absoludity committed Dec 16, 2019
1 parent 6a6f413 commit 4046df2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
11 changes: 11 additions & 0 deletions chart/kubeapps/templates/_helpers.tpl
Expand Up @@ -143,6 +143,17 @@ Create name for the frontend config based on the fullname
{{ template "kubeapps.fullname" . }}-frontend-config
{{- end -}}

{{/*
Create proxy_pass for the frontend config based on the useHelm3 flag
*/}}
{{- define "kubeapps.frontend-config.proxy_pass" -}}
{{- if .Values.useHelm3 -}}
http://{{ template "kubeapps.kubeops.fullname" . }}:{{ .Values.kubeops.service.port }}
{{- else -}}
http://{{ template "kubeapps.tiller-proxy.fullname" . }}:{{ .Values.tillerProxy.service.port }}
{{- end -}}
{{- end -}}

{{/*
Create name for the tiller-proxy based on the fullname
*/}}
Expand Down
18 changes: 3 additions & 15 deletions chart/kubeapps/templates/kubeapps-frontend-config.yaml
Expand Up @@ -62,11 +62,7 @@ data:
proxy_set_header Authorization "Bearer $http_x_forwarded_access_token";
{{- end }}
{{- if .Values.useHelm3 }}
proxy_pass http://{{ template "kubeapps.kubeops.fullname" . }}:{{ .Values.kubeops.service.port }};
{{- else }}
proxy_pass http://{{ template "kubeapps.tiller-proxy.fullname" . }}:{{ .Values.tillerProxy.service.port }};
{{- end }}
proxy_pass {{ include "kubeapps.frontend-config.proxy_pass" . -}};
}
location ~* /api/tiller-deploy {
Expand All @@ -75,11 +71,7 @@ data:
proxy_read_timeout 10m;
rewrite /api/tiller-deploy/(.*) /$1 break;
rewrite /api/tiller-deploy / break;
{{- if .Values.useHelm3 }}
proxy_pass http://{{ template "kubeapps.kubeops.fullname" . }}:{{ .Values.kubeops.service.port }};
{{- else }}
proxy_pass http://{{ template "kubeapps.tiller-proxy.fullname" . }}:{{ .Values.tillerProxy.service.port }};
{{- end }}
proxy_pass {{ include "kubeapps.frontend-config.proxy_pass" . -}};
{{- if .Values.frontend.proxypassAccessTokenAsBearer }}
# Google Kubernetes Engine requires the access_token as the Bearer when talking to the k8s api server.
Expand All @@ -97,11 +89,7 @@ data:
proxy_set_header Authorization "Bearer $http_x_forwarded_access_token";
{{- end }}
{{- if .Values.useHelm3 }}
proxy_pass http://{{ template "kubeapps.kubeops.fullname" . }}:{{ .Values.kubeops.service.port }};
{{- else }}
proxy_pass http://{{ template "kubeapps.tiller-proxy.fullname" . }}:{{ .Values.tillerProxy.service.port }};
{{- end }}
proxy_pass {{ include "kubeapps.frontend-config.proxy_pass" . -}};
}
location / {
Expand Down

0 comments on commit 4046df2

Please sign in to comment.