Tuesday, July 9, 2019

Kubernetes dashboard pagination - number of rows per page without logging in

Recently I am working with kubernetes dashboard on both minicube and a cluster.
While kuberneted dashboard can be started as an image (and some configuration can be inserted), its settings are not available per user as they should. I mean - we are using kubernetes (k8s) dashboard without logging in so the settings are not even accessible.

But when you open list of pods, deployments or similar - you are forced to use 10 rows per page. When you apply any change (ex. edit item or scale a deployment) then pagination information is lost - so you start always from the first page.

Yesterday I spent quite a lot of time to get a workaround for the issue.
3 possible solutions I found:

  1. Press F12 in your web browser to access developer's console. Enter the following command:

    window.angular.element(document.querySelector(".ng-scope")).scope().$root.$$childHead.$ctrl.c.a.itemsPerPage=2;
    (You might be disallowed to paste into the window for the first time - as the developer console can be very dangerous)
  2. Use greasemonkey/tampermonkey/violentmonkey and add script like this bellow

    // ==UserScript==
    // @name         k8s dashboard pagination
    // @namespace    k8s
    // @version      0.1
    // @description  Set pagination to 40 elements per page
    // @author       adderek
    // @match        http://yourserver:yourport/*
    // @grant        none
    // ==/UserScript==

    (function() {
        'use strict';
        window.angular
            .element(document.querySelector(".ng-scope")).scope()
            .$root.$$childHead
            .$ctrl.c.a
            .itemsPerPage=40;
    })();
  3. Add a bookmarklet and click on it every time you wish to change number of rows per page

No comments: