Kubernetes Web View’s behavior and appearance can be customized for the needs of your organization:
- resource type links shown in the Sidebar can be customized to add CRDs, or to optimize for frequent access
- default Label & Custom Columns can be defined to show values of standardized object labels (e.g. “app”, “version”, etc)
- External Links can be added to link objects to monitoring tools, internal application registries, custom UIs, etc
- the Search can be customized to search in CRDs, or to cover frequent search cases
- setting Preferred API Versions allows forcing the use of specific/newer Kubernetes API versions
- one of the Themes can be selected as default, or you can create your own CSS theme
- HTML Templates can be customized to match your branding, to add static links, and to inject custom JS/CSS
- Static Assets can be included to add images, JS, or CSS files
Label & Custom Columns¶
Most organizations have a standard set of labels for Kubernetes resources, e.g. all pods might have “app” and “version” labels.
You can instruct Kubernetes Web View to show these labels as columns for the respective resource types via the
--default-label-columns command line option.
Example command line argument to show the “application” and “version” labels for pods and the “team” label for deployments:
Note that the label names are separated by comma (“,”) whereas multiple different entries for different resource types are separated by semicolon (“;”).
Users of the web UI can remove the pre-configured label columns by passing a single comma as the
labelcols query parameter:
You can hide existing columns via the
--default-hidden-columns command line option, e.g. to remove the “Nominated Node” and “Readiness Gates” columns from pod tables:
--default-hidden-columns=pods=Nominated Node,Readiness Gates
Arbitrary custom columns can be defined with JMESPath expressions, e.g. add a column “Images” for pods and the column “Strategy” for deployments:
Multiple column definitions are separated by a single semicolon (“;”) whereas multiple different entries for different resource types are separated by two semicolons (“;;”). Please be aware that custom columns require one additional Kubernetes API call per listing.
The default search resource types can be customized, e.g. to include Custom Resource Definitions (CRDs) or to optimize for frequent search patterns. Pass comma-separated lists of resource types (plural name) to the following two command line options:
- Set the resource types to search by default (when using the navbar search box). Must be a comma-separated list of resource types, e.g. “deployments,pods”.
- Customize the list of resource types shown on the search page (
/search). Must be a comma-separated list of resource types, e.g. “deployments,pods,nodes”.
Note that all resource types can be searched by using a deep-link, i.e. these options will only restrict what is shown in the HTML UI, but they will not prohibit searching for other resource types.
Preferred API Versions¶
You might want to change the default preferred API version returned by the Kubernetes API server. This is useful to force using a later/newer API version for some resources, e.g. the Kubernetes HorizontalPodAutoscaler has a different spec for later versions.
Here the example CLI option to force using new API versions for Deployment and HPA (the default is
autoscaling/v1 as of Kubernetes 1.14):
Kubernetes Web View ships with a number of color (CSS) themes. You can choose a default theme for your users via
--default-theme and/or limit the selection via
--theme-options. Available themes are:
- Flatly in night mode: dark background, blue and green as primary colors, see darkly demo
- Kubernetes Web View default theme: white background, blue as primary color, see default demo
- Flat and thick: white background, blue and green as primary colors, see flatly demo
- Shades of gunmetal grey: dark grey background, grey colors, see slate demo
- The brave and the blue: dark background, orange navbar, see superhero demo
You can use one of the Bulmaswatch themes to create your own.
Custom Jinja2 HTML templates can override any of the default templates.
Mount your custom templates into kube-web-view’s pod and point the
--templates-path to it.
Here some of the common templates you might want to customize:
- The main HTML layout (contains
- Optional extra content for the
<head>HTML part. Use this template to add any custom JS/CSS.
- The top navigation bar.
- Template for the left sidebar, customize this to add your own links. Note that you can change the list of resource types without touching HTML via
--sidebar-resource-types, see the sidebar section.
- Footer element at the end of the HTML
You can find all the standard templates in the official git repo: https://codeberg.org/hjacobs/kube-web-view/src/branch/master/kube_web/templates
You can build your own Docker image containing the templates or you can use a volume of type
emptyDir and some InitContainer to inject your templates.
Example pod spec with a custom footer:
spec: initContainers: - name: generate-templates image: busybox command: ["sh", "-c", "mkdir /templates/partials && echo '<footer class=\"footer\">YOUR CUSTOM CONTENT HERE</footer>' > /templates/partials/footer.html"] volumeMounts: - mountPath: /templates name: templates containers: - name: kube-web-view # see https://codeberg.org/hjacobs/kube-web-view/releases image: hjacobs/kube-web-view:latest args: - --port=8080 - --templates-path=/templates ports: - containerPort: 8080 readinessProbe: httpGet: path: /health port: 8080 volumeMounts: - mountPath: /templates name: templates readOnly: true resources: limits: memory: 100Mi requests: cpu: 5m memory: 100Mi securityContext: readOnlyRootFilesystem: true runAsNonRoot: true runAsUser: 1000 volumes: - name: templates emptyDir: sizeLimit: 50Mi
As you might want to add or change static assets (e.g. JS, CSS, images),
you can point Kubernetes Web View to a folder containing your custom assets.
--static-assets-path command line option for this and either build a custom Docker image or mount your asset directory into the pod.