Last active
August 31, 2023 03:46
-
-
Save JohnKDay/ebc4b71e6cb1a5fd208c535509ade5f5 to your computer and use it in GitHub Desktop.
Configure ingress for Kibana interface for EFK stack CCP 6.1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Set cluster config path | |
export KUBECONFIG=${KUBECONFIG:-~/.kube/config} | |
# Kibana username | |
KIBANA_USERNAME=admin | |
KIBANA_PASSWORD=superdooper | |
# Configure Kibana server.basePath param | |
kubectl -n ccp get cm ccp-efk-kibana -o json | | |
jq '.["data"]["kibana.yml"] += "server.basePath: \"/kibana\"\n"' | | |
kubectl replace -f - | |
# Generating password and creating secret | |
KIBANA_SECRET=`htpasswd -n -b $KIBANA_USERNAME $KIBANA_PASSWORD | head -n 1` | |
kubectl -n ccp create secret generic ccp-kibana-basic-auth --from-literal=auth=$KIBANA_SECRET | |
# Creating ingress | |
cat <<EOF | kubectl apply -f - | |
apiVersion: extensions/v1beta1 | |
kind: Ingress | |
metadata: | |
annotations: | |
kubernetes.io/ingress.class: nginx | |
nginx.ingress.kubernetes.io/add-base-url: "false" | |
nginx.ingress.kubernetes.io/auth-realm: Kibana | |
nginx.ingress.kubernetes.io/auth-secret: ccp-kibana-basic-auth | |
nginx.ingress.kubernetes.io/auth-type: basic | |
nginx.ingress.kubernetes.io/rewrite-target: /\$1 | |
name: ccp-kibana | |
namespace: ccp | |
spec: | |
rules: | |
- http: | |
paths: | |
- backend: | |
serviceName: ccp-efk-kibana | |
servicePort: 5601 | |
path: /kibana/?(.*) | |
EOF | |
# Rerunning Kibana pod | |
kubectl -n ccp delete $(kubectl -n ccp get pods -o name | grep ccp-efk-kibana) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment