Skip to content

Commit 115d03f

Browse files
authored
Allow to set annotations (#499)
1 parent ba3a309 commit 115d03f

File tree

18 files changed

+1243
-39
lines changed

18 files changed

+1243
-39
lines changed

chart/kube-arangodb/templates/deployment-operator/role.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ rules:
1717
resources: ["arangodeployments"]
1818
verbs: ["*"]
1919
- apiGroups: [""]
20-
resources: ["pods", "services", "endpoints", "persistentvolumeclaims", "events", "secrets"]
20+
resources: ["pods", "services", "endpoints", "persistentvolumeclaims", "events", "secrets", "serviceaccounts"]
2121
verbs: ["*"]
2222
- apiGroups: ["apps"]
2323
resources: ["deployments", "replicasets"]
2424
verbs: ["get"]
2525
- apiGroups: ["policy"]
2626
resources: ["poddisruptionbudgets"]
27-
verbs: ["get", "create", "delete"]
27+
verbs: ["*"]
2828
- apiGroups: ["backup.arangodb.com"]
2929
resources: ["arangobackuppolicies", "arangobackups"]
3030
verbs: ["get", "list", "watch"]

docs/Manual/Deployment/Kubernetes/DeploymentResource.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ Possible values are:
100100

101101
This setting specifies the list of image pull secrets for the docker image to use for all ArangoDB servers.
102102

103+
### `spec.annotations: map[string]string`
104+
105+
This setting set specified annotations to all ArangoDeployment owned resources (pods, services, PVC's, PDB's).
106+
103107
### `spec.storageEngine: string`
104108

105109
This setting specifies the type of storage engine used for all servers
@@ -517,6 +521,10 @@ rules:
517521
If you are using a different service account, please grant these rights
518522
to that service account.
519523

524+
### `spec.<group>.annotations: map[string]string`
525+
526+
This setting set annotations overrides for pods in this group. Annotations are merged with `spec.annotations`.
527+
520528
### `spec.<group>.priorityClassName: string`
521529

522530
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/)

pkg/apis/backup/v1/backup_policy.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ func (a *ArangoBackupPolicy) NewBackup(d *deployment.ArangoDeployment) *ArangoBa
7070
Name: fmt.Sprintf("%s-%s", d.Name, utils.RandomString(8)),
7171
Namespace: a.Namespace,
7272

73-
Labels: d.Labels,
73+
Labels: d.Labels,
74+
Annotations: d.Annotations,
7475

7576
Finalizers: []string{
7677
FinalizerArangoBackup,

pkg/apis/backup/v1alpha/backup_policy.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ func (a *ArangoBackupPolicy) NewBackup(d *deployment.ArangoDeployment) *ArangoBa
7070
Name: fmt.Sprintf("%s-%s", d.Name, utils.RandomString(8)),
7171
Namespace: a.Namespace,
7272

73-
Labels: d.Labels,
73+
Labels: d.Labels,
74+
Annotations: d.Annotations,
7475

7576
Finalizers: []string{
7677
FinalizerArangoBackup,

pkg/apis/deployment/v1/deployment_spec.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,12 @@ type DeploymentSpec struct {
5656
DowntimeAllowed *bool `json:"downtimeAllowed,omitempty"`
5757
DisableIPv6 *bool `json:"disableIPv6,omitempty"`
5858

59-
NetworkAttachedVolumes *bool `json:"networkAttachedVolumes,omitempty"`
59+
NetworkAttachedVolumes *bool `json:"networkAttachedVolumes,omitempty"`
6060

61-
RestoreFrom *string `json:"restoreFrom,omitempty"`
61+
// Annotations specified the annotations added to all resources
62+
Annotations map[string]string `json:"annotations,omitempty"`
63+
64+
RestoreFrom *string `json:"restoreFrom,omitempty"`
6265

6366
ExternalAccess ExternalAccessSpec `json:"externalAccess"`
6467
RocksDB RocksDBSpec `json:"rocksdb"`
@@ -105,6 +108,11 @@ func (s DeploymentSpec) GetEnvironment() Environment {
105108
return EnvironmentOrDefault(s.Environment)
106109
}
107110

111+
// GetAnnotations returns the annotations of this group
112+
func (s DeploymentSpec) GetAnnotations() map[string]string {
113+
return s.Annotations
114+
}
115+
108116
// GetStorageEngine returns the value of storageEngine.
109117
func (s DeploymentSpec) GetStorageEngine() StorageEngine {
110118
return StorageEngineOrDefault(s.StorageEngine)

pkg/apis/deployment/v1/server_group.go

Lines changed: 68 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,32 @@
2222

2323
package v1
2424

25-
import time "time"
25+
import "time"
2626

2727
type ServerGroup int
2828

2929
const (
30+
ServerGroupUnknown ServerGroup = 0
3031
ServerGroupSingle ServerGroup = 1
3132
ServerGroupAgents ServerGroup = 2
3233
ServerGroupDBServers ServerGroup = 3
3334
ServerGroupCoordinators ServerGroup = 4
3435
ServerGroupSyncMasters ServerGroup = 5
3536
ServerGroupSyncWorkers ServerGroup = 6
37+
38+
ServerGroupSingleString = "single"
39+
ServerGroupAgentsString = "agent"
40+
ServerGroupDBServersString = "dbserver"
41+
ServerGroupCoordinatorsString = "coordinator"
42+
ServerGroupSyncMastersString = "syncmaster"
43+
ServerGroupSyncWorkersString = "syncworker"
44+
45+
ServerGroupSingleAbbreviatedString = "sngl"
46+
ServerGroupAgentsAbbreviatedString = "agnt"
47+
ServerGroupDBServersAbbreviatedString = "prmr"
48+
ServerGroupCoordinatorsAbbreviatedString = "crdn"
49+
ServerGroupSyncMastersAbbreviatedString = "syma"
50+
ServerGroupSyncWorkersAbbreviatedString = "sywo"
3651
)
3752

3853
var (
@@ -51,17 +66,17 @@ var (
5166
func (g ServerGroup) AsRole() string {
5267
switch g {
5368
case ServerGroupSingle:
54-
return "single"
69+
return ServerGroupSingleString
5570
case ServerGroupAgents:
56-
return "agent"
71+
return ServerGroupAgentsString
5772
case ServerGroupDBServers:
58-
return "dbserver"
73+
return ServerGroupDBServersString
5974
case ServerGroupCoordinators:
60-
return "coordinator"
75+
return ServerGroupCoordinatorsString
6176
case ServerGroupSyncMasters:
62-
return "syncmaster"
77+
return ServerGroupSyncMastersString
6378
case ServerGroupSyncWorkers:
64-
return "syncworker"
79+
return ServerGroupSyncWorkersString
6580
default:
6681
return "?"
6782
}
@@ -71,17 +86,17 @@ func (g ServerGroup) AsRole() string {
7186
func (g ServerGroup) AsRoleAbbreviated() string {
7287
switch g {
7388
case ServerGroupSingle:
74-
return "sngl"
89+
return ServerGroupSingleAbbreviatedString
7590
case ServerGroupAgents:
76-
return "agnt"
91+
return ServerGroupAgentsAbbreviatedString
7792
case ServerGroupDBServers:
78-
return "prmr"
93+
return ServerGroupDBServersAbbreviatedString
7994
case ServerGroupCoordinators:
80-
return "crdn"
95+
return ServerGroupCoordinatorsAbbreviatedString
8196
case ServerGroupSyncMasters:
82-
return "syma"
97+
return ServerGroupSyncMastersAbbreviatedString
8398
case ServerGroupSyncWorkers:
84-
return "sywo"
99+
return ServerGroupSyncWorkersAbbreviatedString
85100
default:
86101
return "?"
87102
}
@@ -140,3 +155,43 @@ func (g ServerGroup) IsExportMetrics() bool {
140155
return false
141156
}
142157
}
158+
159+
// ServerGroupFromAbbreviatedRole returns ServerGroup from abbreviated role
160+
func ServerGroupFromAbbreviatedRole(label string) ServerGroup {
161+
switch label {
162+
case ServerGroupSingleAbbreviatedString:
163+
return ServerGroupSingle
164+
case ServerGroupAgentsAbbreviatedString:
165+
return ServerGroupAgents
166+
case ServerGroupDBServersAbbreviatedString:
167+
return ServerGroupDBServers
168+
case ServerGroupCoordinatorsAbbreviatedString:
169+
return ServerGroupCoordinators
170+
case ServerGroupSyncMastersAbbreviatedString:
171+
return ServerGroupSyncMasters
172+
case ServerGroupSyncWorkersAbbreviatedString:
173+
return ServerGroupSyncWorkers
174+
default:
175+
return ServerGroupUnknown
176+
}
177+
}
178+
179+
// ServerGroupFromAbbreviatedRole returns ServerGroup from role
180+
func ServerGroupFromRole(label string) ServerGroup {
181+
switch label {
182+
case ServerGroupSingleString:
183+
return ServerGroupSingle
184+
case ServerGroupAgentsString:
185+
return ServerGroupAgents
186+
case ServerGroupDBServersString:
187+
return ServerGroupDBServers
188+
case ServerGroupCoordinatorsString:
189+
return ServerGroupCoordinators
190+
case ServerGroupSyncMastersString:
191+
return ServerGroupSyncMasters
192+
case ServerGroupSyncWorkersString:
193+
return ServerGroupSyncWorkers
194+
default:
195+
return ServerGroupUnknown
196+
}
197+
}

pkg/apis/deployment/v1/server_group_spec.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ type ServerGroupSpec struct {
5252
Resources v1.ResourceRequirements `json:"resources,omitempty"`
5353
// Tolerations specifies the tolerations added to Pods in this group.
5454
Tolerations []v1.Toleration `json:"tolerations,omitempty"`
55+
// Annotations specified the annotations added to Pods in this group.
56+
Annotations map[string]string `json:"annotations,omitempty"`
5557
// ServiceAccountName specifies the name of the service account used for Pods in this group.
5658
ServiceAccountName *string `json:"serviceAccountName,omitempty"`
5759
// NodeSelector speficies a set of selectors for nodes
@@ -133,6 +135,11 @@ func (s ServerGroupSpec) GetNodeSelector() map[string]string {
133135
return s.NodeSelector
134136
}
135137

138+
// GetAnnotations returns the annotations of this group
139+
func (s ServerGroupSpec) GetAnnotations() map[string]string {
140+
return s.Annotations
141+
}
142+
136143
// GetArgs returns the value of args.
137144
func (s ServerGroupSpec) GetArgs() []string {
138145
return s.Args

pkg/apis/deployment/v1/zz_generated.deepcopy.go

Lines changed: 20 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/apis/deployment/v1alpha/deployment_spec.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,12 @@ type DeploymentSpec struct {
5656
DowntimeAllowed *bool `json:"downtimeAllowed,omitempty"`
5757
DisableIPv6 *bool `json:"disableIPv6,omitempty"`
5858

59-
NetworkAttachedVolumes *bool `json:"networkAttachedVolumes,omitempty"`
59+
NetworkAttachedVolumes *bool `json:"networkAttachedVolumes,omitempty"`
6060

61-
RestoreFrom *string `json:"restoreFrom,omitempty"`
61+
// Annotations specified the annotations added to Pods in this group.
62+
Annotations map[string]string `json:"annotations,omitempty"`
63+
64+
RestoreFrom *string `json:"restoreFrom,omitempty"`
6265

6366
ExternalAccess ExternalAccessSpec `json:"externalAccess"`
6467
RocksDB RocksDBSpec `json:"rocksdb"`
@@ -105,6 +108,11 @@ func (s DeploymentSpec) GetEnvironment() Environment {
105108
return EnvironmentOrDefault(s.Environment)
106109
}
107110

111+
// GetAnnotations returns the annotations of this group
112+
func (s DeploymentSpec) GetAnnotations() map[string]string {
113+
return s.Annotations
114+
}
115+
108116
// GetStorageEngine returns the value of storageEngine.
109117
func (s DeploymentSpec) GetStorageEngine() StorageEngine {
110118
return StorageEngineOrDefault(s.StorageEngine)

0 commit comments

Comments
 (0)