Skip to content

Commit c086754

Browse files
authored
Add the ability to use global.imageRegistry (#151)
Signed-off-by: Pete Wall <pete.wall@grafana.com>
1 parent 6cb71b7 commit c086754

7 files changed

Lines changed: 67 additions & 24 deletions

File tree

charts/alloy-operator/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
* Update Alloy to 1.7.0 (@petewall)
66
* Add support for PodDisruptionBudget and topologySpreadConstraints (@petewall)
7+
* Add the ability to use global.imageRegistry instead of global.image.registry (@petewall)
78

89
## 0.5.2
910

charts/alloy-operator/README.md

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -59,27 +59,29 @@ A Helm chart the Alloy Operator, a project to innovate on creating instances of
5959
|-----|------|---------|-------------|
6060
| extraArgs | list | `[]` | Additional arguments to pass to the Alloy Operator. |
6161

62+
### Deployment Settings
63+
64+
| Key | Type | Default | Description |
65+
|-----|------|---------|-------------|
66+
| fullnameOverride | string | `""` | Overrides the chart's computed fullname. Used to change the full prefix of resource names. |
67+
| global.namespaceOverride | string | `""` | Global namespace override. When set, all resources will be deployed to this namespace instead of the Helm release namespace. Takes lower precedence than `namespaceOverride`. |
68+
| nameOverride | string | `""` | Overrides the chart's name. Used to change the infix in the resource names. |
69+
| namespaceOverride | string | `""` | Overrides the namespace for all resources deployed by this chart. When empty, resources are deployed to the Helm release namespace. |
70+
| replicaCount | int | `1` | How many replicas to use for the Alloy Operator Deployment. |
71+
6272
### Image Settings
6373

6474
| Key | Type | Default | Description |
6575
|-----|------|---------|-------------|
6676
| global.image.pullSecrets | list | `[]` | Global image pull secrets. |
67-
| global.image.registry | string | `""` | Global image registry override. |
77+
| global.imageRegistry | string | `""` | Global image registry override. |
6878
| image.digest | string | `""` | Alloy Operator image digest. If set, will override the tag. Format: sha256:&lt;digest&gt;. |
6979
| image.pullPolicy | string | `"IfNotPresent"` | The pull policy for images. |
7080
| image.pullSecrets | list | `[]` | Optional set of image pull secrets. |
7181
| image.registry | string | `"ghcr.io"` | Alloy Operator image registry |
7282
| image.repository | string | `"grafana/alloy-operator"` | Alloy Operator image repository |
7383
| image.tag | string | `""` | Alloy Operator image tag. When empty, the Chart's appVersion is used. |
7484

75-
### Deployment Settings
76-
77-
| Key | Type | Default | Description |
78-
|-----|------|---------|-------------|
79-
| global.namespaceOverride | string | `""` | Global namespace override. When set, all resources will be deployed to this namespace instead of the Helm release namespace. Takes lower precedence than `namespaceOverride`. |
80-
| namespaceOverride | string | `""` | Overrides the namespace for all resources deployed by this chart. When empty, resources are deployed to the Helm release namespace. |
81-
| replicaCount | int | `1` | How many replicas to use for the Alloy Operator Deployment. |
82-
8385
### Leader Election Settings
8486

8587
| Key | Type | Default | Description |
@@ -150,10 +152,3 @@ A Helm chart the Alloy Operator, a project to innovate on creating instances of
150152
| serviceMonitor.scrapeTimeout | string | `"10s"` | Set timeout for scrape |
151153
| serviceMonitor.targetLabels | list | `[]` | Set of labels to transfer from the Kubernetes Service onto the target |
152154
| serviceMonitor.telemetryPath | string | `"/metrics"` | Set path to metrics path |
153-
154-
### Other Values
155-
156-
| Key | Type | Default | Description |
157-
|-----|------|---------|-------------|
158-
| fullnameOverride | string | `""` | Overrides the chart's computed fullname. Used to change the full prefix of resource names. |
159-
| nameOverride | string | `""` | Overrides the chart's name. Used to change the infix in the resource names. |

charts/alloy-operator/templates/_helpers.tpl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ app.kubernetes.io/instance: {{ .Release.Name }}
5656
{{- .Values.namespaceOverride | default ((.Values.global).namespaceOverride) | default .Release.Namespace -}}
5757
{{- end }}
5858

59+
{{/* Calculate the image registry to use */}}
60+
{{- define "alloy-operator.imageRegistry" -}}
61+
{{- ((.Values.global).imageRegistry) | default (((.Values.global).image).registry) | default .Values.image.registry -}}
62+
{{- end -}}
63+
5964
{{/* Calculate the image identifier to use */}}
6065
{{- define "alloy-operator.imageIdentifier" -}}
6166
{{- if .Values.image.digest }}

charts/alloy-operator/templates/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ spec:
4040
{{- end }}
4141
containers:
4242
- name: {{ .Chart.Name }}
43-
image: "{{ .Values.global.image.registry | default .Values.image.registry }}/{{ .Values.image.repository }}{{ include "alloy-operator.imageIdentifier" . }}"
43+
image: "{{ include "alloy-operator.imageRegistry" . }}/{{ .Values.image.repository }}{{ include "alloy-operator.imageIdentifier" . }}"
4444
imagePullPolicy: {{ .Values.image.pullPolicy }}
4545
args:
4646
- --health-probe-bind-address=:{{ .Values.service.health.port }}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# yamllint disable rule:document-start rule:line-length rule:trailing-spaces
2+
suite: Test - Alloy Operator - Image Settings
3+
templates:
4+
- deployment.yaml
5+
tests:
6+
- it: uses the default image registry
7+
asserts:
8+
- matchRegex:
9+
path: spec.template.spec.containers[0].image
10+
pattern: "^ghcr\\.io/grafana/alloy-operator:"
11+
12+
- it: uses global.imageRegistry to override the image registry
13+
set:
14+
global:
15+
imageRegistry: my-registry.example.com
16+
asserts:
17+
- matchRegex:
18+
path: spec.template.spec.containers[0].image
19+
pattern: "^my-registry\\.example\\.com/grafana/alloy-operator:"
20+
21+
- it: uses global.image.registry for backwards compatibility
22+
set:
23+
global:
24+
image:
25+
registry: old-registry.example.com
26+
asserts:
27+
- matchRegex:
28+
path: spec.template.spec.containers[0].image
29+
pattern: "^old-registry\\.example\\.com/grafana/alloy-operator:"
30+
31+
- it: prefers global.imageRegistry over global.image.registry
32+
set:
33+
global:
34+
imageRegistry: preferred-registry.example.com
35+
image:
36+
registry: old-registry.example.com
37+
asserts:
38+
- matchRegex:
39+
path: spec.template.spec.containers[0].image
40+
pattern: "^preferred-registry\\.example\\.com/grafana/alloy-operator:"

charts/alloy-operator/values.schema.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
"properties": {
3131
"pullSecrets": {
3232
"type": "array"
33-
},
34-
"registry": {
35-
"type": "string"
3633
}
3734
}
3835
},
36+
"imageRegistry": {
37+
"type": "string"
38+
},
3939
"namespaceOverride": {
4040
"type": "string"
4141
}

charts/alloy-operator/values.yaml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
---
22
# -- Overrides the chart's name. Used to change the infix in the resource names.
3+
# @section -- Deployment Settings
34
nameOverride: ""
45
# -- Overrides the chart's computed fullname. Used to change the full prefix of
56
# resource names.
7+
# @section -- Deployment Settings
68
fullnameOverride: ""
79
# -- Overrides the namespace for all resources deployed by this chart. When empty,
810
# resources are deployed to the Helm release namespace.
@@ -15,11 +17,11 @@ global:
1517
# @section -- Deployment Settings
1618
namespaceOverride: ""
1719

18-
image:
19-
# -- Global image registry override.
20-
# @section -- Image Settings
21-
registry: ""
20+
# -- Global image registry override.
21+
# @section -- Image Settings
22+
imageRegistry: ""
2223

24+
image:
2325
# -- Global image pull secrets.
2426
# @section -- Image Settings
2527
pullSecrets: []

0 commit comments

Comments
 (0)