Skip to content
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Change Log

## [master](https://github.com/arangodb/kube-arangodb/tree/master) (N/A)
- Added possibility to override default images used by ArangoDeployment
- Added possibility to set probes on all groups
- Added Image Discovery type in ArangoDeployment spec
- Prevent Agency Members recreation
- Added Customizable Volumes and VolumeMounts for ArangoDB server container
Expand Down
6 changes: 6 additions & 0 deletions chart/kube-arangodb/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ spec:
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: RELATED_IMAGE_UBI
value: "{{ .Values.operator.images.base }}"
- name: RELATED_IMAGE_METRICSEXPORTER
value: "{{ .Values.operator.images.metricsExporter }}"
- name: RELATED_IMAGE_DATABASE
value: "{{ .Values.operator.images.arango }}"
ports:
- name: metrics
containerPort: 8528
Expand Down
4 changes: 4 additions & 0 deletions chart/kube-arangodb/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,9 @@ operator:
storage: false
backup: false

images:
base: alpine:3.11
metricsExporter: arangodb/arangodb-exporter:0.1.6
arango: arangodb/arangodb:latest
rbac:
enabled: true
32 changes: 25 additions & 7 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ import (
"strings"
"time"

deploymentApi "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"

"github.com/arangodb/kube-arangodb/pkg/util"

utilsError "github.com/arangodb/kube-arangodb/pkg/util/errors"

"github.com/pkg/errors"
Expand Down Expand Up @@ -58,11 +62,17 @@ import (
)

const (
defaultServerHost = "0.0.0.0"
defaultServerPort = 8528
defaultLogLevel = "debug"
defaultAdminSecretName = "arangodb-operator-dashboard"
defaultAlpineImage = "alpine:3.7"
defaultServerHost = "0.0.0.0"
defaultServerPort = 8528
defaultLogLevel = "debug"
defaultAdminSecretName = "arangodb-operator-dashboard"
defaultAlpineImage = "alpine:3.7"
defaultMetricsExporterImage = "arangodb/arangodb-exporter:0.1.6"
defaultArangoImage = "arangodb/arangodb:latest"

UBIImageEnv util.EnvironmentVariable = "RELATED_IMAGE_UBI"
ArangoImageEnv util.EnvironmentVariable = "RELATED_IMAGE_DATABASE"
MetricsExporterImageEnv util.EnvironmentVariable = "RELATED_IMAGE_METRICSEXPORTER"
)

var (
Expand Down Expand Up @@ -91,7 +101,8 @@ var (
enableDeploymentReplication bool // Run deployment-replication operator
enableStorage bool // Run local-storage operator
enableBackup bool // Run backup operator
alpineImage string

alpineImage, metricsExporterImage, arangoImage string
}
chaosOptions struct {
allowed bool
Expand All @@ -104,6 +115,7 @@ var (
)

func init() {

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

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

deploymentApi.DefaultImage = operatorOptions.arangoImage

// Prepare log service
var err error
logService, err = logging.NewService(logLevel)
Expand Down Expand Up @@ -277,6 +293,8 @@ func newOperatorConfigAndDeps(id, namespace, name string) (operator.Config, oper
EnableBackup: operatorOptions.enableBackup,
AllowChaos: chaosOptions.allowed,
AlpineImage: operatorOptions.alpineImage,
MetricsExporterImage: operatorOptions.metricsExporterImage,
ArangoImage: operatorOptions.arangoImage,
}
deps := operator.Dependencies{
LogService: logService,
Expand Down
6 changes: 3 additions & 3 deletions pkg/apis/deployment/v1/deployment_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ import (
v1 "k8s.io/api/core/v1"
)

const (
defaultImage = "arangodb/arangodb:latest"
var (
DefaultImage = "arangodb/arangodb:latest"
)

// validatePullPolicy the image pull policy.
Expand Down Expand Up @@ -223,7 +223,7 @@ func (s *DeploymentSpec) SetDefaults(deploymentName string) {
s.StorageEngine = NewStorageEngine(StorageEngineRocksDB)
}
if s.GetImage() == "" && s.IsDevelopment() {
s.Image = util.NewString(defaultImage)
s.Image = util.NewString(DefaultImage)
}
if s.GetImagePullPolicy() == "" {
s.ImagePullPolicy = util.NewPullPolicy(v1.PullIfNotPresent)
Expand Down
8 changes: 8 additions & 0 deletions pkg/deployment/context_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,3 +475,11 @@ func (d *Deployment) RenderPodForMember(spec api.DeploymentSpec, status api.Depl
func (d *Deployment) SelectImage(spec api.DeploymentSpec, status api.DeploymentStatus) (api.ImageInfo, bool) {
return d.resources.SelectImage(spec, status)
}

func (d *Deployment) GetMetricsExporterImage() string {
return d.config.MetricsExporterImage
}

func (d *Deployment) GetArangoImage() string {
return d.config.ArangoImage
}
10 changes: 6 additions & 4 deletions pkg/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,12 @@ import (

// Config holds configuration settings for a Deployment
type Config struct {
ServiceAccount string
AllowChaos bool
LifecycleImage string
AlpineImage string
ServiceAccount string
AllowChaos bool
LifecycleImage string
AlpineImage string
MetricsExporterImage string
ArangoImage string
}

// Dependencies holds dependent services for a Deployment
Expand Down
4 changes: 4 additions & 0 deletions pkg/deployment/resources/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ type Context interface {
GetLifecycleImage() string
// GetAlpineImage returns the image name containing the alpine environment
GetAlpineImage() string
// GetMetricsExporterImage returns the image name containing the default metrics exporter image
GetMetricsExporterImage() string
// GetArangoImage returns the image name containing the default arango image
GetArangoImage() string
// GetNamespace returns the namespace that contains the deployment
GetNamespace() string
// CreateEvent creates a given event.
Expand Down
1 change: 1 addition & 0 deletions pkg/deployment/resources/pod_creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ func (r *Resources) RenderPodForMember(spec api.DeploymentSpec, status api.Deplo
group: group,
resources: r,
imageInfo: imageInfo,
context: r.context,
}

return RenderArangoPod(apiObject, role, m.ID, m.PodName, args, &memberPod)
Expand Down
2 changes: 1 addition & 1 deletion pkg/deployment/resources/pod_creator_arangod.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ func (m *MemberArangoDPod) GetServiceAccountName() string {
func (m *MemberArangoDPod) GetSidecars(pod *core.Pod) {

if isMetricsEnabledForGroup(m.spec, m.group) {
image := m.spec.GetImage()
image := m.context.GetMetricsExporterImage()
if m.spec.Metrics.HasImage() {
image = m.spec.Metrics.GetImage()
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ type Config struct {
ServiceAccount string
LifecycleImage string
AlpineImage string
ArangoImage string
MetricsExporterImage string
EnableDeployment bool
EnableDeploymentReplication bool
EnableStorage bool
Expand Down
10 changes: 6 additions & 4 deletions pkg/operator/operator_deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,12 @@ func (o *Operator) handleDeploymentEvent(event *Event) error {
// makeDeploymentConfigAndDeps creates a Config & Dependencies object for a new Deployment.
func (o *Operator) makeDeploymentConfigAndDeps(apiObject *api.ArangoDeployment) (deployment.Config, deployment.Dependencies) {
cfg := deployment.Config{
ServiceAccount: o.Config.ServiceAccount,
LifecycleImage: o.Config.LifecycleImage,
AlpineImage: o.Config.AlpineImage,
AllowChaos: o.Config.AllowChaos,
ServiceAccount: o.Config.ServiceAccount,
LifecycleImage: o.Config.LifecycleImage,
AlpineImage: o.Config.AlpineImage,
MetricsExporterImage: o.MetricsExporterImage,
ArangoImage: o.ArangoImage,
AllowChaos: o.Config.AllowChaos,
}
deps := deployment.Dependencies{
Log: o.Dependencies.LogService.MustGetLogger("deployment").With().
Expand Down
59 changes: 59 additions & 0 deletions pkg/util/env.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
//
// DISCLAIMER
//
// Copyright 2020 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
// Author Adam Janikowski
//

package util

import "os"

// EnvironmentVariable is a wrapper to get environment variables
type EnvironmentVariable string

// String return string representation of environment variable name
func (e EnvironmentVariable) String() string {
return string(e)
}

// Lookup for environment variable
func (e EnvironmentVariable) Lookup() (string, bool) {
return os.LookupEnv(e.String())
}

// Exists check if variable is defined
func (e EnvironmentVariable) Exists() bool {
_, exists := e.Lookup()
return exists
}

// Get fetch variable. If variable does not exist empty string is returned
func (e EnvironmentVariable) Get() string {
value, _ := e.Lookup()
return value
}

// GetOrDefault fetch variable. If variable is not defined default value is returned
func (e EnvironmentVariable) GetOrDefault(d string) string {
if value, exists := e.Lookup(); exists {
return value
}

return d
}