mirror of
https://github.com/arangodb/kube-arangodb.git
synced 2024-12-14 11:57:37 +00:00
Using clear roles again
This commit is contained in:
parent
1d3d82b10f
commit
8d4fb8ea11
6 changed files with 41 additions and 11 deletions
|
@ -5,7 +5,7 @@ metadata:
|
|||
spec:
|
||||
selector:
|
||||
app: arangodb
|
||||
role: crdn
|
||||
role: coordinator
|
||||
type: NodePort
|
||||
publishNotReadyAddresses: true
|
||||
ports:
|
||||
|
|
|
@ -5,7 +5,7 @@ metadata:
|
|||
spec:
|
||||
selector:
|
||||
app: arangodb
|
||||
role: sngl
|
||||
role: single
|
||||
type: NodePort
|
||||
ports:
|
||||
- protocol: TCP
|
||||
|
|
|
@ -47,6 +47,26 @@ var (
|
|||
|
||||
// AsRole returns the "role" value for the given group.
|
||||
func (g ServerGroup) AsRole() string {
|
||||
switch g {
|
||||
case ServerGroupSingle:
|
||||
return "single"
|
||||
case ServerGroupAgents:
|
||||
return "agent"
|
||||
case ServerGroupDBServers:
|
||||
return "dbserver"
|
||||
case ServerGroupCoordinators:
|
||||
return "coordinator"
|
||||
case ServerGroupSyncMasters:
|
||||
return "syncmaster"
|
||||
case ServerGroupSyncWorkers:
|
||||
return "syncworker"
|
||||
default:
|
||||
return "?"
|
||||
}
|
||||
}
|
||||
|
||||
// AsRoleAbbreviated returns the abbreviation of the "role" value for the given group.
|
||||
func (g ServerGroup) AsRoleAbbreviated() string {
|
||||
switch g {
|
||||
case ServerGroupSingle:
|
||||
return "sngl"
|
||||
|
|
|
@ -29,12 +29,21 @@ import (
|
|||
)
|
||||
|
||||
func TestServerGroupAsRole(t *testing.T) {
|
||||
assert.Equal(t, "sngl", ServerGroupSingle.AsRole())
|
||||
assert.Equal(t, "agnt", ServerGroupAgents.AsRole())
|
||||
assert.Equal(t, "prmr", ServerGroupDBServers.AsRole())
|
||||
assert.Equal(t, "crdn", ServerGroupCoordinators.AsRole())
|
||||
assert.Equal(t, "syma", ServerGroupSyncMasters.AsRole())
|
||||
assert.Equal(t, "sywo", ServerGroupSyncWorkers.AsRole())
|
||||
assert.Equal(t, "single", ServerGroupSingle.AsRole())
|
||||
assert.Equal(t, "agent", ServerGroupAgents.AsRole())
|
||||
assert.Equal(t, "dbserver", ServerGroupDBServers.AsRole())
|
||||
assert.Equal(t, "coordinator", ServerGroupCoordinators.AsRole())
|
||||
assert.Equal(t, "syncmaster", ServerGroupSyncMasters.AsRole())
|
||||
assert.Equal(t, "syncworker", ServerGroupSyncWorkers.AsRole())
|
||||
}
|
||||
|
||||
func TestServerGroupAsRoleAbbreviated(t *testing.T) {
|
||||
assert.Equal(t, "sngl", ServerGroupSingle.AsRoleAbbreviated())
|
||||
assert.Equal(t, "agnt", ServerGroupAgents.AsRoleAbbreviated())
|
||||
assert.Equal(t, "prmr", ServerGroupDBServers.AsRoleAbbreviated())
|
||||
assert.Equal(t, "crdn", ServerGroupCoordinators.AsRoleAbbreviated())
|
||||
assert.Equal(t, "syma", ServerGroupSyncMasters.AsRoleAbbreviated())
|
||||
assert.Equal(t, "sywo", ServerGroupSyncWorkers.AsRoleAbbreviated())
|
||||
}
|
||||
|
||||
func TestServerGroupIsArangod(t *testing.T) {
|
||||
|
|
|
@ -307,8 +307,9 @@ func (d *Deployment) ensurePods(apiObject *api.ArangoDeployment) error {
|
|||
}
|
||||
// Update pod name
|
||||
role := group.AsRole()
|
||||
roleAbbr := group.AsRoleAbbreviated()
|
||||
podSuffix := createPodSuffix(apiObject.Spec)
|
||||
m.PodName = k8sutil.CreatePodName(apiObject.GetName(), role, m.ID, podSuffix)
|
||||
m.PodName = k8sutil.CreatePodName(apiObject.GetName(), roleAbbr, m.ID, podSuffix)
|
||||
// Create pod
|
||||
if group.IsArangod() {
|
||||
// Find image ID
|
||||
|
|
|
@ -83,9 +83,9 @@ func CreateDatabaseClientService(kubecli kubernetes.Interface, deployment metav1
|
|||
}
|
||||
var role string
|
||||
if single {
|
||||
role = "sngl"
|
||||
role = "single"
|
||||
} else {
|
||||
role = "crdn"
|
||||
role = "coordinator"
|
||||
}
|
||||
publishNotReadyAddresses := true
|
||||
sessionAffinity := v1.ServiceAffinityClientIP
|
||||
|
|
Loading…
Reference in a new issue