mirror of https://github.com/linkerd/linkerd2.git
viz: make checks aware of prom and grafana being optional (#5627)
* viz: make checks aware of prom and grafana being optional Fixes #5618 Currently, The linkerd-viz checks fail whenever external Prometheus is being used as those checks are not aware of Prometheus and grafana being optional. This commit fixes this by making the Prometheus and Grafana as separate checks which are not fatal and these checks can also be made dynamic and be ran only if those components are available. This commit also adds some of the missing resources checks, especially that of the new `metrics-api` into viz checks Signed-off-by: Tarun Pothulapati <tarunpothulapati@outlook.com>
This commit is contained in:
parent
c6536996f7
commit
704ed00a49
|
@ -2538,7 +2538,8 @@ func CheckForPods(pods []corev1.Pod, deployNames []string) error {
|
||||||
|
|
||||||
for _, pod := range pods {
|
for _, pod := range pods {
|
||||||
// Strip randomized suffix and take the deployment name
|
// Strip randomized suffix and take the deployment name
|
||||||
deployName := strings.Join(strings.Split(pod.Name, "-")[:2], "-")
|
parts := strings.Split(pod.Name, "-")
|
||||||
|
deployName := strings.Join(parts[:len(parts)-2], "-")
|
||||||
exists[deployName] = true
|
exists[deployName] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,12 +18,13 @@ linkerd-viz
|
||||||
√ linkerd-viz Namespace exists
|
√ linkerd-viz Namespace exists
|
||||||
√ linkerd-viz ClusterRoles exist
|
√ linkerd-viz ClusterRoles exist
|
||||||
√ linkerd-viz ClusterRoleBindings exist
|
√ linkerd-viz ClusterRoleBindings exist
|
||||||
√ linkerd-viz ConfigMaps exist
|
|
||||||
√ tap API server has valid cert
|
√ tap API server has valid cert
|
||||||
√ tap API server cert is valid for at least 60 days
|
√ tap API server cert is valid for at least 60 days
|
||||||
√ tap API service is running
|
√ tap API service is running
|
||||||
√ linkerd-viz pods are injected
|
√ linkerd-viz pods are injected
|
||||||
√ viz extension pods are running
|
√ viz extension pods are running
|
||||||
|
√ prometheus is installed and configured correctly
|
||||||
|
√ grafana is installed and configured correctly
|
||||||
√ can initialize the client
|
√ can initialize the client
|
||||||
√ viz extension self-check
|
√ viz extension self-check
|
||||||
√ [kubernetes] linkerd viz can talk to Kubernetes
|
√ [kubernetes] linkerd viz can talk to Kubernetes
|
||||||
|
|
|
@ -72,8 +72,10 @@ spec:
|
||||||
- -cluster-domain={{.Values.clusterDomain}}
|
- -cluster-domain={{.Values.clusterDomain}}
|
||||||
{{- if .Values.prometheusUrl }}
|
{{- if .Values.prometheusUrl }}
|
||||||
- -prometheus-url={{.Values.prometheusUrl}}
|
- -prometheus-url={{.Values.prometheusUrl}}
|
||||||
|
{{- else if .Values.prometheus.enabled }}
|
||||||
|
- -prometheus-url=http://linkerd-prometheus.{{.Values.namespace}}.svc.{{.Values.clusterDomain}}:9090
|
||||||
{{- else }}
|
{{- else }}
|
||||||
- -prometheus-url=http://linkerd-prometheus.linkerd-viz.svc.{{.Values.clusterDomain}}:9090
|
{{ fail "Please enable `linkerd-prometheus` or provide `prometheusUrl` for the viz extension to function properly"}}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
image: {{.Values.metricsAPI.image.registry}}/{{.Values.metricsAPI.image.name}}:{{.Values.metricsAPI.image.tag}}
|
image: {{.Values.metricsAPI.image.registry}}/{{.Values.metricsAPI.image.name}}:{{.Values.metricsAPI.image.tag}}
|
||||||
imagePullPolicy: {{.Values.metricsAPI.pullPolicy}}
|
imagePullPolicy: {{.Values.metricsAPI.pullPolicy}}
|
||||||
|
|
|
@ -82,21 +82,14 @@ func (hc *HealthChecker) VizCategory() healthcheck.Category {
|
||||||
Fatal().
|
Fatal().
|
||||||
Warning().
|
Warning().
|
||||||
WithCheck(func(ctx context.Context) error {
|
WithCheck(func(ctx context.Context) error {
|
||||||
return healthcheck.CheckClusterRoles(ctx, hc.KubeAPIClient(), true, []string{fmt.Sprintf("linkerd-%s-prometheus", hc.vizNamespace), fmt.Sprintf("linkerd-%s-tap", hc.vizNamespace)}, "")
|
return healthcheck.CheckClusterRoles(ctx, hc.KubeAPIClient(), true, []string{fmt.Sprintf("linkerd-%s-tap", hc.vizNamespace), fmt.Sprintf("linkerd-%s-metrics-api", hc.vizNamespace), fmt.Sprintf("linkerd-%s-tap-admin", hc.vizNamespace), "linkerd-tap-injector"}, "")
|
||||||
}),
|
}),
|
||||||
*healthcheck.NewChecker("linkerd-viz ClusterRoleBindings exist").
|
*healthcheck.NewChecker("linkerd-viz ClusterRoleBindings exist").
|
||||||
WithHintAnchor("l5d-viz-crb-exists").
|
WithHintAnchor("l5d-viz-crb-exists").
|
||||||
Fatal().
|
Fatal().
|
||||||
Warning().
|
Warning().
|
||||||
WithCheck(func(ctx context.Context) error {
|
WithCheck(func(ctx context.Context) error {
|
||||||
return healthcheck.CheckClusterRoleBindings(ctx, hc.KubeAPIClient(), true, []string{fmt.Sprintf("linkerd-%s-prometheus", hc.vizNamespace), fmt.Sprintf("linkerd-%s-tap", hc.vizNamespace)}, "")
|
return healthcheck.CheckClusterRoleBindings(ctx, hc.KubeAPIClient(), true, []string{fmt.Sprintf("linkerd-%s-tap", hc.vizNamespace), fmt.Sprintf("linkerd-%s-metrics-api", hc.vizNamespace), fmt.Sprintf("linkerd-%s-tap-auth-delegator", hc.vizNamespace), "linkerd-tap-injector"}, "")
|
||||||
}),
|
|
||||||
*healthcheck.NewChecker("linkerd-viz ConfigMaps exist").
|
|
||||||
WithHintAnchor("l5d-viz-cm-exists").
|
|
||||||
Fatal().
|
|
||||||
Warning().
|
|
||||||
WithCheck(func(ctx context.Context) error {
|
|
||||||
return healthcheck.CheckConfigMaps(ctx, hc.KubeAPIClient(), hc.vizNamespace, true, []string{"linkerd-prometheus-config", "linkerd-grafana-config"}, "")
|
|
||||||
}),
|
}),
|
||||||
*healthcheck.NewChecker("tap API server has valid cert").
|
*healthcheck.NewChecker("tap API server has valid cert").
|
||||||
WithHintAnchor("l5d-tap-cert-valid").
|
WithHintAnchor("l5d-tap-cert-valid").
|
||||||
|
@ -159,13 +152,73 @@ func (hc *HealthChecker) VizCategory() healthcheck.Category {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for relevant pods to be present
|
// Check for relevant pods to be present
|
||||||
err = healthcheck.CheckForPods(pods, []string{"linkerd-grafana", "linkerd-prometheus", "linkerd-web", "linkerd-tap"})
|
err = healthcheck.CheckForPods(pods, []string{"linkerd-web", "linkerd-tap", "linkerd-metrics-api", "tap-injector"})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return healthcheck.CheckPodsRunning(pods, "")
|
return healthcheck.CheckPodsRunning(pods, "")
|
||||||
}),
|
}),
|
||||||
|
*healthcheck.NewChecker("prometheus is installed and configured correctly").
|
||||||
|
WithHintAnchor("l5d-viz-prometheus").
|
||||||
|
Warning().
|
||||||
|
WithCheck(func(ctx context.Context) error {
|
||||||
|
// TODO: Skip if prometheus is disabled
|
||||||
|
// Check for ClusterRoles
|
||||||
|
err := healthcheck.CheckClusterRoles(ctx, hc.KubeAPIClient(), true, []string{fmt.Sprintf("linkerd-%s-prometheus", hc.vizNamespace)}, "")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for ClusterRoleBindings
|
||||||
|
err = healthcheck.CheckClusterRoleBindings(ctx, hc.KubeAPIClient(), true, []string{fmt.Sprintf("linkerd-%s-prometheus", hc.vizNamespace)}, "")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for ConfigMap
|
||||||
|
err = healthcheck.CheckConfigMaps(ctx, hc.KubeAPIClient(), hc.vizNamespace, true, []string{"linkerd-prometheus-config"}, "")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for relevant pods to be present
|
||||||
|
pods, err := hc.KubeAPIClient().GetPodsByNamespace(ctx, hc.vizNamespace)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = healthcheck.CheckForPods(pods, []string{"linkerd-prometheus"})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}),
|
||||||
|
*healthcheck.NewChecker("grafana is installed and configured correctly").
|
||||||
|
WithHintAnchor("l5d-viz-grafana").
|
||||||
|
Warning().
|
||||||
|
WithCheck(func(ctx context.Context) error {
|
||||||
|
// TODO: Skip if grafana is disabled
|
||||||
|
// Check for ConfigMap
|
||||||
|
err := healthcheck.CheckConfigMaps(ctx, hc.KubeAPIClient(), hc.vizNamespace, true, []string{"linkerd-grafana-config"}, "")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for relevant pods to be present
|
||||||
|
pods, err := hc.KubeAPIClient().GetPodsByNamespace(ctx, hc.vizNamespace)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = healthcheck.CheckForPods(pods, []string{"linkerd-grafana"})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}),
|
||||||
*healthcheck.NewChecker("can initialize the client").
|
*healthcheck.NewChecker("can initialize the client").
|
||||||
WithHintAnchor("l5d-viz-existence-client").
|
WithHintAnchor("l5d-viz-existence-client").
|
||||||
Fatal().
|
Fatal().
|
||||||
|
|
Loading…
Reference in New Issue