Skip to content

Commit 5eaa54a

Browse files
author
lamai93
committed
Merge remote-tracking branch 'origin/master' into feature/arangodbexporter
2 parents 9218d81 + 90784a0 commit 5eaa54a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+1606
-41
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## [0.3.10](---) (XXXX-XX-XX)
44
- Added Pod Disruption Budgets for all server groups in production mode.
5+
- Added Priority Class Name to be specified per server group.
56

67
## [0.3.9](https://github.com/arangodb/kube-arangodb/tree/0.3.9) (2019-02-28)
78
[Full Changelog](https://github.com/arangodb/kube-arangodb/compare/0.3.8...0.3.9)

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ endif
256256

257257
.PHONY: manifests
258258
manifests: $(GOBUILDDIR)
259-
echo Building manifests
259+
@echo Building manifests
260260
GOPATH=$(GOBUILDDIR) go run $(ROOTDIR)/tools/manifests/manifest_builder.go \
261261
--output-suffix=$(MANIFESTSUFFIX) \
262262
--image=$(OPERATORIMAGE) \

docs/Manual/Deployment/Kubernetes/DeploymentResource.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,18 @@ This setting specifies the name of a kubernetes `Secret` that contains
342342
the license key token used for enterprise images. This value is not used for
343343
the community edition.
344344

345+
### `spec.bootstrap.passwordSecretNames.root: string`
346+
347+
This setting specifies a secret name for the credentials of the root user.
348+
349+
When a deployment is created the operator will setup the root user account
350+
according to the credentials given by the secret. If the secret doesn't exist
351+
the operator creates a secret with a random password.
352+
353+
There are two magic values for the secret name:
354+
- `None` specifies no action. This disables root password randomization. This is the default value. (Thus the root password is empty - not recommended)
355+
- `Auto` specifies automatic name generation, which is `<deploymentname>-root-password`.
356+
345357
### `spec.<group>.count: number`
346358

347359
This setting specifies the number of servers to start for the given group.
@@ -401,6 +413,18 @@ for each server of this group.
401413
This setting is not available for group `coordinators`, `syncmasters` & `syncworkers`
402414
because servers in these groups do not need persistent storage.
403415

416+
### `spec.<group>.priorityClassName: string`
417+
418+
Priority class name for pods of this group. Will be forwarded to the pod spec. [Kubernetes documentation](https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/)
419+
420+
### `spec.<group>.probes.livenessProbeDisabled: bool`
421+
422+
If set to true, the operator does not generate a liveness probe for new pods belonging to this group.
423+
424+
### `spec.<group>.probes.readinessProbeDisabled: bool`
425+
426+
If set to true, the operator does not generate a readiness probe for new pods belonging to this group.
427+
404428
### `spec.<group>.tolerations: []Toleration`
405429

406430
This setting specifies the `tolerations` for the `Pod`s created

docs/Manual/Tutorials/Kubernetes/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Starting an ArangoDB database (either single server or full blown cluster)
44
on Kubernetes involves a lot of resources.
55

6-
The servers needs to run in `Pods`, you need `Secrets` for authentication,
6+
The servers need to run in `Pods`, you need `Secrets` for authentication,
77
TLS certificates and `Services` to enable communication with the database.
88

99
Use `kube-arangodb`, the ArangoDB Kubernetes Operator to greatly simplify
@@ -76,7 +76,7 @@ new custom resource definition:
7676

7777
- `ArangoLocalStorage` is the resource used to provision `PersistentVolumes` on local storage.
7878

79-
The optioal fourth command installs a `Deployment` that runs the
79+
The optional fourth command installs a `Deployment` that runs the
8080
operator that takes care of DC2DC replications.
8181

8282
## Deploying your first ArangoDB database

examples/reboot-pod.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
kind: Pod
2+
apiVersion: v1
3+
metadata:
4+
name: kube-reboot-pod
5+
spec:
6+
restartPolicy: OnFailure
7+
serviceAccountName: default
8+
containers:
9+
- image: arangodb/kube-arangodb:0.3.10
10+
name: reboot
11+
command: ["arangodb_operator", "reboot"]
12+
args:
13+
- --deployment-name=my-rebooted-depl
14+
- --image-name=arangodb/arangodb:3.4.3
15+
- --license-secret-name=arangodb-license-key
16+
- --coordinators=3
17+
- pvc-5f98090b-4417-11e9-9423-42010aa401d7
18+
- pvc-60119ef4-4417-11e9-9423-42010aa401d7
19+
- pvc-60c8c3d8-4417-11e9-9423-42010aa401d7
20+
- pvc-6142d36a-4417-11e9-9423-42010aa401d7
21+
- pvc-61bce8a5-4417-11e9-9423-42010aa401d7
22+
- pvc-62928477-4417-11e9-9423-42010aa401d7
23+
- pvc-630c8f56-4417-11e9-9423-42010aa401d7
24+
- pvc-63680b68-4417-11e9-9423-42010aa401d7
25+
- pvc-63a52558-4417-11e9-9423-42010aa401d7
26+
- pvc-6400be5b-4417-11e9-9423-42010aa401d7
27+
env:
28+
- name: MY_POD_NAMESPACE
29+
valueFrom:
30+
fieldRef:
31+
fieldPath: metadata.namespace
32+
- name: MY_POD_NAME
33+
valueFrom:
34+
fieldRef:
35+
fieldPath: metadata.name

manifests/templates/test/rbac.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ rules:
1515
- apiGroups: ["apps"]
1616
resources: ["daemonsets", "deployments"]
1717
verbs: ["*"]
18+
- apiGroups: ["scheduling.k8s.io"]
19+
resources: ["priorityclasses"]
20+
verbs: ["*"]
1821

1922
---
2023

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
//
2+
// DISCLAIMER
3+
//
4+
// Copyright 2018 ArangoDB GmbH, Cologne, Germany
5+
//
6+
// Licensed under the Apache License, Version 2.0 (the "License");
7+
// you may not use this file except in compliance with the License.
8+
// You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing, software
13+
// distributed under the License is distributed on an "AS IS" BASIS,
14+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
// See the License for the specific language governing permissions and
16+
// limitations under the License.
17+
//
18+
// Copyright holder is ArangoDB GmbH, Cologne, Germany
19+
//
20+
21+
package v1alpha
22+
23+
import (
24+
"fmt"
25+
26+
"github.com/arangodb/kube-arangodb/pkg/util/k8sutil"
27+
)
28+
29+
const (
30+
// UserNameRoot root user name
31+
UserNameRoot = "root"
32+
)
33+
34+
// PasswordSecretName contains user password secret name
35+
type PasswordSecretName string
36+
37+
const (
38+
// PasswordSecretNameNone is magic value for no action
39+
PasswordSecretNameNone PasswordSecretName = "None"
40+
// PasswordSecretNameAuto is magic value for autogenerate name
41+
PasswordSecretNameAuto PasswordSecretName = "Auto"
42+
)
43+
44+
// PasswordSecretNameList is a map from username to secretnames
45+
type PasswordSecretNameList map[string]PasswordSecretName
46+
47+
// BootstrapSpec contains information for cluster bootstrapping
48+
type BootstrapSpec struct {
49+
// PasswordSecretNames contains a map of username to password-secret-name
50+
PasswordSecretNames PasswordSecretNameList `json:"passwordSecretNames,omitempty"`
51+
}
52+
53+
// IsNone returns true if p is None or p is empty
54+
func (p PasswordSecretName) IsNone() bool {
55+
return p == PasswordSecretNameNone || p == ""
56+
}
57+
58+
// IsAuto returns true if p is Auto
59+
func (p PasswordSecretName) IsAuto() bool {
60+
return p == PasswordSecretNameAuto
61+
}
62+
63+
// GetSecretName returns the secret name given by the specs. Or None if not set.
64+
func (s PasswordSecretNameList) GetSecretName(user string) PasswordSecretName {
65+
if s != nil {
66+
if secretname, ok := s[user]; ok {
67+
return secretname
68+
}
69+
}
70+
return PasswordSecretNameNone
71+
}
72+
73+
// getSecretNameForUserPassword returns the default secret name for the given user
74+
func getSecretNameForUserPassword(deploymentname, username string) PasswordSecretName {
75+
return PasswordSecretName(k8sutil.FixupResourceName(deploymentname + "-" + username + "-password"))
76+
}
77+
78+
// Validate the specification.
79+
func (b *BootstrapSpec) Validate() error {
80+
for username, secretname := range b.PasswordSecretNames {
81+
// Remove this restriction as soon as we can bootstrap databases
82+
if username != UserNameRoot {
83+
return fmt.Errorf("only username `root` allowed in passwordSecretNames")
84+
}
85+
86+
if secretname.IsNone() {
87+
if username != UserNameRoot {
88+
return fmt.Errorf("magic value None not allowed for %s", username)
89+
}
90+
} else {
91+
if err := k8sutil.ValidateResourceName(string(secretname)); err != nil {
92+
return maskAny(err)
93+
}
94+
}
95+
}
96+
97+
return nil
98+
}
99+
100+
// SetDefaults fills in default values when a field is not specified.
101+
func (b *BootstrapSpec) SetDefaults(deploymentname string) {
102+
if b.PasswordSecretNames == nil {
103+
b.PasswordSecretNames = make(map[string]PasswordSecretName)
104+
}
105+
106+
// If root is not set init with Auto
107+
if _, ok := b.PasswordSecretNames[UserNameRoot]; !ok {
108+
b.PasswordSecretNames[UserNameRoot] = PasswordSecretNameNone
109+
}
110+
111+
// Replace Auto with generated secret name
112+
for user, secretname := range b.PasswordSecretNames {
113+
if secretname.IsAuto() {
114+
b.PasswordSecretNames[user] = getSecretNameForUserPassword(deploymentname, user)
115+
}
116+
}
117+
}
118+
119+
// NewPasswordSecretNameListOrNil returns nil if input is nil, otherwise returns a clone of the given value.
120+
func NewPasswordSecretNameListOrNil(list PasswordSecretNameList) PasswordSecretNameList {
121+
if list == nil {
122+
return nil
123+
}
124+
var newList = make(PasswordSecretNameList)
125+
for k, v := range list {
126+
newList[k] = v
127+
}
128+
return newList
129+
}
130+
131+
// SetDefaultsFrom fills unspecified fields with a value from given source spec.
132+
func (b *BootstrapSpec) SetDefaultsFrom(source BootstrapSpec) {
133+
if b.PasswordSecretNames == nil {
134+
b.PasswordSecretNames = NewPasswordSecretNameListOrNil(source.PasswordSecretNames)
135+
}
136+
}

pkg/apis/deployment/v1alpha/conditions.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ const (
5353
ConditionTypeSecretsChanged ConditionType = "SecretsChanged"
5454
// ConditionTypeMemberOfCluster indicates that the member is a known member of the ArangoDB cluster.
5555
ConditionTypeMemberOfCluster ConditionType = "MemberOfCluster"
56+
// ConditionTypeBootstrapCompleted indicates that the initial cluster bootstrap has been completed.
57+
ConditionTypeBootstrapCompleted ConditionType = "BootstrapCompleted"
58+
// ConditionTypeBootstrapSucceded indicates that the initial cluster bootstrap completed successfully.
59+
ConditionTypeBootstrapSucceded ConditionType = "BootstrapSucceded"
5660
// ConditionTypeTerminating indicates that the member is terminating but not yet terminated.
5761
ConditionTypeTerminating ConditionType = "Terminating"
5862
)

pkg/apis/deployment/v1alpha/deployment_spec.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ type DeploymentSpec struct {
7171
SyncWorkers ServerGroupSpec `json:"syncworkers"`
7272

7373
Chaos ChaosSpec `json:"chaos"`
74+
75+
Bootstrap BootstrapSpec `json:"bootstrap",omitempty`
7476
}
7577

7678
// Equal compares two DeploymentSpec
@@ -190,6 +192,7 @@ func (s *DeploymentSpec) SetDefaults(deploymentName string) {
190192
s.SyncWorkers.SetDefaults(ServerGroupSyncWorkers, s.Sync.IsEnabled(), s.GetMode())
191193
s.Metrics.SetDefaults(deploymentName+"-exporter-jwt-token", s.Authentication.IsAuthenticated())
192194
s.Chaos.SetDefaults()
195+
s.Bootstrap.SetDefaults(deploymentName)
193196
}
194197

195198
// SetDefaultsFrom fills unspecified fields with a value from given source spec.
@@ -229,6 +232,7 @@ func (s *DeploymentSpec) SetDefaultsFrom(source DeploymentSpec) {
229232
s.SyncWorkers.SetDefaultsFrom(source.SyncWorkers)
230233
s.Metrics.SetDefaultsFrom(source.Metrics)
231234
s.Chaos.SetDefaultsFrom(source.Chaos)
235+
s.Bootstrap.SetDefaultsFrom(source.Bootstrap)
232236
}
233237

234238
// Validate the specification.
@@ -291,6 +295,9 @@ func (s *DeploymentSpec) Validate() error {
291295
if err := s.License.Validate(); err != nil {
292296
return maskAny(errors.Wrap(err, "spec.licenseKey"))
293297
}
298+
if err := s.Bootstrap.Validate(); err != nil {
299+
return maskAny(err)
300+
}
294301
return nil
295302
}
296303

pkg/apis/deployment/v1alpha/deployment_status_members.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,3 +243,23 @@ func (ds DeploymentStatusMembers) AllMembersReady(mode DeploymentMode, syncEnabl
243243
return false
244244
}
245245
}
246+
247+
// MembersOfGroup returns the member list of the given group
248+
func (ds DeploymentStatusMembers) MembersOfGroup(group ServerGroup) MemberStatusList {
249+
switch group {
250+
case ServerGroupSingle:
251+
return ds.Single
252+
case ServerGroupAgents:
253+
return ds.Agents
254+
case ServerGroupDBServers:
255+
return ds.DBServers
256+
case ServerGroupCoordinators:
257+
return ds.Coordinators
258+
case ServerGroupSyncMasters:
259+
return ds.SyncMasters
260+
case ServerGroupSyncWorkers:
261+
return ds.SyncWorkers
262+
default:
263+
return MemberStatusList{}
264+
}
265+
}

0 commit comments

Comments
 (0)