Skip to content

Commit 2b86360

Browse files
authored
[Feature] Allow to override default images (#536)
1 parent 301048c commit 2b86360

File tree

13 files changed

+127
-19
lines changed

13 files changed

+127
-19
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Change Log
22

33
## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
4+
- Added possibility to override default images used by ArangoDeployment
5+
- Added possibility to set probes on all groups
46
- Added Image Discovery type in ArangoDeployment spec
57
- Prevent Agency Members recreation
68
- Added Customizable Volumes and VolumeMounts for ArangoDB server container

chart/kube-arangodb/templates/deployment.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ spec:
9898
valueFrom:
9999
fieldRef:
100100
fieldPath: status.podIP
101+
- name: RELATED_IMAGE_UBI
102+
value: "{{ .Values.operator.images.base }}"
103+
- name: RELATED_IMAGE_METRICSEXPORTER
104+
value: "{{ .Values.operator.images.metricsExporter }}"
105+
- name: RELATED_IMAGE_DATABASE
106+
value: "{{ .Values.operator.images.arango }}"
101107
ports:
102108
- name: metrics
103109
containerPort: 8528

chart/kube-arangodb/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,9 @@ operator:
3131
storage: false
3232
backup: false
3333

34+
images:
35+
base: alpine:3.11
36+
metricsExporter: arangodb/arangodb-exporter:0.1.6
37+
arango: arangodb/arangodb:latest
3438
rbac:
3539
enabled: true

main.go

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ import (
3131
"strings"
3232
"time"
3333

34+
deploymentApi "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
35+
36+
"github.com/arangodb/kube-arangodb/pkg/util"
37+
3438
utilsError "github.com/arangodb/kube-arangodb/pkg/util/errors"
3539

3640
"github.com/pkg/errors"
@@ -58,11 +62,17 @@ import (
5862
)
5963

6064
const (
61-
defaultServerHost = "0.0.0.0"
62-
defaultServerPort = 8528
63-
defaultLogLevel = "debug"
64-
defaultAdminSecretName = "arangodb-operator-dashboard"
65-
defaultAlpineImage = "alpine:3.7"
65+
defaultServerHost = "0.0.0.0"
66+
defaultServerPort = 8528
67+
defaultLogLevel = "debug"
68+
defaultAdminSecretName = "arangodb-operator-dashboard"
69+
defaultAlpineImage = "alpine:3.7"
70+
defaultMetricsExporterImage = "arangodb/arangodb-exporter:0.1.6"
71+
defaultArangoImage = "arangodb/arangodb:latest"
72+
73+
UBIImageEnv util.EnvironmentVariable = "RELATED_IMAGE_UBI"
74+
ArangoImageEnv util.EnvironmentVariable = "RELATED_IMAGE_DATABASE"
75+
MetricsExporterImageEnv util.EnvironmentVariable = "RELATED_IMAGE_METRICSEXPORTER"
6676
)
6777

6878
var (
@@ -91,7 +101,8 @@ var (
91101
enableDeploymentReplication bool // Run deployment-replication operator
92102
enableStorage bool // Run local-storage operator
93103
enableBackup bool // Run backup operator
94-
alpineImage string
104+
105+
alpineImage, metricsExporterImage, arangoImage string
95106
}
96107
chaosOptions struct {
97108
allowed bool
@@ -104,6 +115,7 @@ var (
104115
)
105116

106117
func init() {
118+
107119
f := cmdMain.Flags()
108120
f.StringVar(&serverOptions.host, "server.host", defaultServerHost, "Host to listen on")
109121
f.IntVar(&serverOptions.port, "server.port", defaultServerPort, "Port to listen on")
@@ -115,7 +127,9 @@ func init() {
115127
f.BoolVar(&operatorOptions.enableDeploymentReplication, "operator.deployment-replication", false, "Enable to run the ArangoDeploymentReplication operator")
116128
f.BoolVar(&operatorOptions.enableStorage, "operator.storage", false, "Enable to run the ArangoLocalStorage operator")
117129
f.BoolVar(&operatorOptions.enableBackup, "operator.backup", false, "Enable to run the ArangoBackup operator")
118-
f.StringVar(&operatorOptions.alpineImage, "operator.alpine-image", defaultAlpineImage, "Docker image used for alpine containers")
130+
f.StringVar(&operatorOptions.alpineImage, "operator.alpine-image", UBIImageEnv.GetOrDefault(defaultAlpineImage), "Docker image used for alpine containers")
131+
f.StringVar(&operatorOptions.metricsExporterImage, "operator.metrics-exporter-image", MetricsExporterImageEnv.GetOrDefault(defaultMetricsExporterImage), "Docker image used for metrics containers by default")
132+
f.StringVar(&operatorOptions.arangoImage, "operator.arango-image", ArangoImageEnv.GetOrDefault(defaultArangoImage), "Docker image used for arango by default")
119133
f.BoolVar(&chaosOptions.allowed, "chaos.allowed", false, "Set to allow chaos in deployments. Only activated when allowed and enabled in deployment")
120134

121135
}
@@ -137,6 +151,8 @@ func cmdMainRun(cmd *cobra.Command, args []string) {
137151
name := os.Getenv(constants.EnvOperatorPodName)
138152
ip := os.Getenv(constants.EnvOperatorPodIP)
139153

154+
deploymentApi.DefaultImage = operatorOptions.arangoImage
155+
140156
// Prepare log service
141157
var err error
142158
logService, err = logging.NewService(logLevel)
@@ -277,6 +293,8 @@ func newOperatorConfigAndDeps(id, namespace, name string) (operator.Config, oper
277293
EnableBackup: operatorOptions.enableBackup,
278294
AllowChaos: chaosOptions.allowed,
279295
AlpineImage: operatorOptions.alpineImage,
296+
MetricsExporterImage: operatorOptions.metricsExporterImage,
297+
ArangoImage: operatorOptions.arangoImage,
280298
}
281299
deps := operator.Dependencies{
282300
LogService: logService,

pkg/apis/deployment/v1/deployment_spec.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ import (
3030
v1 "k8s.io/api/core/v1"
3131
)
3232

33-
const (
34-
defaultImage = "arangodb/arangodb:latest"
33+
var (
34+
DefaultImage = "arangodb/arangodb:latest"
3535
)
3636

3737
// validatePullPolicy the image pull policy.
@@ -223,7 +223,7 @@ func (s *DeploymentSpec) SetDefaults(deploymentName string) {
223223
s.StorageEngine = NewStorageEngine(StorageEngineRocksDB)
224224
}
225225
if s.GetImage() == "" && s.IsDevelopment() {
226-
s.Image = util.NewString(defaultImage)
226+
s.Image = util.NewString(DefaultImage)
227227
}
228228
if s.GetImagePullPolicy() == "" {
229229
s.ImagePullPolicy = util.NewPullPolicy(v1.PullIfNotPresent)

pkg/deployment/context_impl.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,3 +475,11 @@ func (d *Deployment) RenderPodForMember(spec api.DeploymentSpec, status api.Depl
475475
func (d *Deployment) SelectImage(spec api.DeploymentSpec, status api.DeploymentStatus) (api.ImageInfo, bool) {
476476
return d.resources.SelectImage(spec, status)
477477
}
478+
479+
func (d *Deployment) GetMetricsExporterImage() string {
480+
return d.config.MetricsExporterImage
481+
}
482+
483+
func (d *Deployment) GetArangoImage() string {
484+
return d.config.ArangoImage
485+
}

pkg/deployment/deployment.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ import (
5252

5353
// Config holds configuration settings for a Deployment
5454
type Config struct {
55-
ServiceAccount string
56-
AllowChaos bool
57-
LifecycleImage string
58-
AlpineImage string
55+
ServiceAccount string
56+
AllowChaos bool
57+
LifecycleImage string
58+
AlpineImage string
59+
MetricsExporterImage string
60+
ArangoImage string
5961
}
6062

6163
// Dependencies holds dependent services for a Deployment

pkg/deployment/resources/context.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ type Context interface {
6363
GetLifecycleImage() string
6464
// GetAlpineImage returns the image name containing the alpine environment
6565
GetAlpineImage() string
66+
// GetMetricsExporterImage returns the image name containing the default metrics exporter image
67+
GetMetricsExporterImage() string
68+
// GetArangoImage returns the image name containing the default arango image
69+
GetArangoImage() string
6670
// GetNamespace returns the namespace that contains the deployment
6771
GetNamespace() string
6872
// CreateEvent creates a given event.

pkg/deployment/resources/pod_creator.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -427,6 +427,7 @@ func (r *Resources) RenderPodForMember(spec api.DeploymentSpec, status api.Deplo
427427
group: group,
428428
resources: r,
429429
imageInfo: imageInfo,
430+
context: r.context,
430431
}
431432

432433
return RenderArangoPod(apiObject, role, m.ID, m.PodName, args, &memberPod)

pkg/deployment/resources/pod_creator_arangod.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func (m *MemberArangoDPod) GetServiceAccountName() string {
180180
func (m *MemberArangoDPod) GetSidecars(pod *core.Pod) {
181181

182182
if isMetricsEnabledForGroup(m.spec, m.group) {
183-
image := m.spec.GetImage()
183+
image := m.context.GetMetricsExporterImage()
184184
if m.spec.Metrics.HasImage() {
185185
image = m.spec.Metrics.GetImage()
186186
}

0 commit comments

Comments
 (0)