|
|
||
|---|---|---|
| .gitignore | ||
| Jenkinsfile | ||
| createDash.py | ||
| environment.yaml | ||
| kubernetes_tiles_template.json | ||
| readme.md | ||
| requirements.txt | ||
readme.md
Kubernetes dashboard as a code
This repository holds the code to generate the Kubernetes overwiew Dashboard as Code.
Dashboard is generated for specific cluster provided as parameter for the script.
Dashboard naming convention is: "[PROVIDED CLUSTER NAME] - Kubernetes cluster overview"
Running with Jenkins
To run this script with Jenkins go to Jenkins project: https://jaws.bmwgroup.net/opapm/job/CoCo_Kubernetes_Dashboard_as_code/job/master/ then use option "Build with parameters".
Jenkins provides following parameters:
CLUSTER - value is provided as "-C CLUSTER, --cluster CLUSTER" parameter for script
ENVIRONMENT - value is provided as "-E ENVIRONMENT, --environment ENVIRONMENT" parameter for script
OWNER - value is provided as "-O OWNER, --owner OWNER" parameter for script
REMOVE - value is provided as "--remove" parameter for script
Using webhook
To run job with webhook include above parameters as URL params:
Create or update:
curl -X POST "https://jaws.bmwgroup.net/opapm/job/CoCo_Kubernetes_Dashboard_as_code/job/master/buildWithParameters?CLUSTER=[CLUSTER]&ENVIRONMENT=[ENVIRONMENT]&OWNER=[YOUR_EMAIL_ADDRESS]" --user USERNAME:APITOKEN
Delete:
curl -X POST "https://jaws.bmwgroup.net/opapm/job/CoCo_Kubernetes_Dashboard_as_code/job/master/buildWithParameters?CLUSTER=[CLUSTER]&ENVIRONMENT=[ENVIRONMENT]&&REMOVE=true" --user USERNAME:APITOKEN
Prerequisites
Python packages
Before executing scripts, python requirements have to be satisfied. To do so, execute following command: pip install -r requirements.txt
.env file
To provide authentication for API calls, create ".env" file in the script directory with following definition:
<ENV NAME>=<ENV TOKEN>
<ENV NAME> is name of environment variable. This name should be passed to "environment.yaml" file as "env-token-name" parameter
Example:
environment.yaml file: "- env-token-name: "GLOBAL_CONFIG_TOKEN"
.env file: "GLOBAL_CONFIG_TOKEN=XXXXXXXXXXX"
DASHBOARD_OWNER=<owner e-mail>
Dashboard owner e-mail address.
Usage
usage: createDash.py [-h] -C CLUSTER [--remove] [-E ENVIRONMENT] [-O OWNER]
Generate and deploy the Kubernetes Overview Dashboard as Code.
options:
-h, --help show this help message and exit
-C CLUSTER, --cluster CLUSTER
Name of the Kubernetes cluster (default: None)
--remove Remove dashboard for given cluster. If not specified dashboard will be created or updated (default: False)
-E ENVIRONMENT, --environment ENVIRONMENT
Name of the environment (the same as in environment.yaml file. Used to upload dashboard to specific Dynatrace environment. If not specified all environments in file will be used
(default: None)
-O OWNER, --owner OWNER
Email address of dashboard owner (default: None)
Files
createDash.py
This scripts generates Dashboard and uploads it to Dynatrace.
environment.yaml
File containing environments to connect to Dynatrace tenant
Environment name:
name: string #name ov environment
env-url: str #url of environment
env-token-name: str #name of environment variable containing API token
requirements.txt
File containing required python packages
kubernetes_tiles_template.json
File containing template for dashboard