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

feat(kubelet): Create an agent container in the kubelet pod only #944

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{{- /* Naming helpers*/ -}}
{{- define "nriKubernetes.kubelet.fullname" -}}
{{- if (.Values.kubelet.agentOnly) }}
{{- include "newrelic.common.naming.truncateToDNSWithSuffix" (dict "name" (include "nriKubernetes.naming.fullname" .) "suffix" "agent") -}}
{{- else }}
{{- include "newrelic.common.naming.truncateToDNSWithSuffix" (dict "name" (include "nriKubernetes.naming.fullname" .) "suffix" "kubelet") -}}
{{- end }}
{{- end -}}

{{- define "nriKubernetes.kubelet.fullname.agent" -}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{- if (.Values.kubelet.enabled) }}
apiVersion: apps/v1
kind: DaemonSet
kind: {{ if (.Values.kubelet.agentOnly) }}Deployment{{ else }}DaemonSet{{ end }}
metadata:
namespace: {{ .Release.Namespace }}
labels:
Expand All @@ -11,17 +11,26 @@ metadata:
annotations: {{ . | nindent 4 }}
{{- end }}
spec:
{{- if (.Values.kubelet.agentOnly) }}
{{- with .Values.strategy }}
strategy: {{ toYaml . | nindent 4 }}
{{- end }}
{{- end }}
{{- if not (.Values.kubelet.agentOnly) }}
{{- with .Values.updateStrategy }}
updateStrategy: {{ toYaml . | nindent 4 }}
{{- end }}
{{- end }}
selector:
matchLabels:
{{- include "newrelic.common.labels.selectorLabels" . | nindent 6 }}
app.kubernetes.io/component: kubelet
template:
metadata:
annotations:
{{- if not (.Values.kubelet.agentOnly) }}
checksum/nri-kubernetes: {{ include (print $.Template.BasePath "/kubelet/scraper-configmap.yaml") . | sha256sum }}
{{- end }}
checksum/agent-config: {{ include (print $.Template.BasePath "/kubelet/agent-configmap.yaml") . | sha256sum }}
{{- if include "newrelic.common.license.secret" . }}{{- /* If the is secret to template */}}
checksum/license-secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
Expand Down Expand Up @@ -59,6 +68,7 @@ spec:
initContainers: {{- tpl (.Values.kubelet.initContainers | toYaml) . | nindent 8 }}
{{- end }}
containers:
{{- if not (.Values.kubelet.agentOnly) }}
- name: kubelet
image: {{ include "newrelic.common.images.image" ( dict "imageRoot" .Values.images.integration "context" .) }}
imagePullPolicy: {{ .Values.images.integration.pullPolicy }}
Expand Down Expand Up @@ -102,6 +112,7 @@ spec:
{{- with .Values.kubelet.resources }}
resources: {{ toYaml . | nindent 12 }}
{{- end }}
{{- end }}
- name: agent
image: {{ include "newrelic.common.images.image" ( dict "imageRoot" .Values.images.agent "context" .) }}
args: [ "newrelic-infra" ]
Expand Down Expand Up @@ -230,12 +241,14 @@ spec:
emptyDir: {}
- name: agent-tmpfs-tmp
emptyDir: {}
{{- if not (.Values.kubelet.agentOnly) }}
- name: nri-kubernetes-config
configMap:
name: {{ include "nriKubernetes.kubelet.fullname" . }}
items:
- key: nri-kubernetes.yml
path: nri-kubernetes.yml
{{- end }}
- name: config
configMap:
name: {{ include "nriKubernetes.kubelet.fullname.agent" . }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.kubelet.enabled -}}
{{- if and (.Values.kubelet.enabled) (not (.Values.kubelet.agentOnly)) -}}
---
apiVersion: v1
kind: ConfigMap
Expand Down
4 changes: 4 additions & 0 deletions charts/newrelic-infrastructure/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ kubelet:
# -- Enable kubelet monitoring.
# Advanced users only. Setting this to `false` is not supported and will break the New Relic experience.
enabled: true
# -- Enable agent only.
# Advanced users only. Setting this to `true` is not supported and will break the New Relic experience.
# deploy only an agent container from a deployment rather than agent and kubelet containers from a daemonSet
agentOnly: false
annotations: {}
# -- Tolerations for the control plane DaemonSet.
# @default -- Schedules in all tainted nodes
Expand Down