openshift-toolkit icon indicating copy to clipboard operation
openshift-toolkit copied to clipboard

Add dashboard capacity-by-nodetype

Open bszeti opened this issue 6 years ago • 10 comments
trafficstars

Custom dashboards about resource utilization and node capacity (grouped by node role).

bszeti avatar Oct 09 '19 14:10 bszeti

hey @bszeti it looks like there is likely some overlap between these dashboards, and the one that we have in https://github.com/redhat-cop/openshift-toolkit/tree/master/capacity-dashboard. Could you take a look at this, and maybe suggest some enhancements so that we don't end up with competing solutions in the same repo?

cc: @raffaelespazzoli @shah-zobair

etsauer avatar Oct 09 '19 15:10 etsauer

Yes, and I've talked to Raffaele about this. The "capacity" dashboards requires a special "nodegroup" label on nodes and shows the resource utilization when we have different group of compute nodes in the claster. The "capacity-by-nodetype" dashboards don't need special labels, they work with the default "role.kubernetes.io/..." label, so they can be deployed on any OpenShift v3.11 clusters. So the two dashboards show similar metrics, but were built to solve a different problem.

bszeti avatar Oct 09 '19 15:10 bszeti

@bszeti ok, I would say that these dashboards should probably live in the /capacity-dashboard/ space, rather than the custom-dashboards space, which is really about deploying a customizable grafana, not about the dashboards.

etsauer avatar Oct 11 '19 14:10 etsauer

@etsauer ok, at the moment the "capacity dashboards" are duplicated in the repo. They are under "capacity-dashboard" directory and also in the yaml files under "custom-dasboards/.openshift/dashboards/capacity". The purpose of "custom-dashboards" is to be able to run openshift-applier and bring up a custom Grafana with all our custom dashboards, so it's easy to try. This is what I tried to follow in the first round. Do you want me to completely remove the "capacity-by-nodetype" dashboards from there and not make them part of the openshift-applier deployment? If yes, then I would add a new directory "capacity-by-nodetype-dashboard" (next to "capacity-dashboard") with the Grafana json files and README. Is that ok?

bszeti avatar Oct 23 '19 14:10 bszeti

@bszeti rather than have the dashboards in two places, I would just point applier to the dashboard in "{{ inventory_dir }}/../../../capacity-dashboard/grafana-dashboard-capacity-by-nodetype.yml"

etsauer avatar Oct 24 '19 14:10 etsauer

@etsauer I'm taking a look at this now. I see two use cases:

  • manually import the dashboards via Grafana UI. This requires a json files. For example /capacity-dashboard/capacity-planning.json

  • have the dashboard added by OpenShift Applier. This requires a yaml file ConfigMap. For example /custom-dashboards/.openshift/dashboards/capacity/dashboard-capacity.yml

Ideally the ConfigMap yaml file should somehow refer to the json files, but I don't know if it's possible. Is there a way to do something like this with the applier:

apiVersion: v1
kind: ConfigMap
data:
  namespaces-in-cluster.json: **import** {{ inventory_dir }}/../../../capacity-dashboard/namespaces-in-cluster.json
  pods-in-namespace.json: **import** {{ inventory_dir }}/../../../capacity-dashboard/pods-in-namespace.json
  summary-by-node.json: **import** {{ inventory_dir }}/../../../capacity-dashboard/summary-by-node.json
  summary-by-nodetype.json: **import** {{ inventory_dir }}/../../../capacity-dashboard/summary-by-nodetype.json

If this is not possible, then I don't know how to support both scenarios (manual import and applier) without duplicating the json definitions.

bszeti avatar Oct 31 '19 19:10 bszeti

@bszeti So, I haven't tried this, but Applier supports Jinja2 templates, which has an include function. See if you can make that work. If you can it would be really nice to somehow document that approach, as this is a common sticking point with managing configmaps.

https://jinja.palletsprojects.com/en/2.10.x/templates/#include

etsauer avatar Nov 01 '19 00:11 etsauer

I'm trying to use jinja like this: {% include "namespaces-in-cluster.json" %} or {% include inventory_dir + '/../.openshift/dashboards/capacity-by-nodetype/namespaces-in-cluster.json' %} or even with absolute path {% include "/Users/bszeti/git/openshift-toolkit/custom-dashboards/.openshift/dashboards/capacity-by-nodetype/namespaces-in-cluster.json" %}

but I'm keep getting an error with applier:

TASK [openshift-applier : Process Jinja template] ******************************************************************************************************************************************************************************************** fatal: [localhost -> localhost]: FAILED! => {"changed": false, "msg": "TemplateNotFound: /Users/bszeti/git/openshift-toolkit/custom-dashboards/.applier/../.openshift/dashboards/capacity-by-nodetype/namespaces-in-cluster.json"}

Any ideas? How is the template lookup done in this task?

bszeti avatar Nov 01 '19 22:11 bszeti

It seems that the {% include [file] %} only works if the file is under the role. In this case "galaxy/openshift-applier/roles/openshift-applier", which is obviously not god for us. (Also "../../../../namespaces-in-cluster.json" didn't work"). Because of this I don't know how to arrange the files better than in the original commit.

Another related problem is that the included file is processed as a template so any "{{" causes issues. This later problem may be handled by adding {% raw %}...{% endraw %} in the included file...

For the record we tried:

{% macro include_namespaces_in_cluster() %}{% include 'namespaces-in-cluster.json' %}{% endmacro %}
data:
  namespaces-in-cluster.json: |
    {{ include_namespaces_in_cluster() | indent(4) }}

bszeti avatar Nov 03 '19 00:11 bszeti

@etsauer Any suggestions?

bszeti avatar Nov 12 '19 02:11 bszeti