I deployed a helm chart (helm install --name=my-release stable/kube-ops-view
) which created a svc with clusterIP, I tried to create a route to it via traefik ingress, but its not working
I have been able to route other applications (nginx) using similar ingress configurations
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: demo-ingress
namespace: kube-ops-view #svc is created in this namespace
spec:
rules:
- host:
http:
paths:
- path: /kube
backend:
serviceName: kube-ops-view
servicePort: 80
Ingress should have worked
I was able to make it work on GKE cluster. After cluster creation :
1) Installed Helm
2) Installed NGINX Ingress Controller](https://kubernetes.github.io/ingress-nginx/deploy/)
Next.. You should use Rewrite target with nginx.ingress.kubernetes.io/rewrite-target
annotation.
Starting in Version 0.22.0, ingress definitions using the annotation nginx.ingress.kubernetes.io/rewrite-target are not backwards compatible with previous versions. In Version 0.22.0 and beyond, any substrings within the request URI that need to be passed to the rewritten path must explicitly be defined in a capture group.
you ingress should look like
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/rewrite-target: /$2
name: kubeops-kube-ops-view
namespace: default
spec:
rules:
- http:
paths:
- backend:
serviceName: kubeops-kube-ops-view
servicePort: 80
path: /kube(/?|$)(.*)
And another option: you can enable ingress in helm chart without writing ingress yaml.
My way:
helm fetch stable/kube-ops-view --untar
edit values.yaml
ingress:
enabled: true
path: /kube(/|$)(.*)
# hostname: kube-ops-view.local
annotations: {
kubernetes.io/ingress.class: nginx,
nginx.ingress.kubernetes.io/rewrite-target: /$2
}
tls: []
## Secrets must be manually created in the namespace
# - secretName: kube-ops-view.local-tls
# hosts:
# - kube-ops-view.local
edit templates/ingress.yaml
{{- if .Values.ingress.enabled -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ template "kube-ops-view.fullname" . }}
labels:
app: {{ template "kube-ops-view.fullname" . }}
chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"
release: "{{ .Release.Name }}"
heritage: "{{ .Release.Service }}"
{{- if .Values.ingress.annotations }}
annotations:
{{ toYaml .Values.ingress.annotations | indent 4 }}
{{- end }}
spec:
rules:
- host:
http:
paths:
- path: {{ .Values.ingress.path }}
backend:
serviceName: {{ template "kube-ops-view.fullname" . }}
servicePort: {{ .Values.service.externalPort }}
{{- if .Values.ingress.tls }}
tls:
{{ toYaml .Values.ingress.tls | indent 4 }}
{{- end -}}
{{- end -}}
Verify and install: helm install --server-dry-run --debug kube-ops-view helm install kube-ops-view --name kubeops
Check Result:
curl -iLk http://Ingress-external-ip/kube/
HTTP/1.1 308 Permanent Redirect
Server: openresty/1.15.8.1
Date: Thu, 22 Aug 2019 09:21:21 GMT
Content-Type: text/html
Content-Length: 177
Connection: keep-alive
Location: https://Ingress-external-ip/kube/
HTTP/2 200
server: openresty/1.15.8.1
date: Thu, 22 Aug 2019 09:21:21 GMT
content-type: text/html; charset=utf-8
content-length: 1276
vary: Accept-Encoding
strict-transport-security: max-age=15724800; includeSubDomains
<!doctype >
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Kubernetes Operational View 0.11</title>
<link rel="shortcut icon" href="static/favicon.ico">
<style>* {padding: 0; margin: 0} body { color: #aaaaff; background: #000; }</style>
<style>
/* latin */
@font-face {
font-family: 'ShareTechMono';
font-style: normal;
font-weight: 400;
/* ShareTechMono-Regular.ttf: Copyright (c) 2012, Carrois Type Design, Ralph du Carrois (www.carrois.com post@carrois.com), with Reserved Font Name 'Share'
License: SIL Open Font License, 1.1 */
src: local('Share Tech Mono'), local('ShareTechMono-Regular'), url(static/sharetechmono.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
</style>
</head>
<body>
<!-- make sure the font is loaded -->
<div id="loading" style="font-family: ShareTechMono">Loading..</div>
<script src="static/build/app-ee71ac795470b05e7f76.js"></script>
<script>document.getElementById('loading').style.display = 'none'; const app = new App(); app.run()</script>
</body>
</html>