examples: update platform snippets and doc

Signed-off-by: Damien Grisonnet <dgrisonn@redhat.com>
This commit is contained in:
Damien Grisonnet 2021-04-06 11:33:07 +02:00
parent f06175bb3b
commit b59b2c23d8
12 changed files with 38 additions and 81 deletions

View File

@ -360,57 +360,28 @@ Jsonnet is a turing complete language, any logic can be reflected in it. It also
### Cluster Creation Tools
A common example is that not all Kubernetes clusters are created exactly the same way, meaning the configuration to monitor them may be slightly different. For [kubeadm](examples/jsonnet-snippets/kubeadm.jsonnet), [bootkube](examples/jsonnet-snippets/bootkube.jsonnet), [kops](examples/jsonnet-snippets/kops.jsonnet) and [kubespray](examples/jsonnet-snippets/kubespray.jsonnet) clusters there are mixins available to easily configure these:
A common example is that not all Kubernetes clusters are created exactly the same way, meaning the configuration to monitor them may be slightly different. For the following clusters there are mixins available to easily configure them:
kubeadm:
* aws
* bootkube
* eks
* gke
* kops-coredns
* kubeadm
* kubespray
[embedmd]:# (examples/jsonnet-snippets/kubeadm.jsonnet)
These mixins are selectable via the `platform` field of kubePrometheus:
[embedmd]:# (examples/jsonnet-snippets/platform.jsonnet)
```jsonnet
(import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/platforms/kubeadm.libsonnet')
```
bootkube:
[embedmd]:# (examples/jsonnet-snippets/bootkube.jsonnet)
```jsonnet
(import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/platforms/bootkube.libsonnet')
```
kops:
[embedmd]:# (examples/jsonnet-snippets/kops.jsonnet)
```jsonnet
(import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/platforms/kops.libsonnet')
```
kops with CoreDNS:
If your kops cluster is using CoreDNS, there is an additional mixin to import.
[embedmd]:# (examples/jsonnet-snippets/kops-coredns.jsonnet)
```jsonnet
(import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/platforms/kops.libsonnet') +
(import 'kube-prometheus/platforms/kops-coredns.libsonnet')
```
kubespray:
[embedmd]:# (examples/jsonnet-snippets/kubespray.jsonnet)
```jsonnet
(import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/platforms/kubespray.libsonnet')
```
aws:
[embedmd]:# (examples/jsonnet-snippets/aws.jsonnet)
```jsonnet
(import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/platforms/aws.libsonnet')
{
values+:: {
kubePrometheus+: {
platform: 'example-platform',
},
},
}
```
### Internal Registry

View File

@ -7,12 +7,14 @@ One fatal issue that can occur is that you run out of IP addresses in your eks c
You can monitor the `awscni` using kube-promethus with :
[embedmd]:# (../examples/eks-cni-example.jsonnet)
```jsonnet
local kp = (import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/platforms/eks.libsonnet') + {
local kp = (import 'kube-prometheus/main.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
kubePrometheus+: {
platform: 'eks',
},
},
kubernetesControlPlane+: {
prometheusRuleEksCNI+: {

View File

@ -1,9 +1,11 @@
local kp = (import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/platforms/eks.libsonnet') + {
local kp = (import 'kube-prometheus/main.libsonnet') + {
values+:: {
common+: {
namespace: 'monitoring',
},
kubePrometheus+: {
platform: 'eks',
},
},
kubernetesControlPlane+: {
prometheusRuleEksCNI+: {

View File

@ -1,2 +0,0 @@
(import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/platforms/aws.libsonnet')

View File

@ -1,2 +0,0 @@
(import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/platforms/bootkube.libsonnet')

View File

@ -1,3 +0,0 @@
(import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/platforms/kops.libsonnet') +
(import 'kube-prometheus/platforms/kops-coredns.libsonnet')

View File

@ -1,2 +0,0 @@
(import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/platforms/kops.libsonnet')

View File

@ -1,2 +0,0 @@
(import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/platforms/kubeadm.libsonnet')

View File

@ -1,2 +0,0 @@
(import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/platforms/kubespray.libsonnet')

View File

@ -0,0 +1,8 @@
(import 'kube-prometheus/main.libsonnet') +
{
values+:: {
kubePrometheus+: {
platform: 'example-platform',
},
},
}

View File

@ -1,6 +1,5 @@
local kp =
(import 'kube-prometheus/main.libsonnet') +
(import 'kube-prometheus/platforms/kubeadm.libsonnet') +
// Note that NodePort type services is likely not a good idea for your production use case, it is only used for demonstration purposes here.
(import 'kube-prometheus/addons/node-ports.libsonnet') +
{
@ -19,6 +18,9 @@ local kp =
},
},
},
kubePrometheus+: {
platform: 'kubeadm',
},
},
// For simplicity, each of the following values for 'externalUrl':

View File

@ -1,18 +1,3 @@
# Adding a new platform specific configuration
Adding a new platform specific configuration requires to update the
[platforms.jsonnet](./platform.jsonnet) file by adding the platform to the list
of existing ones.
This allow configuring the new platform in the following way:
```jsonnet
(import 'kube-prometheus/main.libsonnet') +
{
values+:: {
kubePrometheus+: {
platform: 'example-platform',
}
}
}
```
Adding a new platform specific configuration requires to update the [README](../../../README.md#cluster-creation-tools) and the [platforms.jsonnet](./platform.jsonnet) file by adding the platform to the list of existing ones. This allow the new platform to be discoverable and easily configurable by the users.