Skip to content

slashdevops/kube-visibility

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kube-visibility

Work In Progress (WIP)

This project was inspired by kube-prometheus bundle but instead of use jsonnet to customize and configure it, this use kustomize to overlay Kubernetes manifests and kpt to distribute it as a package.

Also, this is GitOps friendly.

Components of this bundle

This kpt package will install the following software list into your Kubernetes cluster

Project License
kubernetes-mixin Apache License 2.0
kube-state-metrics Apache License 2.0
node_exporter Apache License 2.0
prometheus-operator Apache License 2.0
k8s-prometheus-adapter Apache License 2.0
kube-rbac-proxy Apache License 2.0
prometheus Apache License 2.0
alertmanager Apache License 2.0
grafana Apache License 2.0

NOTES:

  1. kubernetes-mixin provides some prometheus rules and dashboards.

Used Tools

Project License
kpt Apache License 2.0
kustomize Apache License 2.0

Components Versions

Kubernetes version supported

  • >= 1.19.x

Project Layout Structure

The layout structure for this project is simple, the pkg folder contains the kpt blueprint implementation of kube-visibility, which is separate from the root of git project intentionally to avoid unnecessary files into the package when you install it using kpt pkg get command. The root folder could contain additional docs, examples, and CI/CD pipeline definitions.

Customization and packager tool

The heart of this project are these two tools, so if you want to contribute with it you need to understand and manage it.

and of course, it is was possible thanks to the big and great idea of kube-prometheus project.

How to Install

To install this kpt package you just need to know about KPT Package Consumers , but in short:

kpt pkg get https://github.com/slashdevops/kube-visibility/pkg@master kube-visibility

NOTE: Remember the pkg folder into the git path

Try it on minikube

Looks inside HowTos folder for more detailed information about how to prepare minikube

minikube setting

MacOS

minikube delete
minikube config set memory 6144
minikube config set cpus 2
minikube config set disk-size 40G
minikube config set vm-driver docker
minikube config set kubernetes-version 1.19.8
minikube config view

minikube start

minikube status

Linux

# set
minikube config set memory 6144 # > much better
minikube config set cpus 2      # > much better
minikube config set disk-size 40G
minikube config set vm-driver kvm2 # for linux, for MacOS see HowTos/ folder
minikube config set kubernetes-version 1.19.8
minikube config view

# start
minikube start

# check
minikube status

Install kubernetes dashboard

# OPTIONAL, EXECUTE IT IN DIFFERENT TERMINAL
# I recommended it to see what is happening inside your cluster
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.3.1/aio/deploy/recommended.yaml
kubectl create clusterrolebinding cluster-admin-binding --clusterrole=cluster-admin --serviceaccount=kube-system:default
kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep default | awk '{print $1}')
kubectl proxy
# then, open the following link in your browser: http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy

Download and Apply

Download and install the kpt pkg from master branch or the specify the release tag, more information here Command Reference / pkg / get

Install kpt

brew tap GoogleContainerTools/kpt https://github.com/GoogleContainerTools/kpt.git
brew install kpt

Install kube-visibility

mkdir k8s-workspace
cd k8s-workspace/
kpt pkg get https://github.com/slashdevops/kube-visibility/pkg@master kube-visibility

# OPTIONAL, using git
git init .
git add .
git commit -am "added kube-visibility tool"

# OPTIONAL, using kpt live
kpt live init kube-visibility/

# OPTIONAL, list available kpt setters
kpt cfg list-setters kube-visibility/

# OPTIONAL, change one setter
kpt cfg set kube-visibility/ alertmanager.resources-limits-cpu 120m

# INSTALL, install kube-visibility manifests
# WORKAROUND, until kpt avoid problems with json and yaml files that not are part of k8s 'kind'
# Apply the manifest bundle to the cluster
# NOTE 1: the first time you execute this command some errors appears at the end, wait until
# prometheus-operator is up before apply again! (see the NOTE below).
# to see it, use the command 'kubectl get pod --all-namespaces' or just see in the kubernetes-dashboard (step above)
# NOTE 2: The second time you apply this command, they are take to long, because depending prometheus CRDs are big!
kustomize build kube-visibility/instance | kubectl apply -f -

# OPTIONAL, depend on 'kpt live init'
# kpt live apply kube-visibility/ --reconcile-timeout=10m

NOTE: The bundle of manifest generated with kustomize has some dependencies with each other (prometheus depends on prometheus-operator and needs that it was created first), so when you execute the first time the manifest, some errors will occur. After the first execution you need to wait until some resources were created, and then you can execute again the command to create the resources into the k8s cluster. If you are using the kubernetes-dashboard you can watch when the first execution finished creating the resources, and then you can execute it again to finish with the installation.

Once installed, access to graphical tools

All these tools are accessible (using the method described below) when you follow the instructions described in HowTos folder for minikube

kubernetes Dashboard

Reference: https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.3.1/aio/deploy/recommended.yaml

Create a RoleBinding to kube-system namespace default ServiceAccount to access to the dashboard as ClusterAdmin

kubectl create clusterrolebinding cluster-admin-binding --clusterrole=cluster-admin --serviceaccount=kube-system:default
# get the token
kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep default | awk '{print $1}')

# Execute it in a different terminal
kubectl proxy

Link: Kubernetes Dashboard --> http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy

Prometheus Dashboard

# Execute it in a different terminal
kubectl --namespace kube-visibility port-forward svc/prometheus-visibility 9090

Link: prometheus --> http://localhost:9090

Alertmanager Dashboard

# Execute it in a different terminal
kubectl --namespace kube-visibility port-forward svc/alertmanager-visibility 9093

Link: alertmanager --> http://localhost:9093

Grafana Dashboard

# Execute it in a different terminal
kubectl --namespace kube-visibility port-forward svc/grafana 3000

Link: grafana --> http://localhost:3000

  • user: admin
  • password: admin

Development / Contributing

WIP, but at least

If you want to contribute to this project do the following

  • Fork the project
  • Clone the Forked repository
  • Create a custom branch or work on develop branch
  • Create your custom manifests/modifiers or grafana dashboard or fix some bug what did you find
  • Merge and push your changes to the custom branch or develop branch in your forked repository
  • Create a Pull Request to official project develop branch
  • Wait until your PR to be approved and merged to the master branch

References

License

This module is released under the Apache License Version 2:

Author Information