mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
Removed spec.sync.image & spec.sync.imagePullPolicy
This commit is contained in:
parent
082b6ac225
commit
8021395116
6 changed files with 22 additions and 120 deletions
|
@ -205,17 +205,6 @@ replication in the cluster. When enabled, the cluster will contain
|
|||
a number of `syncmaster` & `syncworker` servers.
|
||||
The default value is `false`.
|
||||
|
||||
### `spec.sync.image: string`
|
||||
|
||||
This setting specifies the docker image to use for all ArangoSync servers.
|
||||
When not specified, the `spec.image` value is used.
|
||||
|
||||
### `spec.sync.imagePullPolicy: string`
|
||||
|
||||
This setting specifies the pull policy for the docker image to use for all ArangoSync servers.
|
||||
For possible values, see `spec.imagePullPolicy`.
|
||||
When not specified, the `spec.imagePullPolicy` value is used.
|
||||
|
||||
### `spec.sync.externalAccess.type: string`
|
||||
|
||||
This setting specifies the type of `Service` that will be created to provide
|
||||
|
|
|
@ -92,22 +92,6 @@ func (s DeploymentSpec) GetImagePullPolicy() v1.PullPolicy {
|
|||
return util.PullPolicyOrDefault(s.ImagePullPolicy)
|
||||
}
|
||||
|
||||
// GetImageByGroup returns the image used for a server in given group.
|
||||
func (s DeploymentSpec) GetImageByGroup(group ServerGroup) string {
|
||||
if group.IsArangosync() {
|
||||
return s.Sync.GetImage()
|
||||
}
|
||||
return s.GetImage()
|
||||
}
|
||||
|
||||
// GetImagePullPolicyByGroup returns the image pull policy used for a server in given group.
|
||||
func (s DeploymentSpec) GetImagePullPolicyByGroup(group ServerGroup) v1.PullPolicy {
|
||||
if group.IsArangosync() {
|
||||
return s.Sync.GetImagePullPolicy()
|
||||
}
|
||||
return s.GetImagePullPolicy()
|
||||
}
|
||||
|
||||
// IsAuthenticated returns true when authentication is enabled
|
||||
func (s DeploymentSpec) IsAuthenticated() bool {
|
||||
return s.Authentication.IsAuthenticated()
|
||||
|
@ -160,7 +144,7 @@ func (s *DeploymentSpec) SetDefaults(deploymentName string) {
|
|||
s.RocksDB.SetDefaults()
|
||||
s.Authentication.SetDefaults(deploymentName + "-jwt")
|
||||
s.TLS.SetDefaults(deploymentName + "-ca")
|
||||
s.Sync.SetDefaults(s.GetImage(), s.GetImagePullPolicy(), deploymentName+"-sync-jwt", deploymentName+"-sync-client-auth-ca", deploymentName+"-sync-ca")
|
||||
s.Sync.SetDefaults(deploymentName+"-sync-jwt", deploymentName+"-sync-client-auth-ca", deploymentName+"-sync-ca")
|
||||
s.Single.SetDefaults(ServerGroupSingle, s.GetMode().HasSingleServers(), s.GetMode())
|
||||
s.Agents.SetDefaults(ServerGroupAgents, s.GetMode().HasAgents(), s.GetMode())
|
||||
s.DBServers.SetDefaults(ServerGroupDBServers, s.GetMode().HasDBServers(), s.GetMode())
|
||||
|
|
|
@ -24,16 +24,13 @@ package v1alpha
|
|||
|
||||
import (
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/api/core/v1"
|
||||
|
||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||
)
|
||||
|
||||
// SyncSpec holds dc2dc replication specific configuration settings
|
||||
type SyncSpec struct {
|
||||
Enabled *bool `json:"enabled,omitempty"`
|
||||
Image *string `json:"image,omitempty"`
|
||||
ImagePullPolicy *v1.PullPolicy `json:"imagePullPolicy,omitempty"`
|
||||
Enabled *bool `json:"enabled,omitempty"`
|
||||
|
||||
ExternalAccess SyncExternalAccessSpec `json:"externalAccess"`
|
||||
Authentication SyncAuthenticationSpec `json:"auth"`
|
||||
|
@ -46,24 +43,11 @@ func (s SyncSpec) IsEnabled() bool {
|
|||
return util.BoolOrDefault(s.Enabled)
|
||||
}
|
||||
|
||||
// GetImage returns the value of image.
|
||||
func (s SyncSpec) GetImage() string {
|
||||
return util.StringOrDefault(s.Image)
|
||||
}
|
||||
|
||||
// GetImagePullPolicy returns the value of imagePullPolicy.
|
||||
func (s SyncSpec) GetImagePullPolicy() v1.PullPolicy {
|
||||
return util.PullPolicyOrDefault(s.ImagePullPolicy)
|
||||
}
|
||||
|
||||
// Validate the given spec
|
||||
func (s SyncSpec) Validate(mode DeploymentMode) error {
|
||||
if s.IsEnabled() && !mode.SupportsSync() {
|
||||
return maskAny(errors.Wrapf(ValidationError, "Cannot enable sync with mode: '%s'", mode))
|
||||
}
|
||||
if s.GetImage() == "" {
|
||||
return maskAny(errors.Wrapf(ValidationError, "image must be set"))
|
||||
}
|
||||
if s.IsEnabled() {
|
||||
if err := s.ExternalAccess.Validate(); err != nil {
|
||||
return maskAny(err)
|
||||
|
@ -82,13 +66,7 @@ func (s SyncSpec) Validate(mode DeploymentMode) error {
|
|||
}
|
||||
|
||||
// SetDefaults fills in missing defaults
|
||||
func (s *SyncSpec) SetDefaults(defaultImage string, defaulPullPolicy v1.PullPolicy, defaultJWTSecretName, defaultClientAuthCASecretName, defaultTLSCASecretName string) {
|
||||
if s.GetImage() == "" {
|
||||
s.Image = util.NewString(defaultImage)
|
||||
}
|
||||
if s.GetImagePullPolicy() == "" {
|
||||
s.ImagePullPolicy = util.NewPullPolicy(defaulPullPolicy)
|
||||
}
|
||||
func (s *SyncSpec) SetDefaults(defaultJWTSecretName, defaultClientAuthCASecretName, defaultTLSCASecretName string) {
|
||||
s.ExternalAccess.SetDefaults()
|
||||
s.Authentication.SetDefaults(defaultJWTSecretName, defaultClientAuthCASecretName)
|
||||
s.TLS.SetDefaults(defaultTLSCASecretName)
|
||||
|
@ -100,12 +78,6 @@ func (s *SyncSpec) SetDefaultsFrom(source SyncSpec) {
|
|||
if s.Enabled == nil {
|
||||
s.Enabled = util.NewBoolOrNil(source.Enabled)
|
||||
}
|
||||
if s.Image == nil {
|
||||
s.Image = util.NewStringOrNil(source.Image)
|
||||
}
|
||||
if s.ImagePullPolicy == nil {
|
||||
s.ImagePullPolicy = util.NewPullPolicyOrNil(source.ImagePullPolicy)
|
||||
}
|
||||
s.ExternalAccess.SetDefaultsFrom(source.ExternalAccess)
|
||||
s.Authentication.SetDefaultsFrom(source.Authentication)
|
||||
s.TLS.SetDefaultsFrom(source.TLS)
|
||||
|
|
|
@ -27,39 +27,31 @@ import (
|
|||
|
||||
"github.com/arangodb/kube-arangodb/pkg/util"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
func TestSyncSpecValidate(t *testing.T) {
|
||||
// Valid
|
||||
auth := SyncAuthenticationSpec{JWTSecretName: util.NewString("foo"), ClientCASecretName: util.NewString("foo-client")}
|
||||
tls := TLSSpec{CASecretName: util.NewString("None")}
|
||||
assert.Nil(t, SyncSpec{Image: util.NewString("foo"), Authentication: auth}.Validate(DeploymentModeSingle))
|
||||
assert.Nil(t, SyncSpec{Image: util.NewString("foo"), Authentication: auth}.Validate(DeploymentModeActiveFailover))
|
||||
assert.Nil(t, SyncSpec{Image: util.NewString("foo"), Authentication: auth}.Validate(DeploymentModeCluster))
|
||||
assert.Nil(t, SyncSpec{Image: util.NewString("foo"), Authentication: auth, TLS: tls, Enabled: util.NewBool(true)}.Validate(DeploymentModeCluster))
|
||||
assert.Nil(t, SyncSpec{Authentication: auth}.Validate(DeploymentModeSingle))
|
||||
assert.Nil(t, SyncSpec{Authentication: auth}.Validate(DeploymentModeActiveFailover))
|
||||
assert.Nil(t, SyncSpec{Authentication: auth}.Validate(DeploymentModeCluster))
|
||||
assert.Nil(t, SyncSpec{Authentication: auth, TLS: tls, Enabled: util.NewBool(true)}.Validate(DeploymentModeCluster))
|
||||
|
||||
// Not valid
|
||||
assert.Error(t, SyncSpec{Image: util.NewString(""), Authentication: auth}.Validate(DeploymentModeSingle))
|
||||
assert.Error(t, SyncSpec{Image: util.NewString(""), Authentication: auth}.Validate(DeploymentModeActiveFailover))
|
||||
assert.Error(t, SyncSpec{Image: util.NewString(""), Authentication: auth}.Validate(DeploymentModeCluster))
|
||||
assert.Error(t, SyncSpec{Image: util.NewString("foo"), Authentication: auth, TLS: tls, Enabled: util.NewBool(true)}.Validate(DeploymentModeSingle))
|
||||
assert.Error(t, SyncSpec{Image: util.NewString("foo"), Authentication: auth, TLS: tls, Enabled: util.NewBool(true)}.Validate(DeploymentModeActiveFailover))
|
||||
assert.Error(t, SyncSpec{Authentication: auth, TLS: tls, Enabled: util.NewBool(true)}.Validate(DeploymentModeSingle))
|
||||
assert.Error(t, SyncSpec{Authentication: auth, TLS: tls, Enabled: util.NewBool(true)}.Validate(DeploymentModeActiveFailover))
|
||||
}
|
||||
|
||||
func TestSyncSpecSetDefaults(t *testing.T) {
|
||||
def := func(spec SyncSpec) SyncSpec {
|
||||
spec.SetDefaults("test-image", v1.PullAlways, "test-jwt", "test-client-auth-ca", "test-tls-ca")
|
||||
spec.SetDefaults("test-jwt", "test-client-auth-ca", "test-tls-ca")
|
||||
return spec
|
||||
}
|
||||
|
||||
assert.False(t, def(SyncSpec{}).IsEnabled())
|
||||
assert.False(t, def(SyncSpec{Enabled: util.NewBool(false)}).IsEnabled())
|
||||
assert.True(t, def(SyncSpec{Enabled: util.NewBool(true)}).IsEnabled())
|
||||
assert.Equal(t, "test-image", def(SyncSpec{}).GetImage())
|
||||
assert.Equal(t, "foo", def(SyncSpec{Image: util.NewString("foo")}).GetImage())
|
||||
assert.Equal(t, v1.PullAlways, def(SyncSpec{}).GetImagePullPolicy())
|
||||
assert.Equal(t, v1.PullNever, def(SyncSpec{ImagePullPolicy: util.NewPullPolicy(v1.PullNever)}).GetImagePullPolicy())
|
||||
assert.Equal(t, "test-jwt", def(SyncSpec{}).Authentication.GetJWTSecretName())
|
||||
assert.Equal(t, "foo", def(SyncSpec{Authentication: SyncAuthenticationSpec{JWTSecretName: util.NewString("foo")}}).Authentication.GetJWTSecretName())
|
||||
}
|
||||
|
@ -84,18 +76,6 @@ func TestSyncSpecResetImmutableFields(t *testing.T) {
|
|||
SyncSpec{Enabled: util.NewBool(false)},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
SyncSpec{Image: util.NewString("foo")},
|
||||
SyncSpec{Image: util.NewString("foo2")},
|
||||
SyncSpec{Image: util.NewString("foo2")},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
SyncSpec{ImagePullPolicy: util.NewPullPolicy(v1.PullAlways)},
|
||||
SyncSpec{ImagePullPolicy: util.NewPullPolicy(v1.PullNever)},
|
||||
SyncSpec{ImagePullPolicy: util.NewPullPolicy(v1.PullNever)},
|
||||
nil,
|
||||
},
|
||||
{
|
||||
SyncSpec{Authentication: SyncAuthenticationSpec{JWTSecretName: util.NewString("None"), ClientCASecretName: util.NewString("some")}},
|
||||
SyncSpec{Authentication: SyncAuthenticationSpec{JWTSecretName: util.NewString("None"), ClientCASecretName: util.NewString("some")}},
|
||||
|
|
|
@ -678,24 +678,6 @@ func (in *SyncSpec) DeepCopyInto(out *SyncSpec) {
|
|||
**out = **in
|
||||
}
|
||||
}
|
||||
if in.Image != nil {
|
||||
in, out := &in.Image, &out.Image
|
||||
if *in == nil {
|
||||
*out = nil
|
||||
} else {
|
||||
*out = new(string)
|
||||
**out = **in
|
||||
}
|
||||
}
|
||||
if in.ImagePullPolicy != nil {
|
||||
in, out := &in.ImagePullPolicy, &out.ImagePullPolicy
|
||||
if *in == nil {
|
||||
*out = nil
|
||||
} else {
|
||||
*out = new(core_v1.PullPolicy)
|
||||
**out = **in
|
||||
}
|
||||
}
|
||||
in.ExternalAccess.DeepCopyInto(&out.ExternalAccess)
|
||||
in.Authentication.DeepCopyInto(&out.Authentication)
|
||||
in.TLS.DeepCopyInto(&out.TLS)
|
||||
|
|
|
@ -445,14 +445,14 @@ func (r *Resources) createPodForMember(spec api.DeploymentSpec, group api.Server
|
|||
podSuffix := createPodSuffix(spec)
|
||||
m.PodName = k8sutil.CreatePodName(apiObject.GetName(), roleAbbr, m.ID, podSuffix)
|
||||
newPhase := api.MemberPhaseCreated
|
||||
// Find image ID
|
||||
imageInfo, imageFound := status.Images.GetByImage(spec.GetImage())
|
||||
if !imageFound {
|
||||
log.Debug().Str("image", spec.GetImage()).Msg("Image ID is not known yet for image")
|
||||
return nil
|
||||
}
|
||||
// Create pod
|
||||
if group.IsArangod() {
|
||||
// Find image ID
|
||||
info, found := status.Images.GetByImage(spec.GetImage())
|
||||
if !found {
|
||||
log.Debug().Str("image", spec.GetImage()).Msg("Image ID is not known yet for image")
|
||||
return nil
|
||||
}
|
||||
// Prepare arguments
|
||||
autoUpgrade := m.Conditions.IsTrue(api.ConditionTypeAutoUpgrade)
|
||||
if autoUpgrade {
|
||||
|
@ -499,21 +499,16 @@ func (r *Resources) createPodForMember(spec api.DeploymentSpec, group api.Server
|
|||
engine := spec.GetStorageEngine().AsArangoArgument()
|
||||
requireUUID := group == api.ServerGroupDBServers && m.IsInitialized
|
||||
finalizers := r.createPodFinalizers(group)
|
||||
if err := k8sutil.CreateArangodPod(kubecli, spec.IsDevelopment(), apiObject, role, m.ID, m.PodName, m.PersistentVolumeClaimName, info.ImageID, lifecycleImage, spec.GetImagePullPolicy(),
|
||||
if err := k8sutil.CreateArangodPod(kubecli, spec.IsDevelopment(), apiObject, role, m.ID, m.PodName, m.PersistentVolumeClaimName, imageInfo.ImageID, lifecycleImage, spec.GetImagePullPolicy(),
|
||||
engine, requireUUID, terminationGracePeriod, args, env, finalizers, livenessProbe, readinessProbe, tolerations, tlsKeyfileSecretName, rocksdbEncryptionSecretName); err != nil {
|
||||
return maskAny(err)
|
||||
}
|
||||
log.Debug().Str("pod-name", m.PodName).Msg("Created pod")
|
||||
} else if group.IsArangosync() {
|
||||
// Find image ID
|
||||
info, found := status.Images.GetByImage(spec.Sync.GetImage())
|
||||
if !found {
|
||||
log.Debug().Str("image", spec.Sync.GetImage()).Msg("Image ID is not known yet for sync image")
|
||||
return nil
|
||||
}
|
||||
if !info.Enterprise {
|
||||
log.Debug().Str("image", spec.Sync.GetImage()).Msg("Image is not an enterprise image")
|
||||
return maskAny(fmt.Errorf("Image '%s' does not contain an Enterprise version of ArangoDB", spec.Sync.GetImage()))
|
||||
// Check image
|
||||
if !imageInfo.Enterprise {
|
||||
log.Debug().Str("image", spec.GetImage()).Msg("Image is not an enterprise image")
|
||||
return maskAny(fmt.Errorf("Image '%s' does not contain an Enterprise version of ArangoDB", spec.GetImage()))
|
||||
}
|
||||
var tlsKeyfileSecretName, clientAuthCASecretName, masterJWTSecretName, clusterJWTSecretName string
|
||||
// Check master JWT secret
|
||||
|
@ -570,7 +565,7 @@ func (r *Resources) createPodForMember(spec api.DeploymentSpec, group api.Server
|
|||
if group == api.ServerGroupSyncWorkers {
|
||||
affinityWithRole = api.ServerGroupDBServers.AsRole()
|
||||
}
|
||||
if err := k8sutil.CreateArangoSyncPod(kubecli, spec.IsDevelopment(), apiObject, role, m.ID, m.PodName, info.ImageID, lifecycleImage, spec.Sync.GetImagePullPolicy(), terminationGracePeriod, args, env,
|
||||
if err := k8sutil.CreateArangoSyncPod(kubecli, spec.IsDevelopment(), apiObject, role, m.ID, m.PodName, imageInfo.ImageID, lifecycleImage, spec.GetImagePullPolicy(), terminationGracePeriod, args, env,
|
||||
livenessProbe, tolerations, tlsKeyfileSecretName, clientAuthCASecretName, masterJWTSecretName, clusterJWTSecretName, affinityWithRole); err != nil {
|
||||
return maskAny(err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue