diff --git a/assets/prometheus/prometheus.yaml b/assets/prometheus/prometheus.yaml index 08df4789771f3b48d8769d66e3e0305901bb5357..14decf23708b82ec1aa9fb9dfd53cdd98654966a 100644 --- a/assets/prometheus/prometheus.yaml +++ b/assets/prometheus/prometheus.yaml @@ -53,15 +53,10 @@ scrape_configs: relabel_configs: - action: keep source_labels: [__meta_kubernetes_service_name] - regex: prometheus|kubernetes|node-exporter|kube-state-metrics|etcd-k8s + regex: prometheus|node-exporter|kube-state-metrics - action: replace source_labels: [__meta_kubernetes_service_name] target_label: job - - action: replace - source_labels: [__meta_kubernetes_service_name] - regex: kubernetes - target_label: __scheme__ - replacement: https # Scrapes the endpoint lists for the kube-dns server. Which we consider # part of a default setup. @@ -75,13 +70,16 @@ scrape_configs: relabel_configs: - action: replace - source_labels: [__meta_kubernetes_service_name] + source_labels: [__meta_kubernetes_service_label_k8s_app] target_label: job - regex: "kube-(.*)-prometheus-discovery" - replacement: "kube-${1}" - action: keep source_labels: [__meta_kubernetes_service_name] - regex: "kube-(.*)-prometheus-discovery" + regex: ".*-prometheus-discovery" - action: keep source_labels: [__meta_kubernetes_endpoint_port_name] - regex: "prometheus.*" + regex: "http-metrics.*|https-metrics.*" + - action: replace + source_labels: [__meta_kubernetes_endpoint_port_name] + regex: "https-metrics.*" + target_label: __scheme__ + replacement: https diff --git a/hack/cluster-monitoring/deploy b/hack/cluster-monitoring/deploy index a096747e64768a75d356762bb9b83f1a143fd629..95a1b54bde65a673d19143adb453324a0f4bc323 100755 --- a/hack/cluster-monitoring/deploy +++ b/hack/cluster-monitoring/deploy @@ -4,19 +4,24 @@ if [ -z "${KUBECONFIG}" ]; then KUBECONFIG=~/.kube/config fi -kubectl --kubeconfig="$KUBECONFIG" create namespace monitoring +if [ -z "${NAMESPACE}" ]; then + NAMESPACE=monitoring +fi + +kubectl --kubeconfig="$KUBECONFIG" create namespace "$NAMESPACE" kctl() { - kubectl --kubeconfig="$KUBECONFIG" -n "monitoring" "$@" + kubectl --kubeconfig="$KUBECONFIG" -n "$NAMESPACE" "$@" } -kctl apply -f manifests/prometheus-operator.yaml +kctl create -f manifests/prometheus-operator.yaml # Wait for TPRs to be ready. until kctl get servicemonitor; do sleep 1; done until kctl get prometheus; do sleep 1; done +until kctl get alertmanager; do sleep 1; done -kctl apply -f manifests/exporters -kctl apply -f manifests/grafana -kctl apply -f manifests/prometheus -kctl apply -f manifests/alertmanager +kctl create -f manifests/exporters +kctl create -f manifests/grafana +kctl create -f manifests/prometheus +kctl create -f manifests/alertmanager diff --git a/hack/cluster-monitoring/teardown b/hack/cluster-monitoring/teardown index afa4ce1486e0153c95eac0ced8b41e71a60e2df2..490979a1e5b27332d025b5dd51d1222af88dd071 100755 --- a/hack/cluster-monitoring/teardown +++ b/hack/cluster-monitoring/teardown @@ -4,8 +4,12 @@ if [ -z "${KUBECONFIG}" ]; then KUBECONFIG=~/.kube/config fi +if [ -z "${NAMESPACE}" ]; then + NAMESPACE=monitoring +fi + kctl() { - kubectl --kubeconfig="$KUBECONFIG" -n "monitoring" "$@" + kubectl --kubeconfig="$KUBECONFIG" -n "$NAMESPACE" "$@" } kctl delete -f manifests/exporters diff --git a/manifests/etcd/etcd-bootkube-gce.yaml b/manifests/etcd/etcd-bootkube-gce.yaml index ee8f391ce19ed3568fbd004326a522cc95f95255..94e1c020b33f48906da12a50def47c441ab982cc 100644 --- a/manifests/etcd/etcd-bootkube-gce.yaml +++ b/manifests/etcd/etcd-bootkube-gce.yaml @@ -3,8 +3,7 @@ kind: Service metadata: name: etcd-k8s labels: - app: etcd - etcd: k8s + k8s-app: etcd spec: type: ClusterIP clusterIP: None @@ -18,8 +17,7 @@ kind: Endpoints metadata: name: etcd-k8s labels: - app: etcd - etcd: k8s + k8s-app: etcd subsets: - addresses: - ip: 10.142.0.2 diff --git a/manifests/etcd/etcd-bootkube-vagrant-multi.yaml b/manifests/etcd/etcd-bootkube-vagrant-multi.yaml index 38cdc9c40f9db356121d28a20f7e25886f4cfc44..51293c60e96839b4586e11ad9c77033bb554d5b3 100644 --- a/manifests/etcd/etcd-bootkube-vagrant-multi.yaml +++ b/manifests/etcd/etcd-bootkube-vagrant-multi.yaml @@ -3,8 +3,7 @@ kind: Service metadata: name: etcd-k8s labels: - app: etcd - etcd: k8s + k8s-app: etcd spec: type: ClusterIP clusterIP: None @@ -18,8 +17,7 @@ kind: Endpoints metadata: name: etcd-k8s labels: - app: etcd - etcd: k8s + k8s-app: etcd subsets: - addresses: - ip: 172.17.4.51 diff --git a/manifests/k8s/minikube/kube-apiserver.yaml b/manifests/k8s/minikube/kube-apiserver.yaml new file mode 100644 index 0000000000000000000000000000000000000000..2b35a4ec6c73b362d6240d115f392926f79c65bd --- /dev/null +++ b/manifests/k8s/minikube/kube-apiserver.yaml @@ -0,0 +1,27 @@ +apiVersion: v1 +kind: Service +metadata: + name: kube-apiserver-prometheus-discovery + labels: + k8s-app: kubernetes +spec: + type: ClusterIP + clusterIP: None + ports: + - name: https-metrics + port: 8443 + protocol: TCP +--- +apiVersion: v1 +kind: Endpoints +metadata: + name: kube-apiserver-prometheus-discovery + labels: + k8s-app: kubernetes +subsets: +- addresses: + - ip: 192.168.99.100 + ports: + - name: https-metrics + port: 8443 + protocol: TCP diff --git a/manifests/k8s/minikube/kube-controller-manager.yaml b/manifests/k8s/minikube/kube-controller-manager.yaml new file mode 100644 index 0000000000000000000000000000000000000000..bca65e405bce2e11b1b782df3adc9de685761489 --- /dev/null +++ b/manifests/k8s/minikube/kube-controller-manager.yaml @@ -0,0 +1,28 @@ +apiVersion: v1 +kind: Service +metadata: + name: kube-controller-manager-prometheus-discovery + labels: + k8s-app: kube-controller-manager +spec: + type: ClusterIP + clusterIP: None + ports: + - name: http-metrics + port: 10252 + targetPort: 10252 + protocol: TCP +--- +apiVersion: v1 +kind: Endpoints +metadata: + name: kube-controller-manager-prometheus-discovery + labels: + k8s-app: kube-controller-manager +subsets: +- addresses: + - ip: 192.168.99.100 + ports: + - name: http-metrics + port: 10252 + protocol: TCP diff --git a/manifests/k8s/minikube/kube-scheduler.yaml b/manifests/k8s/minikube/kube-scheduler.yaml new file mode 100644 index 0000000000000000000000000000000000000000..983e5581369e1dd79be086df632f72940e6f0fa7 --- /dev/null +++ b/manifests/k8s/minikube/kube-scheduler.yaml @@ -0,0 +1,28 @@ +apiVersion: v1 +kind: Service +metadata: + name: kube-scheduler-prometheus-discovery + labels: + k8s-app: kube-scheduler +spec: + type: ClusterIP + clusterIP: None + ports: + - name: http-metrics + port: 10251 + targetPort: 10251 + protocol: TCP +--- +apiVersion: v1 +kind: Endpoints +metadata: + name: kube-scheduler-prometheus-discovery + labels: + k8s-app: kube-scheduler +subsets: +- addresses: + - ip: 192.168.99.100 + ports: + - name: http-metrics + port: 10251 + protocol: TCP diff --git a/manifests/k8s/self-hosted/kube-apiserver.yaml b/manifests/k8s/self-hosted/kube-apiserver.yaml new file mode 100644 index 0000000000000000000000000000000000000000..72b1c08fc3f475082a8149eb0c50c40a620636c7 --- /dev/null +++ b/manifests/k8s/self-hosted/kube-apiserver.yaml @@ -0,0 +1,16 @@ +apiVersion: v1 +kind: Service +metadata: + name: kube-apiserver-prometheus-discovery + labels: + k8s-app: kubernetes +spec: + selector: + k8s-app: kube-apiserver + type: ClusterIP + clusterIP: None + ports: + - name: https-metrics + port: 443 + targetPort: 443 + protocol: TCP diff --git a/manifests/k8s/kube-controller-manager-bootkube-vagrant-multi.yaml b/manifests/k8s/self-hosted/kube-controller-manager.yaml similarity index 92% rename from manifests/k8s/kube-controller-manager-bootkube-vagrant-multi.yaml rename to manifests/k8s/self-hosted/kube-controller-manager.yaml index 2e6b4db956d030d0fe7459af1bbdb66f160ff2ad..2f22a6f2d7834b07a2e30a0d477824626ae116ee 100644 --- a/manifests/k8s/kube-controller-manager-bootkube-vagrant-multi.yaml +++ b/manifests/k8s/self-hosted/kube-controller-manager.yaml @@ -10,7 +10,7 @@ spec: type: ClusterIP clusterIP: None ports: - - name: prometheus + - name: http-metrics port: 10252 targetPort: 10252 protocol: TCP diff --git a/manifests/k8s/kube-dns-bootkube-vagrant-multi.yaml b/manifests/k8s/self-hosted/kube-dns.yaml similarity index 83% rename from manifests/k8s/kube-dns-bootkube-vagrant-multi.yaml rename to manifests/k8s/self-hosted/kube-dns.yaml index 4ae570f8b689f339a8287468cb5cd014dd1e7bd4..36d9a0ad988a7d2ae9f9ba79cda9d484569112a0 100644 --- a/manifests/k8s/kube-dns-bootkube-vagrant-multi.yaml +++ b/manifests/k8s/self-hosted/kube-dns.yaml @@ -10,11 +10,11 @@ spec: type: ClusterIP clusterIP: None ports: - - name: prometheus-skydns + - name: http-metrics-skydns port: 10055 targetPort: 10055 protocol: TCP - - name: prometheus-dnsmasq + - name: http-metrics-dnsmasq port: 10054 targetPort: 10054 protocol: TCP diff --git a/manifests/k8s/kube-scheduler-bootkube-vagrant-multi.yaml b/manifests/k8s/self-hosted/kube-scheduler.yaml similarity index 92% rename from manifests/k8s/kube-scheduler-bootkube-vagrant-multi.yaml rename to manifests/k8s/self-hosted/kube-scheduler.yaml index b79853d22f5233b028777e42fa9b808c47fc4939..331998feba4558a00bda3ec3e08ed2c3e2b58509 100644 --- a/manifests/k8s/kube-scheduler-bootkube-vagrant-multi.yaml +++ b/manifests/k8s/self-hosted/kube-scheduler.yaml @@ -10,7 +10,7 @@ spec: type: ClusterIP clusterIP: None ports: - - name: prometheus + - name: http-metrics port: 10251 targetPort: 10251 protocol: TCP diff --git a/manifests/prometheus-operator.yaml b/manifests/prometheus-operator.yaml index f550d2415b23ff59b02a9cfcfd6056fec66e68da..bb1dab9ae2b5d4a519da3e468e1e9a51dd040b58 100644 --- a/manifests/prometheus-operator.yaml +++ b/manifests/prometheus-operator.yaml @@ -13,7 +13,7 @@ spec: spec: containers: - name: prometheus-operator - image: quay.io/coreos/prometheus-operator:v0.1.0 + image: quay.io/coreos/prometheus-operator:v0.2.1 resources: requests: cpu: 100m diff --git a/manifests/prometheus/prometheus-k8s-cm.yaml b/manifests/prometheus/prometheus-k8s-cm.yaml index f6d61cdd0b7c9159aeef39caa89a333dc194390f..5e4a9cd3f9de9d148fbc452f306e765e6ac72cb8 100644 --- a/manifests/prometheus/prometheus-k8s-cm.yaml +++ b/manifests/prometheus/prometheus-k8s-cm.yaml @@ -56,15 +56,10 @@ data: relabel_configs: - action: keep source_labels: [__meta_kubernetes_service_name] - regex: prometheus|kubernetes|node-exporter|kube-state-metrics|etcd-k8s + regex: prometheus|node-exporter|kube-state-metrics - action: replace source_labels: [__meta_kubernetes_service_name] target_label: job - - action: replace - source_labels: [__meta_kubernetes_service_name] - regex: kubernetes - target_label: __scheme__ - replacement: https # Scrapes the endpoint lists for the kube-dns server. Which we consider # part of a default setup. @@ -78,16 +73,19 @@ data: relabel_configs: - action: replace - source_labels: [__meta_kubernetes_service_name] + source_labels: [__meta_kubernetes_service_label_k8s_app] target_label: job - regex: "kube-(.*)-prometheus-discovery" - replacement: "kube-${1}" - action: keep source_labels: [__meta_kubernetes_service_name] - regex: "kube-(.*)-prometheus-discovery" + regex: ".*-prometheus-discovery" - action: keep source_labels: [__meta_kubernetes_endpoint_port_name] - regex: "prometheus.*" + regex: "http-metrics.*|https-metrics.*" + - action: replace + source_labels: [__meta_kubernetes_endpoint_port_name] + regex: "https-metrics.*" + target_label: __scheme__ + replacement: https kind: ConfigMap metadata: creationTimestamp: null