diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index ebbf8a2b..9c9bc3ab 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -74,6 +74,7 @@ export default defineConfig({ { text: "Healthcheck", link: "/guide/healthcheck" }, { text: "Remote Hosts", link: "/guide/remote-hosts" }, { text: "Swarm Mode", link: "/guide/swarm-mode" }, + { text: "K8s Mode", link: "/guide/k8s" }, { text: "Supported Env Vars", link: "/guide/supported-env-vars" }, { text: "Logging Files on Disk", link: "/guide/log-files-on-disk" }, { text: "SQL Engine", link: "/guide/sql-engine" }, diff --git a/docs/guide/getting-started.md b/docs/guide/getting-started.md index 1951206e..0f34e4db 100644 --- a/docs/guide/getting-started.md +++ b/docs/guide/getting-started.md @@ -47,9 +47,69 @@ networks: driver: overlay ``` +```yaml [k8s-dozzle.yml] +# rbac.yaml +apiVersion: v1 +kind: ServiceAccount +metadata: + name: pod-viewer +--- +# clusterrole.yaml +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: pod-viewer-role +rules: + - apiGroups: [""] + resources: ["pods", "pods/log", "nodes"] + verbs: ["get", "list", "watch"] + - apiGroups: ["metrics.k8s.io"] + resources: ["pods"] + verbs: ["get", "list"] +--- +# clusterrolebinding.yaml +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: pod-viewer-binding +subjects: + - kind: ServiceAccount + name: pod-viewer + namespace: default +roleRef: + kind: ClusterRole + name: pod-viewer-role + apiGroup: rbac.authorization.k8s.io +--- +# deployment.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: dozzle +spec: + replicas: 1 + selector: + matchLabels: + app: dozzle + template: + metadata: + labels: + app: dozzle + spec: + serviceAccountName: pod-viewer + containers: + - name: dozzle + image: amir20/dozzle:latest + ports: + - containerPort: 8080 + env: + - name: DOZZLE_MODE + value: "k8s" +``` + ::: -See [swarm mode](/guide/swarm-mode) for more information on running Dozzle in Swarm. +See [swarm mode](/guide/swarm-mode) for more information on running Dozzle in Swarm and [Kubernetes](/guide/k8s) for running Dozzle in Kubernetes. > [!TIP] > If Docker Hub is blocked in your network, you can use the [GitHub Container Registry](https://ghcr.io/amir20/dozzle:latest) to pull the image. Use `ghcr.io/amir20/dozzle:latest` instead of `amir20/dozzle:latest`. diff --git a/docs/guide/k8s.md b/docs/guide/k8s.md new file mode 100644 index 00000000..1701d174 --- /dev/null +++ b/docs/guide/k8s.md @@ -0,0 +1,92 @@ +--- +title: Kubernetes Support +--- + +# Kubernetes Support + +Dozzle now supports Kubernetes, allowing you to view logs from your Kubernetes pods. This feature is available in `v8.11` version of Dozzle. + +## Kubernetes Setup + +To set up Dozzle in Kubernetes, you can use the following YAML configuration using `DOZZLE_MODE=k8s`. This configuration includes a deployment and a service to expose Dozzle. + +```yaml +# rbac.yaml +apiVersion: v1 +kind: ServiceAccount +metadata: + name: pod-viewer +--- +# clusterrole.yaml +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: pod-viewer-role +rules: + - apiGroups: [""] + resources: ["pods", "pods/log", "nodes"] + verbs: ["get", "list", "watch"] + - apiGroups: ["metrics.k8s.io"] + resources: ["pods"] + verbs: ["get", "list"] +--- +# clusterrolebinding.yaml +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: pod-viewer-binding +subjects: + - kind: ServiceAccount + name: pod-viewer + namespace: default +roleRef: + kind: ClusterRole + name: pod-viewer-role + apiGroup: rbac.authorization.k8s.io +--- +# deployment.yaml +apiVersion: apps/v1 +kind: Deployment +metadata: + name: dozzle +spec: + replicas: 1 + selector: + matchLabels: + app: dozzle + template: + metadata: + labels: + app: dozzle + spec: + serviceAccountName: pod-viewer + containers: + - name: dozzle + image: amir20/dozzle:latest + ports: + - containerPort: 8080 + env: + - name: DOZZLE_MODE + value: "k8s" +--- +# service.yaml +apiVersion: v1 +kind: Service +metadata: + name: dozzle-service +spec: + type: ClusterIP + selector: + app: dozzle + ports: + - port: 8080 + targetPort: 8080 + protocol: TCP +``` + +This configuration creates a service account, a cluster role, and a cluster role binding to allow Dozzle to access the necessary Kubernetes resources. It also creates a deployment for Dozzle and exposes it via a service. + +All other features are supported as well, including authentication, filtering, and more. You can use the same environment variables as you would in Docker to configure Dozzle in Kubernetes. + +> [!NOTE] +> Dozzle in Kubernetes is a new feature and may have some limitations compared to the Docker version. Please use this [discussion](https://github.com/amir20/dozzle/discussions/3614) to report any issues or suggestions for improvement. diff --git a/examples/users.yml b/examples/users.yml index 1c859e77..dc482837 100644 --- a/examples/users.yml +++ b/examples/users.yml @@ -2,4 +2,4 @@ users: amir: email: "" name: Amir - password: 5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8 + password: $2a$11$nXizfBMJrSwfo4ofkS62denLyCKX0X7VsmfTbMyD3thTkmuGNp8.m