Skip to content
Open
55 changes: 45 additions & 10 deletions charts/newrelic-pixie/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,56 @@ helm install newrelic/newrelic-pixie \

## Globals

**Important:** global parameters have higher precedence than locals with the same name.

These are meant to be used when you are writing a chart with subcharts. It helps to avoid
setting values multiple times on different subcharts.

**Precedence Model**: For each value, the precedence is (highest to lowest):
1. **Local value** (e.g., `cluster`) - takes precedence over global
2. **Global value** (e.g., `global.cluster`) - applies if local value is not set
3. **Default value** - applies if neither local nor global value is set

More information on globals and subcharts can be found at [Helm's official documentation](https://helm.sh/docs/topics/chart_template_guide/subcharts_and_globals/).

| Parameter |
| ------------------------------- |
| `global.cluster` |
| `global.licenseKey` |
| `global.customSecretName` |
| `global.customSecretLicenseKey` |
| `global.lowDataMode` |
| `global.nrStaging` |
### Supported Global Values

| Parameter | Description | Default |
| -------------------------------------- | ----------- | ------- |
| `global.cluster` | Cluster name for Kubernetes cluster | |
| `global.licenseKey` | New Relic license key | |
| `global.customSecretName` | Name of Secret containing license key | |
| `global.customSecretLicenseKey` | Key in Secret for license key | |
| `global.lowDataMode` | If true, enable low data mode sampling | false |
| `global.nrStaging` | Send data to staging environment | false |
| `global.proxy` | HTTP/HTTPS proxy URL for connectivity | |
| `global.images.registry` | Container registry (for air-gapped environments) | |
| `global.images.pullSecrets` | Image pull secrets | |
| `global.images.pullPolicy` | Image pull policy (IfNotPresent, Always, Never) | |
| `global.nodeSelector` | Node selector for pod scheduling | {} |
| `global.tolerations` | Node tolerations for tainted nodes | [] |
| `global.affinity` | Pod affinity rules | {} |
| `global.priorityClassName` | Priority class for pod scheduling | |
| `global.podSecurityContext` | Security context for pods | |
| `global.containerSecurityContext` | Security context for containers | |
| `global.dnsConfig` | DNS configuration for pods | |
| `global.hostNetwork` | Use host network for pod | false |
| `global.labels` | Additional labels for all resources | {} |
| `global.podLabels` | Additional labels for pods | {} |

### Important Notes

- **apiKey is not inherited from global**: The Pixie API key must be provided separately as `apiKey` (not `global.licenseKey`). This is because Pixie uses a separate authentication system from New Relic.
- **Example with globals**:
```yaml
global:
cluster: my-cluster
licenseKey: <your-nrl-key>
proxy: http://proxy.example.com:3128
nodeSelector:
node.role/monitoring: "true"

# Still required - Pixie uses separate auth:
apiKey: <your-pixie-api-key>
```

## Custom scripts

Expand Down
267 changes: 234 additions & 33 deletions charts/newrelic-pixie/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,48 +37,42 @@ release: {{.Release.Name }}
{{- end }}

{{- define "newrelic-pixie.cluster" -}}
{{- if .Values.global -}}
{{- if .Values.cluster -}}
{{- .Values.cluster -}}
{{- else if .Values.global -}}
{{- if .Values.global.cluster -}}
{{- .Values.global.cluster -}}
{{- else -}}
{{- .Values.cluster | default "" -}}
{{- .Values.global.cluster -}}
{{- end -}}
{{- else -}}
{{- .Values.cluster | default "" -}}
{{- end -}}
{{- end -}}

{{- define "newrelic-pixie.nrStaging" -}}
{{- if .Values.global }}
{{- if .Values.nrStaging }}
{{- .Values.nrStaging -}}
{{- else if .Values.global }}
{{- if .Values.global.nrStaging }}
{{- .Values.global.nrStaging -}}
{{- end -}}
{{- else if .Values.nrStaging }}
{{- .Values.nrStaging -}}
{{- end -}}
{{- end -}}

{{- define "newrelic-pixie.licenseKey" -}}
{{- if .Values.global}}
{{- if .Values.licenseKey }}
{{- .Values.licenseKey -}}
{{- else if .Values.global -}}
{{- if .Values.global.licenseKey }}
{{- .Values.global.licenseKey -}}
{{- else -}}
{{- .Values.licenseKey | default "" -}}
{{- .Values.global.licenseKey -}}
{{- end -}}
{{- else -}}
{{- .Values.licenseKey | default "" -}}
{{- end -}}
{{- end -}}

{{- define "newrelic-pixie.apiKey" -}}
{{- if .Values.global}}
{{- if .Values.apiKey }}
{{- .Values.apiKey -}}
{{- else if .Values.global -}}
{{- if .Values.global.apiKey }}
{{- .Values.global.apiKey -}}
{{- else -}}
{{- .Values.apiKey | default "" -}}
{{- .Values.global.apiKey -}}
{{- end -}}
{{- else -}}
{{- .Values.apiKey | default "" -}}
{{- end -}}
{{- end -}}

Expand Down Expand Up @@ -117,14 +111,12 @@ Returns "true" if `lowDataMode` is enabled, otherwise "" (empty string)
Return the customSecretName where the New Relic license is being stored.
*/}}
{{- define "newrelic-pixie.customSecretName" -}}
{{- if .Values.global }}
{{- if .Values.customSecretName }}
{{- .Values.customSecretName -}}
{{- else if .Values.global -}}
{{- if .Values.global.customSecretName }}
{{- .Values.global.customSecretName -}}
{{- else -}}
{{- .Values.customSecretName | default "" -}}
{{- .Values.global.customSecretName -}}
{{- end -}}
{{- else -}}
{{- .Values.customSecretName | default "" -}}
{{- end -}}
{{- end -}}

Expand All @@ -139,14 +131,12 @@ Return the customSecretApiKeyName where the Pixie API key is being stored.
Return the customSecretLicenseKey
*/}}
{{- define "newrelic-pixie.customSecretLicenseKey" -}}
{{- if .Values.global }}
{{- if .Values.customSecretLicenseKey }}
{{- .Values.customSecretLicenseKey -}}
{{- else if .Values.global -}}
{{- if .Values.global.customSecretLicenseKey }}
{{- .Values.global.customSecretLicenseKey -}}
{{- else -}}
{{- .Values.customSecretLicenseKey | default "" -}}
{{- .Values.global.customSecretLicenseKey -}}
{{- end -}}
{{- else -}}
{{- .Values.customSecretLicenseKey | default "" -}}
{{- end -}}
{{- end -}}

Expand All @@ -157,6 +147,217 @@ Return the customSecretApiKeyKey
{{- .Values.customSecretApiKeyKey | default "" -}}
{{- end -}}

{{/*
Return proxy configuration from global or local values
*/}}
{{- define "newrelic-pixie.proxy" -}}
{{- if .Values.proxy }}
{{- .Values.proxy -}}
{{- else if .Values.global }}
{{- if .Values.global.proxy }}
{{- .Values.global.proxy -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Return image registry from global or local values
*/}}
{{- define "newrelic-pixie.image.registry" -}}
{{- if .Values.image.registry }}
{{- .Values.image.registry -}}
{{- else if .Values.global -}}
{{- if .Values.global.images -}}
{{- if .Values.global.images.registry -}}
{{- .Values.global.images.registry -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Return image pull policy from local or global values with proper fallback precedence.
Precedence: local .Values.image.pullPolicy > global.images.pullPolicy > default "IfNotPresent"
*/}}
{{- define "newrelic-pixie.image.pullPolicy" -}}
{{- if .Values.image.pullPolicy }}
{{- .Values.image.pullPolicy -}}
{{- else if .Values.global -}}
{{- if .Values.global.images -}}
{{- if .Values.global.images.pullPolicy -}}
{{- .Values.global.images.pullPolicy -}}
{{- end -}}
{{- end -}}
{{- else }}
{{- /* Default fallback when neither local nor global set */ -}}
IfNotPresent
{{- end -}}
{{- end -}}

{{/*
Return image pull secrets from global or local values, merging both
*/}}
{{- define "newrelic-pixie.image.pullSecrets" -}}
{{- $localPullSecrets := .Values.image.pullSecrets | default list -}}
{{- $globalPullSecrets := list -}}
{{- if .Values.global -}}
{{- if .Values.global.images -}}
{{- $globalPullSecrets = .Values.global.images.pullSecrets | default list -}}
{{- end -}}
{{- end -}}
{{- $merged := concat $globalPullSecrets $localPullSecrets -}}
{{- if $merged }}
{{- toJson $merged -}}
{{- end -}}
{{- end -}}

{{/*
Return nodeSelector from global or local values
*/}}
{{- define "newrelic-pixie.nodeSelector" -}}
{{- if .Values.nodeSelector }}
{{- toJson .Values.nodeSelector -}}
{{- else if .Values.global }}
{{- if .Values.global.nodeSelector }}
{{- toJson .Values.global.nodeSelector -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Return tolerations from global or local values
*/}}
{{- define "newrelic-pixie.tolerations" -}}
{{- if .Values.tolerations }}
{{- toJson .Values.tolerations -}}
{{- else if .Values.global }}
{{- if .Values.global.tolerations }}
{{- toJson .Values.global.tolerations -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Return affinity from global or local values
*/}}
{{- define "newrelic-pixie.affinity" -}}
{{- if .Values.affinity }}
{{- toJson .Values.affinity -}}
{{- else if .Values.global }}
{{- if .Values.global.affinity }}
{{- toJson .Values.global.affinity -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Return priorityClassName from global or local values
*/}}
{{- define "newrelic-pixie.priorityClassName" -}}
{{- if .Values.priorityClassName }}
{{- .Values.priorityClassName -}}
{{- else if .Values.global }}
{{- if .Values.global.priorityClassName }}
{{- .Values.global.priorityClassName -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Return podSecurityContext from global or local values
*/}}
{{- define "newrelic-pixie.podSecurityContext" -}}
{{- if .Values.podSecurityContext }}
{{- toJson .Values.podSecurityContext -}}
{{- else if .Values.global }}
{{- if .Values.global.podSecurityContext }}
{{- toJson .Values.global.podSecurityContext -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Return containerSecurityContext from global or local values
*/}}
{{- define "newrelic-pixie.containerSecurityContext" -}}
{{- if .Values.containerSecurityContext }}
{{- toJson .Values.containerSecurityContext -}}
{{- else if .Values.global }}
{{- if .Values.global.containerSecurityContext }}
{{- toJson .Values.global.containerSecurityContext -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Return dnsConfig from global or local values
*/}}
{{- define "newrelic-pixie.dnsConfig" -}}
{{- if .Values.dnsConfig }}
{{- toJson .Values.dnsConfig -}}
{{- else if .Values.global }}
{{- if .Values.global.dnsConfig }}
{{- toJson .Values.global.dnsConfig -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Return hostNetwork from global or local values
*/}}
{{- define "newrelic-pixie.hostNetwork" -}}
{{- if kindIs "bool" .Values.hostNetwork }}
{{- .Values.hostNetwork -}}
{{- else if .Values.global }}
{{- if kindIs "bool" .Values.global.hostNetwork }}
{{- .Values.global.hostNetwork -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Return labels merged from global and local values
*/}}
{{- define "newrelic-pixie.labels.merged" -}}
{{- $globalLabels := dict -}}
{{- if .Values.global -}}
{{- $globalLabels = .Values.global.labels | default dict -}}
{{- end -}}
{{- $localLabels := .Values.labels | default dict -}}
{{- $merged := merge $localLabels $globalLabels -}}
{{- if $merged }}
{{- toJson $merged -}}
{{- end -}}
{{- end -}}

{{/*
Return podLabels merged from global and local values
*/}}
{{- define "newrelic-pixie.podLabels.merged" -}}
{{- $globalLabels := dict -}}
{{- if .Values.global -}}
{{- $globalLabels = .Values.global.podLabels | default dict -}}
{{- end -}}
{{- $localLabels := .Values.podLabels | default dict -}}
{{- $merged := merge $localLabels $globalLabels -}}
{{- if $merged }}
{{- toJson $merged -}}
{{- end -}}
{{- end -}}

{{/*
Return verboseLog from global or local values
*/}}
{{- define "newrelic-pixie.verboseLog" -}}
{{- if .Values.verboseLog }}
{{- .Values.verboseLog -}}
{{- else if .Values.global }}
{{- if .Values.global.verboseLog }}
{{- .Values.global.verboseLog -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Returns if the template should render, it checks if the required values
licenseKey and cluster are set.
Expand Down
Loading