Skip to content
Closed
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
14 changes: 7 additions & 7 deletions charts/metrics-server/templates/apiservice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ metadata:
name: v1beta1.metrics.k8s.io
labels:
{{- include "metrics-server.labels" . | nindent 4 }}
{{- if or .Values.apiService.annotations .Values.tls.certManager.addInjectorAnnotations }}
{{- $certManagerAnnotations := dict }}
{{- if and (eq .Values.tls.type "cert-manager") .Values.tls.certManager.addInjectorAnnotations }}
{{- $certManagerAnnotations = dict "cert-manager.io/inject-ca-from" (printf "%s/%s" .Release.Namespace (include "metrics-server.fullname" .)) }}
{{- end }}
{{- $annotations := mustMergeOverwrite (dict) (.Values.commonAnnotations | default dict) (.Values.apiService.annotations | default dict) $certManagerAnnotations }}
{{- if $annotations }}
annotations:
{{- if and (eq .Values.tls.type "cert-manager") .Values.tls.certManager.addInjectorAnnotations }}
cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ include "metrics-server.fullname" . }}
{{- end }}
{{- with .Values.apiService.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- toYaml $annotations | nindent 4 }}
{{- end }}
spec:
{{- if eq .Values.tls.type "helm" }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ metadata:
rbac.authorization.k8s.io/aggregate-to-admin: "true"
rbac.authorization.k8s.io/aggregate-to-edit: "true"
rbac.authorization.k8s.io/aggregate-to-view: "true"
{{- with .Values.commonAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
rules:
- apiGroups:
- metrics.k8s.io
Expand Down
4 changes: 4 additions & 0 deletions charts/metrics-server/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ metadata:
name: {{ printf "system:%s" (include "metrics-server.fullname" .) }}
labels:
{{- include "metrics-server.labels" . | nindent 4 }}
{{- with .Values.commonAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
rules:
- apiGroups:
- ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ metadata:
name: {{ printf "%s:system:auth-delegator" (include "metrics-server.fullname" .) }}
labels:
{{- include "metrics-server.labels" . | nindent 4 }}
{{- with .Values.commonAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
4 changes: 4 additions & 0 deletions charts/metrics-server/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ metadata:
name: {{ printf "system:%s" (include "metrics-server.fullname" .) }}
labels:
{{- include "metrics-server.labels" . | nindent 4 }}
{{- with .Values.commonAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
Expand Down
7 changes: 4 additions & 3 deletions charts/metrics-server/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ metadata:
namespace: {{ .Release.Namespace }}
labels:
{{- include "metrics-server.labels" . | nindent 4 }}
{{- with .Values.deploymentAnnotations }}
{{- $annotations := mustMergeOverwrite (dict) (.Values.commonAnnotations | default dict) (.Values.deploymentAnnotations | default dict) }}
{{- if $annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- toYaml $annotations | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.replicas }}
Expand Down Expand Up @@ -64,10 +65,10 @@ spec:
image: {{ include "metrics-server.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
args:
- {{ printf "--secure-port=%d" (int .Values.containerPort) }}
{{- range .Values.defaultArgs }}
- {{ . }}
{{- end }}
- {{ printf "--secure-port=%d" (int .Values.containerPort) }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't agree with this change. FYI this chart is designed to work with the official image or a hardened image built from the upstream source.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries. The issue for our usage is for our hardened environment we are required to use a custom entry point in a hardened image forked from upstream and call the application binary as the first arg.
e.g.

args:
- /metrics-server
- args.

{{- if .Values.metrics.enabled }}
- --authorization-always-allow-paths=/metrics
{{- end }}
Expand Down
4 changes: 4 additions & 0 deletions charts/metrics-server/templates/pdb.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ metadata:
namespace: {{ .Release.Namespace }}
labels:
{{- include "metrics-server.labels" . | nindent 4 }}
{{- with .Values.commonAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.podDisruptionBudget.minAvailable }}
minAvailable: {{ .Values.podDisruptionBudget.minAvailable }}
Expand Down
4 changes: 4 additions & 0 deletions charts/metrics-server/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ metadata:
namespace: kube-system
labels:
{{- include "metrics-server.labels" . | nindent 4 }}
{{- with .Values.commonAnnotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
Expand Down
5 changes: 3 additions & 2 deletions charts/metrics-server/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ metadata:
{{- with .Values.service.labels -}}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- with .Values.service.annotations }}
{{- $annotations := mustMergeOverwrite (dict) (.Values.commonAnnotations | default dict) (.Values.service.annotations | default dict) }}
{{- if $annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- toYaml $annotations | nindent 4 }}
{{- end }}
spec:
type: {{ .Values.service.type }}
Expand Down
8 changes: 6 additions & 2 deletions charts/metrics-server/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ metadata:
namespace: {{ .Release.Namespace }}
labels:
{{- include "metrics-server.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
{{- $annotations := mustMergeOverwrite (dict) (.Values.commonAnnotations | default dict) (.Values.serviceAccount.annotations | default dict) }}
{{- if $annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- toYaml $annotations | nindent 4 }}
{{- end }}
{{- if hasKey .Values.serviceAccount "automountServiceAccountToken" }}
automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}
{{- end }}
Comment on lines +14 to +16

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're making this change for security hardening you'll likely also need to modify the deployment.

{{- with .Values.serviceAccount.secrets }}
secrets:
{{- toYaml . | nindent 2 }}
Expand Down
5 changes: 5 additions & 0 deletions charts/metrics-server/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ serviceAccount:
# The list of secrets mountable by this service account.
# See https://kubernetes.io/docs/reference/labels-annotations-taints/#enforce-mountable-secrets
secrets: []
# Specifies whether to automount the service account token
# When not set, Kubernetes default (true) is used
# automountServiceAccountToken: true

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# automountServiceAccountToken: true
automountToken:

This is already in the service account context, and all values need to be declared in the values file.

You can use the following pattern to set the field.

{{- if ne .Values.serviceAccount.automountToken nil }}
...
{{- end }}


rbac:
# Specifies whether RBAC resources should be created
Expand All @@ -47,6 +50,8 @@ apiService:
caBundle: ""

commonLabels: {}
# Annotations to add to all resources
commonAnnotations: {}
podLabels: {}
podAnnotations: {}

Expand Down