Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include SMI metrics as part of Linkerd install #4109

Merged
merged 9 commits into from
Mar 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 168 additions & 0 deletions charts/linkerd2/smi-metrics-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
mesh: linkerd
linkerd:
prometheusUrl: http://linkerd-prometheus.linkerd.svc.cluster.local:9090
resourceQueries:
p99_response_latency : |-
histogram_quantile(
0.99,
sum(
irate(
response_latency_ms_bucket{
namespace=~"{{default ".+" .namespace }}",
{{lower .kind}}=~"{{default ".+" .name }}"
}[{{.window}}]
)
) by (
{{lower .kind}},
namespace,
le
)
)
p90_response_latency : |-
histogram_quantile(
0.90,
sum(
irate(
response_latency_ms_bucket{
namespace=~"{{default ".+" .namespace }}",
{{lower .kind}}=~"{{default ".+" .name }}"
}[{{.window}}]
)
) by (
{{lower .kind}},
namespace,
le
)
)
p50_response_latency : |-
histogram_quantile(
0.50,
sum(
irate(
response_latency_ms_bucket{
namespace=~"{{default ".+" .namespace }}",
{{lower .kind}}=~"{{default ".+" .name }}"
}[{{.window}}]
)
) by (
{{lower .kind}},
namespace,
le
)
)
success_count : |-
sum(
increase(
response_total{
classification="success",
namespace=~"{{default ".+" .namespace }}",
{{lower .kind}}=~"{{default ".+" .name }}"
}[{{.window}}]
)
) by (
{{lower .kind}},
namespace
)
failure_count : |-
sum(
increase(
response_total{
classification="failure",
namespace=~"{{default ".+" .namespace }}",
{{lower .kind}}=~"{{default ".+" .name }}"
}[{{.window}}]
)
) by (
{{lower .kind}},
namespace
)
edgeQueries:
p99_response_latency : |-
histogram_quantile(
0.99,
sum(
irate(
response_latency_ms_bucket{
namespace=~"{{.namespace}}",
{{lower .kind}}=~"{{default ".+" .fromName}}",
dst_{{lower .kind}}=~"{{default ".+" .toName}}"
}[{{.window}}]
)
) by (
{{lower .kind}},
dst_{{lower .kind}},
namespace,
dst_namespace,
le
)
)
p90_response_latency : |-
histogram_quantile(
0.90,
sum(
irate(
response_latency_ms_bucket{
namespace=~"{{.namespace}}",
{{lower .kind}}=~"{{default ".+" .fromName}}",
dst_{{lower .kind}}=~"{{default ".+" .toName}}"
}[{{.window}}]
)
) by (
{{lower .kind}},
dst_{{lower .kind}},
namespace,
dst_namespace,
le
)
)
p50_response_latency : |-
histogram_quantile(
0.50,
sum(
irate(
response_latency_ms_bucket{
namespace=~"{{.namespace}}",
{{lower .kind}}=~"{{default ".+" .fromName}}",
dst_{{lower .kind}}=~"{{default ".+" .toName}}"
}[{{.window}}]
)
) by (
{{lower .kind}},
dst_{{lower .kind}},
namespace,
dst_namespace,
le
)
)
success_count : |-
sum(
increase(
response_total{
classification="success",
namespace=~"{{.namespace}}",
{{lower .kind}}=~"{{default ".+" .fromName}}",
dst_{{lower .kind}}=~"{{default ".+" .toName}}"
}[{{.window}}]
)
) by (
{{lower .kind}},
dst_{{lower .kind}},
namespace,
dst_namespace
)
failure_count : |-
sum(
increase(
response_total{
classification="failure",
namespace=~"{{.namespace}}",
{{lower .kind}}=~"{{default ".+" .fromName}}",
dst_{{lower .kind}}=~"{{default ".+" .toName}}"
}[{{.window}}]
)
) by (
{{lower .kind}},
dst_{{lower .kind}},
namespace,
dst_namespace
)
65 changes: 65 additions & 0 deletions charts/linkerd2/templates/smi-metrics-rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
###
### SMI-Metrics RBAC
###
---
apiVersion: v1
kind: ServiceAccount
metadata:
labels:
{{.Values.global.controllerComponentLabel}}: smi-metrics
{{.Values.global.controllerNamespaceLabel}}: {{.Values.global.namespace}}
name: linkerd-smi-metrics
namespace: {{.Values.global.namespace}}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: linkerd-smi-metrics
labels:
{{.Values.global.controllerComponentLabel}}: smi-metrics
{{.Values.global.controllerNamespaceLabel}}: {{.Values.global.namespace}}
namespace: kube-system
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: extension-apiserver-authentication-reader
subjects:
- kind: ServiceAccount
name: linkerd-smi-metrics
namespace: {{.Values.global.namespace}}
---
kind: Secret
apiVersion: v1
metadata:
name: linkerd-smi-metrics-tls
namespace: {{ .Values.global.namespace }}
labels:
{{.Values.global.controllerComponentLabel}}: smi-metrics
{{.Values.global.controllerNamespaceLabel}}: {{.Values.global.namespace}}
annotations:
{{.Values.global.createdByAnnotation}}: {{default (printf "linkerd/helm %s" .Values.global.linkerdVersion) .Values.global.cliVersion}}
type: kubernetes.io/tls
data:
{{ $cn := printf "linkerd-smi-metrics.%s.svc" .Values.global.namespace -}}
{{ $cert := genCA $cn 365 -}}
tls.crt: {{ ternary (b64enc $cert.Cert) (b64enc (trim .Values.smiMetrics.crtPEM)) (empty .Values.smiMetrics.crtPEM) }}
tls.key: {{ ternary (b64enc $cert.Key) (b64enc (trim .Values.smiMetrics.keyPEM)) (empty .Values.smiMetrics.keyPEM) }}
---
apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:
name: v1alpha1.metrics.smi-spec.io
labels:
{{.Values.global.controllerComponentLabel}}: smi-metrics
{{.Values.global.controllerNamespaceLabel}}: {{.Values.global.namespace}}
spec:
group: metrics.smi-spec.io
version: v1alpha1
insecureSkipTLSVerify: false
groupPriorityMinimum: 100
versionPriority: 100
service:
name: linkerd-smi-metrics
namespace: {{.Values.global.namespace}}
caBundle: {{ ternary (b64enc $cert.Cert) (b64enc (trim .Values.smiMetrics.crtPEM)) (empty .Values.smiMetrics.crtPEM) }}
111 changes: 111 additions & 0 deletions charts/linkerd2/templates/smi-metrics.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
labels:
app.kubernetes.io/name: smi-metrics
app.kubernetes.io/part-of: Linkerd
app.kubernetes.io/version: {{default .Values.global.linkerdVersion .Values.controllerImageVersion}}
{{.Values.global.controllerComponentLabel}}: smi-metrics
{{.Values.global.controllerNamespaceLabel}}: {{.Values.global.namespace}}
name: linkerd-smi-metrics
namespace: {{.Values.global.namespace}}
data:
config.yml: |
{{- $files := .Files }}
{{- $files.Get "smi-metrics-config.yaml" | nindent 4 }}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: linkerd-smi-metrics
namespace: {{.Values.global.namespace}}
labels:
app.kubernetes.io/name: smi-metrics
app.kubernetes.io/part-of: Linkerd
app.kubernetes.io/version: {{default .Values.global.linkerdVersion .Values.controllerImageVersion}}
{{.Values.global.controllerComponentLabel}}: smi-metrics
{{.Values.global.controllerNamespaceLabel}}: {{.Values.global.namespace}}
spec:
replicas: 1
selector:
matchLabels:
{{.Values.global.controllerComponentLabel}}: smi-metrics
{{.Values.global.controllerNamespaceLabel}}: {{.Values.global.namespace}}
{{- include "partials.proxy.labels" .Values.global.proxy | nindent 6}}
template:
metadata:
annotations:
{{- if empty .Values.global.cliVersion }}
linkerd.io/helm-release-version: {{ $.Release.Revision | quote}}
{{- end }}
{{.Values.global.createdByAnnotation}}: {{default (printf "linkerd/helm %s" .Values.global.linkerdVersion) .Values.global.cliVersion}}
{{- include "partials.proxy.annotations" .Values.global.proxy| nindent 8}}
labels:
{{.Values.global.controllerComponentLabel}}: smi-metrics
{{.Values.global.controllerNamespaceLabel}}: {{.Values.global.namespace}}
{{- include "partials.proxy.labels" .Values.global.proxy | nindent 8}}
spec:
{{- include "linkerd.node-selector" . | nindent 6 }}
{{- if .Values.enablePodAntiAffinity -}}
{{- $local := dict "component" "tap" "label" .Values.global.controllerComponentLabel -}}
{{- include "linkerd.pod-affinity" $local | nindent 6 -}}
{{- end }}
serviceAccountName: linkerd-smi-metrics
containers:
- name: shim
image: {{ .Values.smiMetrics.image }}
imagePullPolicy: {{.Values.global.imagePullPolicy}}

command:
- /smi-metrics
- --config=/config.yml

ports:
- containerPort: 8080
name: api
protocol: TCP
- containerPort: 8081
name: admin
protocol: TCP

volumeMounts:
- name: config
mountPath: /config.yml
subPath: config.yml
- mountPath: /var/run/smi-metrics
name: tls
readOnly: true

- {{- include "partials.proxy" . | indent 8 | trimPrefix (repeat 7 " ") }}
{{ if not .Values.global.cniEnabled -}}
initContainers:
- {{- include "partials.proxy-init" . | indent 8 | trimPrefix (repeat 7 " ") }}
{{ end -}}

volumes:
- name: config
configMap:
name: linkerd-smi-metrics
- {{- include "partials.proxy.volumes.identity" . | indent 8 | trimPrefix (repeat 7 " ") }}
- name: tls
secret:
secretName: linkerd-smi-metrics-tls
---
apiVersion: v1
kind: Service
metadata:
name: linkerd-smi-metrics
namespace: {{.Values.global.namespace}}
labels:
{{.Values.global.controllerComponentLabel}}: smi-metrics
{{.Values.global.controllerNamespaceLabel}}: {{.Values.global.namespace}}
annotations:
{{.Values.global.createdByAnnotation}}: {{default (printf "linkerd/helm %s" .Values.global.linkerdVersion) .Values.global.cliVersion}}
spec:
ports:
- port: 443
targetPort: api
protocol: TCP
selector:
{{.Values.global.controllerComponentLabel}}: smi-metrics
6 changes: 6 additions & 0 deletions charts/linkerd2/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,12 @@ installNamespace: true
nodeSelector:
beta.kubernetes.io/os: linux

smiMetrics:
image: deislabs/smi-metrics:v0.2.0
# if empty, Helm will auto-generate these fields
crtPEM: |

keyPEM: |

# Configuration for Add-ons
tracing:
Expand Down
Loading