1
0
Fork 0
mirror of https://github.com/arangodb/kube-arangodb.git synced 2024-12-15 17:51:03 +00:00

Add option for different exporter docker image.

This commit is contained in:
lamai93 2019-01-10 12:01:15 +01:00
parent 4d05a5b348
commit b2a000850e
5 changed files with 62 additions and 4 deletions

View file

@ -180,6 +180,7 @@ func (s *DeploymentSpec) SetDefaults(deploymentName string) {
s.Coordinators.SetDefaults(ServerGroupCoordinators, s.GetMode().HasCoordinators(), s.GetMode())
s.SyncMasters.SetDefaults(ServerGroupSyncMasters, s.Sync.IsEnabled(), s.GetMode())
s.SyncWorkers.SetDefaults(ServerGroupSyncWorkers, s.Sync.IsEnabled(), s.GetMode())
s.Metrics.SetDefaults()
s.Chaos.SetDefaults()
}
@ -218,6 +219,7 @@ func (s *DeploymentSpec) SetDefaultsFrom(source DeploymentSpec) {
s.Coordinators.SetDefaultsFrom(source.Coordinators)
s.SyncMasters.SetDefaultsFrom(source.SyncMasters)
s.SyncWorkers.SetDefaultsFrom(source.SyncWorkers)
s.Metrics.SetDefaultsFrom(source.Metrics)
s.Chaos.SetDefaultsFrom(source.Chaos)
}
@ -272,6 +274,9 @@ func (s *DeploymentSpec) Validate() error {
if err := s.SyncWorkers.Validate(ServerGroupSyncWorkers, s.Sync.IsEnabled(), s.GetMode(), s.GetEnvironment()); err != nil {
return maskAny(err)
}
if err := s.Metrics.Validate(); err != nil {
return maskAny(errors.Wrap(err, "spec.metrics"))
}
if err := s.Chaos.Validate(); err != nil {
return maskAny(errors.Wrap(err, "spec.chaos"))
}
@ -333,5 +338,8 @@ func (s DeploymentSpec) ResetImmutableFields(target *DeploymentSpec) []string {
if l := s.SyncWorkers.ResetImmutableFields(ServerGroupSyncWorkers, "syncworkers", &target.SyncWorkers); l != nil {
resetFields = append(resetFields, l...)
}
if l := s.Metrics.ResetImmutableFields("metrics", &target.Metrics); l != nil {
resetFields = append(resetFields, l...)
}
return resetFields
}

View file

@ -25,10 +25,50 @@ import "github.com/arangodb/kube-arangodb/pkg/util"
// MetricsSpec contains spec for arangodb exporter
type MetricsSpec struct {
Enabled *bool `json:"enabled,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
Image *string `json:"image,omitempty"`
//Authentication struct {
// // JWTSecretName contains the name of the JWT kubernetes secret used for authentication
// JWTSecretName *string `json:"JWTSecretName,omitempty"`
//} `json:"authentication,omitempty"`
}
// IsEnabled returns whether metrics are enabled or not
func (s *MetricsSpec) IsEnabled() bool {
return util.BoolOrDefault(s.Enabled, false)
}
// HasImage returns whether a image was specified or not
func (s *MetricsSpec) HasImage() bool {
return s.Image != nil
}
// GetImage returns the Image or empty string
func (s *MetricsSpec) GetImage() string {
return util.StringOrDefault(s.Image)
}
// SetDefaults sets default values
func (s *MetricsSpec) SetDefaults() {
s.Enabled = util.NewBool(false)
}
// SetDefaultsFrom fills unspecified fields with a value from given source spec.
func (s *MetricsSpec) SetDefaultsFrom(source MetricsSpec) {
if s.Enabled == nil {
s.Enabled = util.NewBoolOrNil(source.Enabled)
}
if s.Image == nil {
s.Image = util.NewStringOrNil(source.Image)
}
}
// Validate the given spec
func (s *MetricsSpec) Validate() error {
return nil
}
// ResetImmutableFields replaces all immutable fields in the given target with values from the source spec.
func (s SyncSpec) ResetImmutableFields(fieldPrefix string, target *SyncSpec) []string {
return nil
}

View file

@ -534,6 +534,11 @@ func (in *MetricsSpec) DeepCopyInto(out *MetricsSpec) {
*out = new(bool)
**out = **in
}
if in.Image != nil {
in, out := &in.Image, &out.Image
*out = new(string)
**out = **in
}
return
}

View file

@ -619,10 +619,15 @@ func (r *Resources) createPodForMember(spec api.DeploymentSpec, memberID string,
SecretName: spec.Authentication.GetJWTSecretName(),
SecretKey: constants.SecretKeyToken,
}
image := spec.GetImage()
if spec.Metrics.HasImage() {
image = spec.Metrics.GetImage()
}
exporter = &k8sutil.ArangodbExporterContainerConf{
Args: createExporterArgs(),
Env: env,
LivenessProbe: createExporterLivenessProbe(),
Image: image,
}
}
}

View file

@ -336,7 +336,7 @@ func arangodbexporterContainer(image string, imagePullPolicy v1.PullPolicy, args
c := v1.Container{
Command: append([]string{"/app/arangodb-exporter"}, args...),
Name: ExporterContainerName,
Image: "arangodb/arangodb-exporter:0.1.3",
Image: image,
ImagePullPolicy: v1.PullIfNotPresent,
Ports: []v1.ContainerPort{
{
@ -352,7 +352,6 @@ func arangodbexporterContainer(image string, imagePullPolicy v1.PullPolicy, args
if livenessProbe != nil {
c.LivenessProbe = livenessProbe.Create()
}
return c
}
@ -442,6 +441,7 @@ type ArangodbExporterContainerConf struct {
Args []string
Env map[string]EnvValue
LivenessProbe *HTTPProbeConfig
Image string
}
// CreateArangodPod creates a Pod that runs `arangod`.
@ -490,7 +490,7 @@ func CreateArangodPod(kubecli kubernetes.Interface, developmentMode bool, deploy
// Add arangodb exporter container
if exporter != nil {
c = arangodbexporterContainer(image, imagePullPolicy, exporter.Args, exporter.Env, exporter.LivenessProbe)
c = arangodbexporterContainer(exporter.Image, imagePullPolicy, exporter.Args, exporter.Env, exporter.LivenessProbe)
p.Spec.Containers = append(p.Spec.Containers, c)
}