mirror of
https://github.com/cnrancher/kube-explorer.git
synced 2025-04-27 11:00:48 +00:00
docs: Add docs for path prefix deploy example
This commit is contained in:
parent
a5e53f2b17
commit
1540341550
34
deploy/kubectl/path-prefix/Readme.md
Normal file
34
deploy/kubectl/path-prefix/Readme.md
Normal file
@ -0,0 +1,34 @@
|
||||
# Deploy kube-explorer behind proxy with path prefix
|
||||
|
||||
> Supported since v0.5.0
|
||||
|
||||
The kube-explorer dashboard can be exposed behind a proxy and path prefix like `http://your-domain.com/kube-explorer`.
|
||||
|
||||
The deployment examples in this folder are:
|
||||
|
||||
- `nginx ingress`
|
||||
- `traefik ingress`
|
||||
|
||||
## Serve with ingress
|
||||
|
||||
When serving with nginx/traefik ingress controller, the template ingress file needs to be modified. In the `*.tpl` file, you can spot the missing hostname like:
|
||||
|
||||
```yaml
|
||||
spec:
|
||||
rules:
|
||||
- host: "${MY_IP}.sslip.io" # Replace with your actual domain
|
||||
```
|
||||
|
||||
Replace your ip to `${MY_UP}`, this will use the [sslip.io](https://sslip.io/) dns service to resolve the hostname to the ingress ip address.
|
||||
|
||||
For the traefik ingress, it is using `v2` version of the traefik ingress schema which use middlewares to modify the proxy request. Both `stripPrefix` and `headers` are used.
|
||||
For the nginx ingress, the annotations `nginx.ingress.kubernetes.io/x-forwarded-prefix` and `nginx.ingress.kubernetes.io/rewrite-target` are used to strip prefix and to add proxy request header.
|
||||
|
||||
## Serve with self-hosted proxy
|
||||
|
||||
If serving the kube-explorer with self-hosted proxy, following modifications are required when proxying:
|
||||
|
||||
- Rewrite the proxy request to strip the path prefix like `rewrite "(?i)/kube-explorer(/|$)(.*)" /$2 break;` in nginx configuration.
|
||||
- Add header `X-API-URL-Prefix` or `X-Forwarded-Prefix` with the path prefix when proxying request like `proxy_set_header X-Forwarded-Prefix "/kube-explorer";` in nginx configuration.
|
||||
|
||||
Then kube-explorer will response the index.html with modified content with path prefix to the browser.
|
24
deploy/kubectl/path-prefix/nginx-ingress.yaml.tpl
Normal file
24
deploy/kubectl/path-prefix/nginx-ingress.yaml.tpl
Normal file
@ -0,0 +1,24 @@
|
||||
# Note: please replace the host first
|
||||
# To use sslip.io: https://sslip.io/
|
||||
# To get your public IP: curl ipinfo.io/ip
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
annotations:
|
||||
nginx.ingress.kubernetes.io/x-forwarded-prefix: "/kube-explorer"
|
||||
nginx.ingress.kubernetes.io/rewrite-target: /$2
|
||||
name: kube-explorer-ingress
|
||||
namespace: kube-system
|
||||
spec:
|
||||
rules:
|
||||
- host: "${MY_IP}.sslip.io" # Replace with your actual domain
|
||||
http:
|
||||
paths:
|
||||
- backend:
|
||||
service:
|
||||
name: kube-explorer
|
||||
port:
|
||||
name: http
|
||||
path: /kube-explorer(/|$)(.*)
|
||||
pathType: ImplementationSpecific
|
||||
|
42
deploy/kubectl/path-prefix/traefik-ingress.yaml.tpl
Normal file
42
deploy/kubectl/path-prefix/traefik-ingress.yaml.tpl
Normal file
@ -0,0 +1,42 @@
|
||||
# Note: please replace the host first
|
||||
# To use sslip.io: https://sslip.io/
|
||||
# To get your public IP: curl ipinfo.io/ip
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: kube-explorer-ingress
|
||||
namespace: kube-system
|
||||
annotations:
|
||||
traefik.ingress.kubernetes.io/router.middlewares: kube-system-prefix@kubernetescrd,kube-system-add-header@kubernetescrd
|
||||
spec:
|
||||
rules:
|
||||
- host: "${MY_IP}.sslip.io" # Replace with your actual domain
|
||||
http:
|
||||
paths:
|
||||
- path: /kube-explorer
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: kube-explorer
|
||||
port:
|
||||
name: http
|
||||
---
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: Middleware
|
||||
metadata:
|
||||
name: prefix
|
||||
namespace: kube-system
|
||||
spec:
|
||||
stripPrefix:
|
||||
prefixes:
|
||||
- /kube-explorer
|
||||
---
|
||||
apiVersion: traefik.io/v1alpha1
|
||||
kind: Middleware
|
||||
metadata:
|
||||
name: add-header
|
||||
namespace: kube-system
|
||||
spec:
|
||||
headers:
|
||||
customRequestHeaders:
|
||||
X-Forwarded-Prefix: "/kube-explorer" # Adds
|
Loading…
Reference in New Issue
Block a user