Skip to content

Instantly share code, notes, and snippets.

@yadutaf
Created March 18, 2024 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yadutaf/dcbf8668a102438e7b1ec3ff520d0cb6 to your computer and use it in GitHub Desktop.
Save yadutaf/dcbf8668a102438e7b1ec3ff520d0cb6 to your computer and use it in GitHub Desktop.
Run Kubernetes dashboard locally
# Run Kubernetes dashboard locally - no install in the cluster
#
# Usage:
#
# 1. Make sure you have Docker compose >= v2.23.1 (required for inline configuration files)
#
# 2. Download this Gist as 'kube-dashboard.docker.compose.yaml'
#
# 3. Run Docker compose:
# docker compose -f kube-dashboard.docker.compose.yaml up \
# --remove-orphans \
# --no-attach gateway \
# --no-attach scraper \
# --no-attach metrics-server
#
# 3. Visit http://localhost:8080 and authenticate as usual
#
# Configuration:
#
# * VERSION: Version of the dashboard to pull from the Docker hub. Defaults to 'latest'.
# * KUBECONFIG: Path to a kubeconfig file with the cluster address, certificate authority
# and service account. Defaults to '${HOME}/.kube/config'
#
# Known issue(s):
#
# * metrics collection does not work
#
# Acknowledgement:
#
# This docker-compose module is largely based on:
# https://raw.githubusercontent.com/kubernetes/dashboard/4a1905486efc9e8b128e35e1e357c0d49291fd7e/hack/docker/docker.compose.yaml
version: "3.8"
name: kube-dashboard
configs:
kong_config:
content: |
_format_version: "3.0"
services:
- name: auth
host: auth # Internal name of docker service
port: 8000
protocol: http
routes:
- name: authLogin
paths:
- /api/v1/login
strip_path: false
- name: authCsrf
paths:
- /api/v1/csrftoken/login
strip_path: false
- name: authMe
paths:
- /api/v1/me
strip_path: false
- name: api
host: api # Internal name of docker service
port: 8000
protocol: http
routes:
- name: api
paths:
- /api
strip_path: false
- name: metrics
paths:
- /metrics
strip_path: false
- name: web
host: web # Internal name of docker service
port: 8000
protocol: http
routes:
- name: root
paths:
- /
strip_path: false
services:
gateway:
container_name: kong-gateway
image: kong/kong-gateway:3.6
environment:
- "KONG_DATABASE=off"
- "KONG_PROXY_ACCESS_LOG=/dev/stdout"
- "KONG_DECLARATIVE_CONFIG=/kong/declarative/kong.yml"
- "KONG_ADMIN_ACCESS_LOG=/dev/stdout"
- "KONG_PROXY_ERROR_LOG=/dev/stderr"
- "KONG_ADMIN_ERROR_LOG=/dev/stderr"
- "KONG_DNS_ORDER=LAST,A,CNAME"
configs:
- source: kong_config
target: /kong/declarative/kong.yml
ports:
- "8080:8000"
- "8443:8443"
auth:
container_name: dashboard-auth
image: kubernetesui/dashboard-auth:${VERSION:-latest}
command:
- "--kubeconfig=${KUBECONFIG:-${HOME}/.kube/config}"
volumes:
- ${KUBECONFIG:-${HOME}/.kube/config}:${KUBECONFIG:-${HOME}/.kube/config}
tmpfs:
- /tmp
api:
container_name: dashboard-api
image: kubernetesui/dashboard-api:${VERSION:-latest}
command:
--kubeconfig=${KUBECONFIG:-${HOME}/.kube/config}
--sidecar-host=http://scraper:8000
volumes:
- ${KUBECONFIG:-${HOME}/.kube/config}:${KUBECONFIG:-${HOME}/.kube/config}
tmpfs:
- /tmp
web:
container_name: dashboard-web
image: kubernetesui/dashboard-web:${VERSION:-latest}
command:
- "--kubeconfig=${KUBECONFIG:-${HOME}/.kube/config}"
volumes:
- ${KUBECONFIG:-${HOME}/.kube/config}:${KUBECONFIG:-${HOME}/.kube/config}
tmpfs:
- /tmp
scraper:
container_name: metrics-scraper
image: kubernetesui/dashboard-metrics-scraper:${VERSION:-latest}
command:
--kubeconfig=${KUBECONFIG:-${HOME}/.kube/config}
--metric-resolution=5s
--metric-duration=10m
volumes:
- ${KUBECONFIG:-${HOME}/.kube/config}:${KUBECONFIG:-${HOME}/.kube/config}
shm_size: 1G
tmpfs:
- /tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment