mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
Add option for different exporter docker image.
This commit is contained in:
parent
4d05a5b348
commit
b2a000850e
5 changed files with 62 additions and 4 deletions
|
@ -180,6 +180,7 @@ func (s *DeploymentSpec) SetDefaults(deploymentName string) {
|
||||||
s.Coordinators.SetDefaults(ServerGroupCoordinators, s.GetMode().HasCoordinators(), s.GetMode())
|
s.Coordinators.SetDefaults(ServerGroupCoordinators, s.GetMode().HasCoordinators(), s.GetMode())
|
||||||
s.SyncMasters.SetDefaults(ServerGroupSyncMasters, s.Sync.IsEnabled(), s.GetMode())
|
s.SyncMasters.SetDefaults(ServerGroupSyncMasters, s.Sync.IsEnabled(), s.GetMode())
|
||||||
s.SyncWorkers.SetDefaults(ServerGroupSyncWorkers, s.Sync.IsEnabled(), s.GetMode())
|
s.SyncWorkers.SetDefaults(ServerGroupSyncWorkers, s.Sync.IsEnabled(), s.GetMode())
|
||||||
|
s.Metrics.SetDefaults()
|
||||||
s.Chaos.SetDefaults()
|
s.Chaos.SetDefaults()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,6 +219,7 @@ func (s *DeploymentSpec) SetDefaultsFrom(source DeploymentSpec) {
|
||||||
s.Coordinators.SetDefaultsFrom(source.Coordinators)
|
s.Coordinators.SetDefaultsFrom(source.Coordinators)
|
||||||
s.SyncMasters.SetDefaultsFrom(source.SyncMasters)
|
s.SyncMasters.SetDefaultsFrom(source.SyncMasters)
|
||||||
s.SyncWorkers.SetDefaultsFrom(source.SyncWorkers)
|
s.SyncWorkers.SetDefaultsFrom(source.SyncWorkers)
|
||||||
|
s.Metrics.SetDefaultsFrom(source.Metrics)
|
||||||
s.Chaos.SetDefaultsFrom(source.Chaos)
|
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 {
|
if err := s.SyncWorkers.Validate(ServerGroupSyncWorkers, s.Sync.IsEnabled(), s.GetMode(), s.GetEnvironment()); err != nil {
|
||||||
return maskAny(err)
|
return maskAny(err)
|
||||||
}
|
}
|
||||||
|
if err := s.Metrics.Validate(); err != nil {
|
||||||
|
return maskAny(errors.Wrap(err, "spec.metrics"))
|
||||||
|
}
|
||||||
if err := s.Chaos.Validate(); err != nil {
|
if err := s.Chaos.Validate(); err != nil {
|
||||||
return maskAny(errors.Wrap(err, "spec.chaos"))
|
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 {
|
if l := s.SyncWorkers.ResetImmutableFields(ServerGroupSyncWorkers, "syncworkers", &target.SyncWorkers); l != nil {
|
||||||
resetFields = append(resetFields, l...)
|
resetFields = append(resetFields, l...)
|
||||||
}
|
}
|
||||||
|
if l := s.Metrics.ResetImmutableFields("metrics", &target.Metrics); l != nil {
|
||||||
|
resetFields = append(resetFields, l...)
|
||||||
|
}
|
||||||
return resetFields
|
return resetFields
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,10 +25,50 @@ import "github.com/arangodb/kube-arangodb/pkg/util"
|
||||||
|
|
||||||
// MetricsSpec contains spec for arangodb exporter
|
// MetricsSpec contains spec for arangodb exporter
|
||||||
type MetricsSpec struct {
|
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
|
// IsEnabled returns whether metrics are enabled or not
|
||||||
func (s *MetricsSpec) IsEnabled() bool {
|
func (s *MetricsSpec) IsEnabled() bool {
|
||||||
return util.BoolOrDefault(s.Enabled, false)
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -534,6 +534,11 @@ func (in *MetricsSpec) DeepCopyInto(out *MetricsSpec) {
|
||||||
*out = new(bool)
|
*out = new(bool)
|
||||||
**out = **in
|
**out = **in
|
||||||
}
|
}
|
||||||
|
if in.Image != nil {
|
||||||
|
in, out := &in.Image, &out.Image
|
||||||
|
*out = new(string)
|
||||||
|
**out = **in
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -619,10 +619,15 @@ func (r *Resources) createPodForMember(spec api.DeploymentSpec, memberID string,
|
||||||
SecretName: spec.Authentication.GetJWTSecretName(),
|
SecretName: spec.Authentication.GetJWTSecretName(),
|
||||||
SecretKey: constants.SecretKeyToken,
|
SecretKey: constants.SecretKeyToken,
|
||||||
}
|
}
|
||||||
|
image := spec.GetImage()
|
||||||
|
if spec.Metrics.HasImage() {
|
||||||
|
image = spec.Metrics.GetImage()
|
||||||
|
}
|
||||||
exporter = &k8sutil.ArangodbExporterContainerConf{
|
exporter = &k8sutil.ArangodbExporterContainerConf{
|
||||||
Args: createExporterArgs(),
|
Args: createExporterArgs(),
|
||||||
Env: env,
|
Env: env,
|
||||||
LivenessProbe: createExporterLivenessProbe(),
|
LivenessProbe: createExporterLivenessProbe(),
|
||||||
|
Image: image,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -336,7 +336,7 @@ func arangodbexporterContainer(image string, imagePullPolicy v1.PullPolicy, args
|
||||||
c := v1.Container{
|
c := v1.Container{
|
||||||
Command: append([]string{"/app/arangodb-exporter"}, args...),
|
Command: append([]string{"/app/arangodb-exporter"}, args...),
|
||||||
Name: ExporterContainerName,
|
Name: ExporterContainerName,
|
||||||
Image: "arangodb/arangodb-exporter:0.1.3",
|
Image: image,
|
||||||
ImagePullPolicy: v1.PullIfNotPresent,
|
ImagePullPolicy: v1.PullIfNotPresent,
|
||||||
Ports: []v1.ContainerPort{
|
Ports: []v1.ContainerPort{
|
||||||
{
|
{
|
||||||
|
@ -352,7 +352,6 @@ func arangodbexporterContainer(image string, imagePullPolicy v1.PullPolicy, args
|
||||||
if livenessProbe != nil {
|
if livenessProbe != nil {
|
||||||
c.LivenessProbe = livenessProbe.Create()
|
c.LivenessProbe = livenessProbe.Create()
|
||||||
}
|
}
|
||||||
|
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,6 +441,7 @@ type ArangodbExporterContainerConf struct {
|
||||||
Args []string
|
Args []string
|
||||||
Env map[string]EnvValue
|
Env map[string]EnvValue
|
||||||
LivenessProbe *HTTPProbeConfig
|
LivenessProbe *HTTPProbeConfig
|
||||||
|
Image string
|
||||||
}
|
}
|
||||||
|
|
||||||
// CreateArangodPod creates a Pod that runs `arangod`.
|
// CreateArangodPod creates a Pod that runs `arangod`.
|
||||||
|
@ -490,7 +490,7 @@ func CreateArangodPod(kubecli kubernetes.Interface, developmentMode bool, deploy
|
||||||
|
|
||||||
// Add arangodb exporter container
|
// Add arangodb exporter container
|
||||||
if exporter != nil {
|
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)
|
p.Spec.Containers = append(p.Spec.Containers, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue