mirror of
https://github.com/cnrancher/kube-explorer.git
synced 2025-09-17 23:48:04 +00:00
Add basic-auth wati in ingress-nginx class
This commit is contained in:
21
deploy/kubectl/nginx-auth/README.md
Normal file
21
deploy/kubectl/nginx-auth/README.md
Normal file
@@ -0,0 +1,21 @@
|
||||
## Traefik Auth
|
||||
|
||||
This can be used in the cluster which uses the nginx-ingress.
|
||||
|
||||
We use `basic-auth` to control the access of kube-explorer. The auth token is stored in the secret.
|
||||
|
||||
The default user is `niusmallnan`, and password is `dagedddd`. You can replace to another value with `htpasswd` tool.
|
||||
|
||||
```
|
||||
htpasswd -nb username password | base64
|
||||
```
|
||||
|
||||
To install this mode, just run this script:
|
||||
|
||||
```
|
||||
kubectl apply -f ./secret.yaml
|
||||
export MY_XIP_IO=$(curl -sL ipinfo.io/ip)
|
||||
envsubst < ./ingress.yaml.tpl | kubectl apply -f -
|
||||
```
|
||||
|
||||
For more infos: https://kubernetes.github.io/ingress-nginx/examples/auth/basic/
|
25
deploy/kubectl/nginx-auth/ingress.yaml.tpl
Normal file
25
deploy/kubectl/nginx-auth/ingress.yaml.tpl
Normal file
@@ -0,0 +1,25 @@
|
||||
# Note: please replace the host first
|
||||
# To use xip.io: http://xip.io/
|
||||
# To get your public IP: curl ipinfo.io/ip
|
||||
|
||||
apiVersion: networking.k8s.io/v1beta1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: kube-explorer
|
||||
namespace: kube-system
|
||||
labels:
|
||||
app: kube-explorer
|
||||
annotations:
|
||||
kubernetes.io/ingress.class: "nginx"
|
||||
nginx.ingress.kubernetes.io/auth-type: basic
|
||||
nginx.ingress.kubernetes.io/auth-secret: kube-explorer
|
||||
nginx.ingress.kubernetes.io/auth-realm: 'Authentication Required - kube-explorer'
|
||||
spec:
|
||||
rules:
|
||||
- host: "${MY_XIP_IO}.xip.io"
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
backend:
|
||||
serviceName: kube-explorer
|
||||
servicePort: 8989
|
13
deploy/kubectl/nginx-auth/secret.yaml
Normal file
13
deploy/kubectl/nginx-auth/secret.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
# To create an encoded user:password pair, the following command can be used:
|
||||
# htpasswd -nb user password | base64
|
||||
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: kube-explorer
|
||||
namespace: kube-system
|
||||
labels:
|
||||
app: kube-explorer
|
||||
data:
|
||||
auth: bml1c21hbGxuYW46JGFwcjEkbDdUZjJOdWskbmNXajYubHYvMGNkcXM0NFoyelVQLgoK
|
||||
type: Opaque
|
Reference in New Issue
Block a user