Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Sync kube-prometheus resources with 0.4.x upstream branch` #183

Merged
merged 14 commits into from Jul 21, 2020
Merged
1,822 changes: 915 additions & 907 deletions images/grafana/rootfs/etc/grafana/dashboards/k8s-cluster-rsrc-use.json

Large diffs are not rendered by default.

3,987 changes: 2,542 additions & 1,445 deletions images/grafana/rootfs/etc/grafana/dashboards/k8s-resources-cluster.json

Large diffs are not rendered by default.

2,741 changes: 1,830 additions & 911 deletions images/grafana/rootfs/etc/grafana/dashboards/k8s-resources-namespace.json

Large diffs are not rendered by default.

1,605 changes: 1,605 additions & 0 deletions images/grafana/rootfs/etc/grafana/dashboards/k8s-resources-pod.json

Large diffs are not rendered by default.

2,883 changes: 1,999 additions & 884 deletions images/grafana/rootfs/etc/grafana/dashboards/k8s-resources-workload.json

Large diffs are not rendered by default.

Large diffs are not rendered by default.

980 changes: 0 additions & 980 deletions images/grafana/rootfs/etc/grafana/dashboards/k8s-resources.pod.json

This file was deleted.

2,620 changes: 1,288 additions & 1,332 deletions images/grafana/rootfs/etc/grafana/dashboards/nodes.json

Large diffs are not rendered by default.

1,240 changes: 599 additions & 641 deletions images/grafana/rootfs/etc/grafana/dashboards/pod.json

Large diffs are not rendered by default.

24 changes: 23 additions & 1 deletion images/hook/entrypoint.sh
Expand Up @@ -20,6 +20,28 @@ if [ $1 = "update" ]; then
echo "---> Deleting old deployment 'kapacitor'"
rig delete deployments/kapacitor --resource-namespace=monitoring --force

echo "---> Removing last applied configuration from resources"
for deployment in grafana kube-state-metrics prometheus-adapter prometheus-operator watcher
do
# || true is needed in case resources does not have last applied configuration
kubectl --namespace=monitoring patch deployments.apps $deployment --type=json -p='[{"op": "replace", "path": "/metadata/managedFields", "value": [{}]}]' || true
kubectl --namespace=monitoring patch deployments.apps $deployment --type=json -p='[{"op": "remove", "path": "/metadata/annotations/kubectl.kubernetes.io~1last-applied-configuration"}]' || true
done
for daemonset in nethealth node-exporter
do
# || true is needed in case resources does not have last applied configuration
kubectl --namespace=monitoring patch daemonsets.apps $daemonset --type=json -p='[{"op": "replace", "path": "/metadata/managedFields", "value": [{}]}]' || true
kubectl --namespace=monitoring patch daemonsets.apps $daemonset --type=json -p='[{"op": "remove", "path": "/metadata/annotations/kubectl.kubernetes.io~1last-applied-configuration"}]' || true
done
for configmap in adapter-config grafana-cfg prometheus-k8s-rulefiles-0 grafana-dashboard-k8s-cluster-rsrc-use grafana-dashboard-k8s-resources-cluster \
grafana-dashboard-k8s-resources-namespace grafana-dashboard-k8s-resources-pod grafana-dashboard-k8s-resources-workload grafana-dashboard-k8s-resources-workloads-namespace \
grafana-dashboard-nodes grafana-dashboard-pods grafana-dashboard-nethealth grafana-dashboards
do
# || true is needed in case resources does not have last applied configuration
kubectl --namespace=monitoring patch configmaps $configmap --type=json -p='[{"op": "replace", "path": "/metadata/managedFields", "value": [{}]}]' || true
kubectl --namespace=monitoring patch configmaps $configmap --type=json -p='[{"op": "remove", "path": "/metadata/annotations/kubectl.kubernetes.io~1last-applied-configuration"}]' || true
done

echo "---> Deleting old configmaps"
for configmap in influxdb grafana kapacitor-alerts rollups-default grafana-dashboard-k8s-cluster-rsrc-use grafana-dashboard-k8s-resources-cluster \
grafana-dashboard-k8s-resources-namespace grafana-dashboard-k8s-resources-pod grafana-dashboard-k8s-resources-workload grafana-dashboard-k8s-resources-workloads-namespace \
Expand All @@ -31,7 +53,7 @@ if [ $1 = "update" ]; then
echo "---> Creating monitoring namespace"
rig upsert -f /var/lib/gravity/resources/namespace.yaml --debug

for file in /var/lib/gravity/resources/crds/*
for file in /var/lib/gravity/resources/kube-prometheus-setup/*
do
rig upsert -f $file --debug
done
Expand Down
2,411 changes: 0 additions & 2,411 deletions resources/crds/0prometheus-operator-0alertmanagerCustomResourceDefinition.yaml

This file was deleted.

3,199 changes: 0 additions & 3,199 deletions resources/crds/0prometheus-operator-0prometheusCustomResourceDefinition.yaml

This file was deleted.

This file was deleted.

13 changes: 8 additions & 5 deletions resources/install.sh
Expand Up @@ -2,19 +2,22 @@

/opt/bin/kubectl apply -f /var/lib/gravity/resources/namespace.yaml

for file in /var/lib/gravity/resources/crds/*
for file in /var/lib/gravity/resources/kube-prometheus-setup/*
do
head -n -6 $file | /opt/bin/kubectl apply -f -
/opt/bin/kubectl create -f $file
done

# Wait until setup of CRDs are done
until /opt/bin/kubectl get servicemonitors --all-namespaces ; do echo $(date) ": Waiting for CRDs to setup"; done

# Generate password for Grafana administrator
password=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1 | tr -d '\n ' | /opt/bin/base64)
sed -i s/cGFzc3dvcmQtZ29lcy1oZXJlCg==/$password/g /var/lib/gravity/resources/grafana.yaml

for name in security grafana watcher
do
/opt/bin/kubectl apply -f /var/lib/gravity/resources/${name}.yaml
/opt/bin/kubectl create -f /var/lib/gravity/resources/${name}.yaml
done

/opt/bin/kubectl apply -f /var/lib/gravity/resources/prometheus/
/opt/bin/kubectl apply -f /var/lib/gravity/resources/nethealth/
/opt/bin/kubectl create -f /var/lib/gravity/resources/prometheus/
/opt/bin/kubectl create -f /var/lib/gravity/resources/nethealth/

Large diffs are not rendered by default.

@@ -1,80 +1,70 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.2.4
creationTimestamp: null
name: servicemonitors.monitoring.coreos.com
name: podmonitors.monitoring.coreos.com
spec:
group: monitoring.coreos.com
names:
kind: ServiceMonitor
plural: servicemonitors
kind: PodMonitor
listKind: PodMonitorList
plural: podmonitors
singular: podmonitor
preserveUnknownFields: false
scope: Namespaced
validation:
openAPIV3Schema:
description: PodMonitor defines monitoring for a set of pods.
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds'
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: ServiceMonitorSpec contains specification parameters for a
ServiceMonitor.
description: Specification of desired Pod selection for target discovery
by Prometheus.
properties:
endpoints:
description: A list of endpoints allowed as part of this ServiceMonitor.
jobLabel:
description: The label to use to retrieve the job name from.
type: string
namespaceSelector:
description: Selector to select which namespaces the Endpoints objects
are discovered from.
properties:
any:
description: Boolean describing whether all namespaces are selected
in contrast to a list restricting them.
type: boolean
matchNames:
description: List of namespace names.
items:
type: string
type: array
type: object
podMetricsEndpoints:
description: A list of endpoints allowed as part of this PodMonitor.
items:
description: Endpoint defines a scrapeable endpoint serving Prometheus
metrics.
description: PodMetricsEndpoint defines a scrapeable endpoint of a
Kubernetes Pod serving Prometheus metrics.
properties:
basicAuth:
description: 'BasicAuth allow an endpoint to authenticate over
basic authentication More info: https://prometheus.io/docs/operating/configuration/#endpoints'
properties:
password:
description: SecretKeySelector selects a key of a Secret.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
type: string
optional:
description: Specify whether the Secret or it's key must
be defined
type: boolean
required:
- key
username:
description: SecretKeySelector selects a key of a Secret.
properties:
key:
description: The key of the secret to select from. Must
be a valid secret key.
type: string
name:
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
type: string
optional:
description: Specify whether the Secret or it's key must
be defined
type: boolean
required:
- key
bearerTokenFile:
description: File to read bearer token for scraping targets.
type: string
honorLabels:
description: HonorLabels chooses the metric's labels on collisions
with target labels.
type: boolean
honorTimestamps:
description: HonorTimestamps controls whether Prometheus respects
the timestamps present in scraped data.
type: boolean
interval:
description: Interval at which metrics should be scraped
type: string
Expand All @@ -97,7 +87,7 @@ spec:
type: integer
regex:
description: Regular expression against which the extracted
value is matched. defailt is '(.*)'
value is matched. Default is '(.*)'
type: string
replacement:
description: Replacement value against which a regex replace
Expand All @@ -121,16 +111,21 @@ spec:
in a replace action. It is mandatory for replace actions.
Regex capture groups are available.
type: string
type: object
type: array
params:
additionalProperties:
items:
type: string
type: array
description: Optional HTTP URL parameters
type: object
path:
description: HTTP path to scrape for metrics.
type: string
port:
description: Name of the service port this endpoint refers to.
Mutually exclusive with targetPort.
description: Name of the port this endpoint refers to. Mutually
exclusive with targetPort.
type: string
proxyUrl:
description: ProxyURL eg http://proxyserver:2195 Directs scrapes
Expand All @@ -156,7 +151,7 @@ spec:
type: integer
regex:
description: Regular expression against which the extracted
value is matched. defailt is '(.*)'
value is matched. Default is '(.*)'
type: string
replacement:
description: Replacement value against which a regex replace
Expand All @@ -180,6 +175,7 @@ spec:
in a replace action. It is mandatory for replace actions.
Regex capture groups are available.
type: string
type: object
type: array
scheme:
description: HTTP scheme to use for scraping.
Expand All @@ -189,43 +185,13 @@ spec:
type: string
targetPort:
anyOf:
- type: string
- type: integer
tlsConfig:
description: TLSConfig specifies TLS configuration parameters.
properties:
caFile:
description: The CA cert to use for the targets.
type: string
certFile:
description: The client cert file for the targets.
type: string
insecureSkipVerify:
description: Disable target certificate validation.
type: boolean
keyFile:
description: The client key file for the targets.
type: string
serverName:
description: Used to verify the hostname for the targets.
type: string
- type: string
description: Name or number of the target port of the endpoint.
Mutually exclusive with port.
x-kubernetes-int-or-string: true
type: object
type: array
jobLabel:
description: The label to use to retrieve the job name from.
type: string
namespaceSelector:
description: NamespaceSelector is a selector for selecting either all
namespaces or a list of namespaces.
properties:
any:
description: Boolean describing whether all namespaces are selected
in contrast to a list restricting them.
type: boolean
matchNames:
description: List of namespace names.
items:
type: string
type: array
podTargetLabels:
description: PodTargetLabels transfers labels on the Kubernetes Pod
onto the target.
Expand All @@ -238,10 +204,7 @@ spec:
format: int64
type: integer
selector:
description: A label selector is a label query over a set of resources.
The result of matchLabels and matchExpressions are ANDed. An empty
label selector matches all objects. A null label selector matches
no objects.
description: Selector to select Pod objects.
properties:
matchExpressions:
description: matchExpressions is a list of label selector requirements.
Expand Down Expand Up @@ -271,21 +234,33 @@ spec:
required:
- key
- operator
type: object
type: array
matchLabels:
additionalProperties:
type: string
description: matchLabels is a map of {key,value} pairs. A single
{key,value} in the matchLabels map is equivalent to an element
of matchExpressions, whose key field is "key", the operator is
"In", and the values array contains only "value". The requirements
are ANDed.
type: object
targetLabels:
description: TargetLabels transfers labels on the Kubernetes Service
onto the target.
items:
type: string
type: array
type: object
required:
- endpoints
- podMetricsEndpoints
- selector
type: object
required:
- spec
type: object
version: v1
versions:
- name: v1
served: true
storage: true
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []