mirror of https://github.com/k3s-io/k3s
Add flags for prometheus-to-sd components.
Configure prometheus-to-sd-endpoint and prometheus-to-sd-prefix base on the environment.pull/6/head
parent
07dea6b447
commit
d48e2d338d
|
@ -63,12 +63,14 @@ spec:
|
||||||
- name: usr-ca-certs
|
- name: usr-ca-certs
|
||||||
mountPath: /usr/share/ca-certificates
|
mountPath: /usr/share/ca-certificates
|
||||||
readOnly: true
|
readOnly: true
|
||||||
|
# BEGIN_PROMETHEUS_TO_SD
|
||||||
- name: prom-to-sd
|
- name: prom-to-sd
|
||||||
image: gcr.io/google-containers/prometheus-to-sd:v0.2.1
|
image: gcr.io/google-containers/prometheus-to-sd:v0.2.1
|
||||||
command:
|
command:
|
||||||
- /monitor
|
- /monitor
|
||||||
- --source=heapster:http://localhost:8082?whitelisted=stackdriver_requests_count,stackdriver_timeseries_count
|
- --source=heapster:http://localhost:8082?whitelisted=stackdriver_requests_count,stackdriver_timeseries_count
|
||||||
- --stackdriver-prefix=container.googleapis.com/internal/addons
|
- --stackdriver-prefix={{ prometheus_to_sd_prefix }}/addons
|
||||||
|
- --api-override={{ prometheus_to_sd_endpoint }}
|
||||||
- --pod-id=$(POD_NAME)
|
- --pod-id=$(POD_NAME)
|
||||||
- --namespace-id=$(POD_NAMESPACE)
|
- --namespace-id=$(POD_NAMESPACE)
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
|
@ -83,6 +85,7 @@ spec:
|
||||||
valueFrom:
|
valueFrom:
|
||||||
fieldRef:
|
fieldRef:
|
||||||
fieldPath: metadata.namespace
|
fieldPath: metadata.namespace
|
||||||
|
# END_PROMETHEUS_TO_SD
|
||||||
- image: gcr.io/google_containers/addon-resizer:2.0
|
- image: gcr.io/google_containers/addon-resizer:2.0
|
||||||
name: heapster-nanny
|
name: heapster-nanny
|
||||||
resources:
|
resources:
|
||||||
|
|
|
@ -51,16 +51,19 @@ spec:
|
||||||
image: gcr.io/google-containers/event-exporter:v0.1.5
|
image: gcr.io/google-containers/event-exporter:v0.1.5
|
||||||
command:
|
command:
|
||||||
- '/event-exporter'
|
- '/event-exporter'
|
||||||
|
# BEGIN_PROMETHEUS_TO_SD
|
||||||
- name: prometheus-to-sd-exporter
|
- name: prometheus-to-sd-exporter
|
||||||
image: gcr.io/google-containers/prometheus-to-sd:v0.2.1
|
image: gcr.io/google-containers/prometheus-to-sd:v0.2.1
|
||||||
command:
|
command:
|
||||||
- /monitor
|
- /monitor
|
||||||
- --component=event_exporter
|
- --component=event_exporter
|
||||||
- --stackdriver-prefix=container.googleapis.com/internal/addons
|
- --stackdriver-prefix={{ prometheus_to_sd_prefix }}/addons
|
||||||
|
- --api-override={{ prometheus_to_sd_endpoint }}
|
||||||
- --whitelisted-metrics=stackdriver_sink_received_entry_count,stackdriver_sink_request_count,stackdriver_sink_successfully_sent_entry_count
|
- --whitelisted-metrics=stackdriver_sink_received_entry_count,stackdriver_sink_request_count,stackdriver_sink_successfully_sent_entry_count
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: ssl-certs
|
- name: ssl-certs
|
||||||
mountPath: /etc/ssl/certs
|
mountPath: /etc/ssl/certs
|
||||||
|
# END_PROMETHEUS_TO_SD
|
||||||
terminationGracePeriodSeconds: 30
|
terminationGracePeriodSeconds: 30
|
||||||
volumes:
|
volumes:
|
||||||
- name: ssl-certs
|
- name: ssl-certs
|
||||||
|
|
|
@ -80,17 +80,20 @@ spec:
|
||||||
then
|
then
|
||||||
exit 1;
|
exit 1;
|
||||||
fi;
|
fi;
|
||||||
|
# BEGIN_PROMETHEUS_TO_SD
|
||||||
- name: prometheus-to-sd-exporter
|
- name: prometheus-to-sd-exporter
|
||||||
image: gcr.io/google-containers/prometheus-to-sd:v0.1.3
|
image: gcr.io/google-containers/prometheus-to-sd:v0.1.3
|
||||||
command:
|
command:
|
||||||
- /monitor
|
- /monitor
|
||||||
- --component=fluentd
|
- --component=fluentd
|
||||||
- --target-port=31337
|
- --target-port=31337
|
||||||
- --stackdriver-prefix=container.googleapis.com/internal/addons
|
- --stackdriver-prefix={{ prometheus_to_sd_prefix }}/addons
|
||||||
|
- --api-override={{ prometheus_to_sd_endpoint }}
|
||||||
- --whitelisted-metrics=stackdriver_successful_requests_count,stackdriver_failed_requests_count,stackdriver_ingested_entries_count,stackdriver_dropped_entries_count
|
- --whitelisted-metrics=stackdriver_successful_requests_count,stackdriver_failed_requests_count,stackdriver_ingested_entries_count,stackdriver_dropped_entries_count
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: ssl-certs
|
- name: ssl-certs
|
||||||
mountPath: /etc/ssl/certs
|
mountPath: /etc/ssl/certs
|
||||||
|
# END_PROMETHEUS_TO_SD
|
||||||
nodeSelector:
|
nodeSelector:
|
||||||
beta.kubernetes.io/fluentd-ds-ready: "true"
|
beta.kubernetes.io/fluentd-ds-ready: "true"
|
||||||
tolerations:
|
tolerations:
|
||||||
|
|
|
@ -668,6 +668,9 @@ ENABLE_CACHE_MUTATION_DETECTOR: $(yaml-quote ${ENABLE_CACHE_MUTATION_DETECTOR:-f
|
||||||
ENABLE_PATCH_CONVERSION_DETECTOR: $(yaml-quote ${ENABLE_PATCH_CONVERSION_DETECTOR:-false})
|
ENABLE_PATCH_CONVERSION_DETECTOR: $(yaml-quote ${ENABLE_PATCH_CONVERSION_DETECTOR:-false})
|
||||||
ADVANCED_AUDIT_BACKEND: $(yaml-quote ${ADVANCED_AUDIT_BACKEND:-log})
|
ADVANCED_AUDIT_BACKEND: $(yaml-quote ${ADVANCED_AUDIT_BACKEND:-log})
|
||||||
GCE_API_ENDPOINT: $(yaml-quote ${GCE_API_ENDPOINT:-})
|
GCE_API_ENDPOINT: $(yaml-quote ${GCE_API_ENDPOINT:-})
|
||||||
|
PROMETHEUS_TO_SD_ENDPOINT: $(yaml-quote ${PROMETHEUS_TO_SD_ENDPOINT:-})
|
||||||
|
PROMETHEUS_TO_SD_PREFIX: $(yaml-quote ${PROMETHEUS_TO_SD_PREFIX:-})
|
||||||
|
ENABLE_PROMETHEUS_TO_SD: $(yaml-quote ${ENABLE_PROMETHEUS_TO_SD:-false})
|
||||||
EOF
|
EOF
|
||||||
if [ -n "${KUBELET_PORT:-}" ]; then
|
if [ -n "${KUBELET_PORT:-}" ]; then
|
||||||
cat >>$file <<EOF
|
cat >>$file <<EOF
|
||||||
|
|
|
@ -292,3 +292,8 @@ FLUENTD_GCP_CPU_REQUEST="${FLUENTD_GCP_CPU_REQUEST:-100m}"
|
||||||
FLUENTD_GCP_MEMORY_REQUEST="${FLUENTD_GCP_MEMORY_REQUEST:-200Mi}"
|
FLUENTD_GCP_MEMORY_REQUEST="${FLUENTD_GCP_MEMORY_REQUEST:-200Mi}"
|
||||||
# Adding to PROVIDER_VARS, since this is GCP-specific.
|
# Adding to PROVIDER_VARS, since this is GCP-specific.
|
||||||
PROVIDER_VARS="${PROVIDER_VARS:-} FLUENTD_GCP_MEMORY_LIMIT FLUENTD_GCP_CPU_REQUEST FLUENTD_GCP_MEMORY_REQUEST"
|
PROVIDER_VARS="${PROVIDER_VARS:-} FLUENTD_GCP_MEMORY_LIMIT FLUENTD_GCP_CPU_REQUEST FLUENTD_GCP_MEMORY_REQUEST"
|
||||||
|
|
||||||
|
# prometheus-to-sd configuration
|
||||||
|
PROMETHEUS_TO_SD_ENDPOINT="${PROMETHEUS_TO_SD_ENDPOINT:-https://monitoring.googleapis.com/}"
|
||||||
|
PROMETHEUS_TO_SD_PREFIX="${PROMETHEUS_TO_SD_PREFIX:-custom.googleapis.com}"
|
||||||
|
ENABLE_PROMETHEUS_TO_SD="${ENABLE_PROMETHEUS_TO_SD:-false}"
|
||||||
|
|
|
@ -351,3 +351,8 @@ FLUENTD_GCP_CPU_REQUEST="${FLUENTD_GCP_CPU_REQUEST:-100m}"
|
||||||
FLUENTD_GCP_MEMORY_REQUEST="${FLUENTD_GCP_MEMORY_REQUEST:-200Mi}"
|
FLUENTD_GCP_MEMORY_REQUEST="${FLUENTD_GCP_MEMORY_REQUEST:-200Mi}"
|
||||||
# Adding to PROVIDER_VARS, since this is GCP-specific.
|
# Adding to PROVIDER_VARS, since this is GCP-specific.
|
||||||
PROVIDER_VARS="${PROVIDER_VARS:-} FLUENTD_GCP_MEMORY_LIMIT FLUENTD_GCP_CPU_REQUEST FLUENTD_GCP_MEMORY_REQUEST"
|
PROVIDER_VARS="${PROVIDER_VARS:-} FLUENTD_GCP_MEMORY_LIMIT FLUENTD_GCP_CPU_REQUEST FLUENTD_GCP_MEMORY_REQUEST"
|
||||||
|
|
||||||
|
# prometheus-to-sd configuration
|
||||||
|
PROMETHEUS_TO_SD_ENDPOINT="${PROMETHEUS_TO_SD_ENDPOINT:-https://monitoring.googleapis.com/}"
|
||||||
|
PROMETHEUS_TO_SD_PREFIX="${PROMETHEUS_TO_SD_PREFIX:-custom.googleapis.com}"
|
||||||
|
ENABLE_PROMETHEUS_TO_SD="${ENABLE_PROMETHEUS_TO_SD:-true}"
|
||||||
|
|
|
@ -1193,6 +1193,18 @@ function setup-addon-manifests {
|
||||||
chmod 644 "${dst_dir}"/*
|
chmod 644 "${dst_dir}"/*
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Updates parameters in yaml file for prometheus-to-sd configuration, or
|
||||||
|
# removes component if it is disabled.
|
||||||
|
function update-prometheus-to-sd-parameters {
|
||||||
|
if [[ "${ENABLE_PROMETHEUS_TO_SD:-}" == "true" ]]; then
|
||||||
|
sed -i -e "s@{{ *prometheus_to_sd_prefix *}}@${PROMETHEUS_TO_SD_PREFIX}@g" "$1"
|
||||||
|
sed -i -e "s@{{ *prometheus_to_sd_endpoint *}}@${PROMETHEUS_TO_SD_ENDPOINT}@g" "$1"
|
||||||
|
else
|
||||||
|
# Removes all lines between two patterns (throws away prometheus-to-sd)
|
||||||
|
sed -i -e "/# BEGIN_PROMETHEUS_TO_SD/,/# END_PROMETHEUS_TO_SD/d" "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Prepares the manifests of k8s addons, and starts the addon manager.
|
# Prepares the manifests of k8s addons, and starts the addon manager.
|
||||||
# Vars assumed:
|
# Vars assumed:
|
||||||
# CLUSTER_NAME
|
# CLUSTER_NAME
|
||||||
|
@ -1241,6 +1253,7 @@ function start-kube-addons {
|
||||||
sed -i -e "s@{{ *eventer_memory_per_node *}}@${eventer_memory_per_node}@g" "${controller_yaml}"
|
sed -i -e "s@{{ *eventer_memory_per_node *}}@${eventer_memory_per_node}@g" "${controller_yaml}"
|
||||||
sed -i -e "s@{{ *nanny_memory *}}@${nanny_memory}@g" "${controller_yaml}"
|
sed -i -e "s@{{ *nanny_memory *}}@${nanny_memory}@g" "${controller_yaml}"
|
||||||
sed -i -e "s@{{ *metrics_cpu_per_node *}}@${metrics_cpu_per_node}@g" "${controller_yaml}"
|
sed -i -e "s@{{ *metrics_cpu_per_node *}}@${metrics_cpu_per_node}@g" "${controller_yaml}"
|
||||||
|
update-prometheus-to-sd-parameters ${controller_yaml}
|
||||||
fi
|
fi
|
||||||
if [[ "${ENABLE_CLUSTER_DNS:-}" == "true" ]]; then
|
if [[ "${ENABLE_CLUSTER_DNS:-}" == "true" ]]; then
|
||||||
setup-addon-manifests "addons" "dns"
|
setup-addon-manifests "addons" "dns"
|
||||||
|
@ -1276,6 +1289,10 @@ function start-kube-addons {
|
||||||
if [[ "${ENABLE_NODE_LOGGING:-}" == "true" ]] && \
|
if [[ "${ENABLE_NODE_LOGGING:-}" == "true" ]] && \
|
||||||
[[ "${LOGGING_DESTINATION:-}" == "gcp" ]]; then
|
[[ "${LOGGING_DESTINATION:-}" == "gcp" ]]; then
|
||||||
setup-addon-manifests "addons" "fluentd-gcp"
|
setup-addon-manifests "addons" "fluentd-gcp"
|
||||||
|
local -r event_exporter_yaml="${dst_dir}/fluentd-gcp/event-exporter.yaml"
|
||||||
|
local -r fluentd_gcp_yaml="${dst_dir}/fluentd-gcp/fluentd-gcp-ds.yaml"
|
||||||
|
update-prometheus-to-sd-parameters ${event_exporter_yaml}
|
||||||
|
update-prometheus-to-sd-parameters ${fluentd_gcp_yaml}
|
||||||
fi
|
fi
|
||||||
if [[ "${ENABLE_CLUSTER_UI:-}" == "true" ]]; then
|
if [[ "${ENABLE_CLUSTER_UI:-}" == "true" ]]; then
|
||||||
setup-addon-manifests "addons" "dashboard"
|
setup-addon-manifests "addons" "dashboard"
|
||||||
|
|
|
@ -1617,6 +1617,18 @@ function start-fluentd-resource-update {
|
||||||
wait-for-apiserver-and-update-fluentd &
|
wait-for-apiserver-and-update-fluentd &
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Updates parameters in yaml file for prometheus-to-sd configuration, or
|
||||||
|
# removes component if it is disabled.
|
||||||
|
function update-prometheus-to-sd-parameters {
|
||||||
|
if [[ "${ENABLE_PROMETHEUS_TO_SD:-}" == "true" ]]; then
|
||||||
|
sed -i -e "s@{{ *prometheus_to_sd_prefix *}}@${PROMETHEUS_TO_SD_PREFIX}@g" "$1"
|
||||||
|
sed -i -e "s@{{ *prometheus_to_sd_endpoint *}}@${PROMETHEUS_TO_SD_ENDPOINT}@g" "$1"
|
||||||
|
else
|
||||||
|
# Removes all lines between two patterns (throws away prometheus-to-sd)
|
||||||
|
sed -i -e "/# BEGIN_PROMETHEUS_TO_SD/,/# END_PROMETHEUS_TO_SD/d" "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Prepares the manifests of k8s addons, and starts the addon manager.
|
# Prepares the manifests of k8s addons, and starts the addon manager.
|
||||||
# Vars assumed:
|
# Vars assumed:
|
||||||
# CLUSTER_NAME
|
# CLUSTER_NAME
|
||||||
|
@ -1665,6 +1677,7 @@ function start-kube-addons {
|
||||||
sed -i -e "s@{{ *eventer_memory_per_node *}}@${eventer_memory_per_node}@g" "${controller_yaml}"
|
sed -i -e "s@{{ *eventer_memory_per_node *}}@${eventer_memory_per_node}@g" "${controller_yaml}"
|
||||||
sed -i -e "s@{{ *nanny_memory *}}@${nanny_memory}@g" "${controller_yaml}"
|
sed -i -e "s@{{ *nanny_memory *}}@${nanny_memory}@g" "${controller_yaml}"
|
||||||
sed -i -e "s@{{ *metrics_cpu_per_node *}}@${metrics_cpu_per_node}@g" "${controller_yaml}"
|
sed -i -e "s@{{ *metrics_cpu_per_node *}}@${metrics_cpu_per_node}@g" "${controller_yaml}"
|
||||||
|
update-prometheus-to-sd-parameters ${controller_yaml}
|
||||||
fi
|
fi
|
||||||
if [[ "${ENABLE_CLUSTER_DNS:-}" == "true" ]]; then
|
if [[ "${ENABLE_CLUSTER_DNS:-}" == "true" ]]; then
|
||||||
setup-addon-manifests "addons" "dns"
|
setup-addon-manifests "addons" "dns"
|
||||||
|
@ -1700,7 +1713,10 @@ function start-kube-addons {
|
||||||
if [[ "${ENABLE_NODE_LOGGING:-}" == "true" ]] && \
|
if [[ "${ENABLE_NODE_LOGGING:-}" == "true" ]] && \
|
||||||
[[ "${LOGGING_DESTINATION:-}" == "gcp" ]]; then
|
[[ "${LOGGING_DESTINATION:-}" == "gcp" ]]; then
|
||||||
setup-addon-manifests "addons" "fluentd-gcp"
|
setup-addon-manifests "addons" "fluentd-gcp"
|
||||||
|
local -r event_exporter_yaml="${dst_dir}/fluentd-gcp/event-exporter.yaml"
|
||||||
local -r fluentd_gcp_yaml="${dst_dir}/fluentd-gcp/fluentd-gcp-ds.yaml"
|
local -r fluentd_gcp_yaml="${dst_dir}/fluentd-gcp/fluentd-gcp-ds.yaml"
|
||||||
|
update-prometheus-to-sd-parameters ${event_exporter_yaml}
|
||||||
|
update-prometheus-to-sd-parameters ${fluentd_gcp_yaml}
|
||||||
start-fluentd-resource-update
|
start-fluentd-resource-update
|
||||||
fi
|
fi
|
||||||
if [[ "${ENABLE_CLUSTER_UI:-}" == "true" ]]; then
|
if [[ "${ENABLE_CLUSTER_UI:-}" == "true" ]]; then
|
||||||
|
|
Loading…
Reference in New Issue