Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Add ArangoJob and Apps Operator
- Use Go 1.17
- Add metrics for the plan actions
- Add ArangoClusterSynchronization Operator

## [1.2.6](https://github.com/arangodb/kube-arangodb/tree/1.2.6) (2021-12-15)
- Add ArangoBackup backoff functionality
Expand Down
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ MANIFESTPATHDEPLOYMENT := manifests/arango-deployment$(MANIFESTSUFFIX).yaml
MANIFESTPATHDEPLOYMENTREPLICATION := manifests/arango-deployment-replication$(MANIFESTSUFFIX).yaml
MANIFESTPATHBACKUP := manifests/arango-backup$(MANIFESTSUFFIX).yaml
MANIFESTPATHAPPS := manifests/arango-apps$(MANIFESTSUFFIX).yaml
MANIFESTPATHK2KCLUSTERSYNC := manifests/arango-k2kclustersync$(MANIFESTSUFFIX).yaml
MANIFESTPATHSTORAGE := manifests/arango-storage$(MANIFESTSUFFIX).yaml
MANIFESTPATHALL := manifests/arango-all$(MANIFESTSUFFIX).yaml
MANIFESTPATHTEST := manifests/arango-test$(MANIFESTSUFFIX).yaml
Expand All @@ -106,6 +107,7 @@ KUSTOMIZEPATHDEPLOYMENT := manifests/kustomize/deployment/arango-deployment$(MAN
KUSTOMIZEPATHDEPLOYMENTREPLICATION := manifests/kustomize/deployment-replication/arango-deployment-replication$(MANIFESTSUFFIX).yaml
KUSTOMIZEPATHBACKUP := manifests/kustomize/backup/arango-backup$(MANIFESTSUFFIX).yaml
KUSTOMIZEPATHAPPS := manifests/kustomize/apps/arango-apps$(MANIFESTSUFFIX).yaml
KUSTOMIZEPATHK2KCLUSTERSYNC := manifests/kustomize/apps/arango-k2kclustersync$(MANIFESTSUFFIX).yaml
KUSTOMIZEPATHSTORAGE := manifests/kustomize/storage/arango-storage$(MANIFESTSUFFIX).yaml
KUSTOMIZEPATHALL := manifests/kustomize/all/arango-all$(MANIFESTSUFFIX).yaml
KUSTOMIZEPATHTEST := manifests/kustomize/test/arango-test$(MANIFESTSUFFIX).yaml
Expand Down Expand Up @@ -333,41 +335,55 @@ $(eval $(call manifest-generator, deployment, kube-arangodb, \
--set "operator.features.deploymentReplications=false" \
--set "operator.features.storage=false" \
--set "operator.features.apps=false" \
--set "operator.features.k8sToK8sClusterSync=false" \
--set "operator.features.backup=false"))

$(eval $(call manifest-generator, deployment-replication, kube-arangodb, \
--set "operator.features.deployment=false" \
--set "operator.features.deploymentReplications=true" \
--set "operator.features.storage=false" \
--set "operator.features.apps=false" \
--set "operator.features.k8sToK8sClusterSync=false" \
--set "operator.features.backup=false"))

$(eval $(call manifest-generator, storage, kube-arangodb, \
--set "operator.features.deployment=false" \
--set "operator.features.deploymentReplications=false" \
--set "operator.features.storage=true" \
--set "operator.features.apps=false" \
--set "operator.features.k8sToK8sClusterSync=false" \
--set "operator.features.backup=false"))

$(eval $(call manifest-generator, backup, kube-arangodb, \
--set "operator.features.deployment=false" \
--set "operator.features.deploymentReplications=false" \
--set "operator.features.storage=false" \
--set "operator.features.apps=false" \
--set "operator.features.k8sToK8sClusterSync=false" \
--set "operator.features.backup=true"))

$(eval $(call manifest-generator, apps, kube-arangodb, \
--set "operator.features.deployment=false" \
--set "operator.features.deploymentReplications=false" \
--set "operator.features.storage=false" \
--set "operator.features.apps=true" \
--set "operator.features.k8sToK8sClusterSync=false" \
--set "operator.features.backup=false"))

$(eval $(call manifest-generator, k2kclustersync, kube-arangodb, \
--set "operator.features.deployment=false" \
--set "operator.features.deploymentReplications=false" \
--set "operator.features.storage=false" \
--set "operator.features.apps=false" \
--set "operator.features.k8sToK8sClusterSync=true" \
--set "operator.features.backup=false"))

$(eval $(call manifest-generator, all, kube-arangodb, \
--set "operator.features.deployment=true" \
--set "operator.features.deploymentReplications=true" \
--set "operator.features.storage=true" \
--set "operator.features.apps=true" \
--set "operator.features.k8sToK8sClusterSync=true" \
--set "operator.features.backup=true"))

.PHONY: chart-crd
Expand Down
39 changes: 39 additions & 0 deletions chart/kube-arangodb-crd/templates/k2kclustersync.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: arangoclustersynchronizations.database.arangodb.com
labels:
app.kubernetes.io/name: {{ template "kube-arangodb-crd.name" . }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
release: {{ .Release.Name }}
spec:
group: database.arangodb.com
names:
kind: ArangoClusterSynchronization
listKind: ArangoClusterSynchronizationList
plural: arangoclustersynchronizations
singular: arangoclustersynchronization
shortNames:
- arangoclustersync
scope: Namespaced
versions:
- name: v1
schema:
openAPIV3Schema:
type: object
x-kubernetes-preserve-unknown-fields: true
served: true
storage: true
subresources:
status: {}
- name: v2alpha1
schema:
openAPIV3Schema:
type: object
x-kubernetes-preserve-unknown-fields: true
served: true
storage: false
subresources:
status: {}
32 changes: 19 additions & 13 deletions chart/kube-arangodb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,20 @@ Possible Operators:
- `ArangoDeployment` - enabled by default
- `ArangoDeploymentReplications` - enabled by default
- `ArangoLocalStorage` - disabled by default
- `ArangoBackup` - disabled by default
- `ArangoJob` - disabled by default
- `ArangoClusterSynchronization` - disabled by default

To install Operators in mode "One per Helm Release" we can use:

```
helm install --name arango-deployment kube-arangodb.tar.gz \
--set operator.features.deployment=true \
--set operator.features.deploymentReplications=false \
--set operator.features.storage=false


helm install --name arango-deployment-replications kube-arangodb.tar.gz \
--set operator.features.deployment=false \
--set operator.features.deploymentReplications=true \
--set operator.features.storage=false


helm install --name arango-storage kube-arangodb.tar.gz \
--set operator.features.deployment=false \
--set operator.features.deploymentReplications=false \
--set operator.features.storage=true
--set operator.features.storage=false \
--set operator.features.backup=false \
--set operator.features.apps=false \
--set operator.features.k8sToK8sClusterSync=false
```


Expand Down Expand Up @@ -155,6 +149,18 @@ Define if ArangoBackup Operator should be enabled.

Default: `false`

### `operator.features.apps`

Define if ArangoJob Operator should be enabled.

Default: `false`

### `operator.features.k8sToK8sClusterSync`

Define if ArangoClusterSynchronization Operator should be enabled.

Default: `false`

### `rbac.enabled`

Define if RBAC should be enabled.
Expand Down
3 changes: 3 additions & 0 deletions chart/kube-arangodb/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ spec:
{{- end }}
{{ if .Values.operator.features.apps }}
- --operator.apps
{{- end }}
{{ if .Values.operator.features.k8sToK8sClusterSync }}
- --operator.k2k-cluster-sync
{{- end }}
- --chaos.allowed={{ .Values.operator.allowChaos }}
{{- if .Values.operator.args }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{{ if .Values.rbac.enabled -}}
{{ if not (eq .Values.operator.scope "namespaced") -}}
{{ if .Values.operator.features.k8sToK8sClusterSync -}}

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ template "kube-arangodb.rbac-cluster" . }}-k2kclustersync
labels:
app.kubernetes.io/name: {{ template "kube-arangodb.name" . }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
release: {{ .Release.Name }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ template "kube-arangodb.rbac-cluster" . }}-k2kclustersync
subjects:
- kind: ServiceAccount
name: {{ template "kube-arangodb.operatorName" . }}
namespace: {{ .Release.Namespace }}

{{- end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{{ if .Values.rbac.enabled -}}
{{ if not (eq .Values.operator.scope "namespaced") -}}
{{ if .Values.operator.features.k8sToK8sClusterSync -}}

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ template "kube-arangodb.rbac-cluster" . }}-k2kclustersync
labels:
app.kubernetes.io/name: {{ template "kube-arangodb.name" . }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
release: {{ .Release.Name }}
rules:
- apiGroups: ["apiextensions.k8s.io"]
resources: ["customresourcedefinitions"]
verbs: ["get", "list", "watch"]

{{- end }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{{ if .Values.rbac.enabled -}}
{{ if .Values.operator.features.k8sToK8sClusterSync -}}

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ template "kube-arangodb.rbac" . }}-k2kclustersync
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ template "kube-arangodb.name" . }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
release: {{ .Release.Name }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ template "kube-arangodb.rbac" . }}-k2kclustersync
subjects:
- kind: ServiceAccount
name: {{ template "kube-arangodb.operatorName" . }}
namespace: {{ .Release.Namespace }}

{{- end }}
{{- end }}
33 changes: 33 additions & 0 deletions chart/kube-arangodb/templates/k2k-cluster-sync-operator/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{{ if .Values.rbac.enabled -}}
{{ if .Values.operator.features.k8sToK8sClusterSync -}}

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ template "kube-arangodb.rbac" . }}-k2kclustersync
namespace: {{ .Release.Namespace }}
labels:
app.kubernetes.io/name: {{ template "kube-arangodb.name" . }}
helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
release: {{ .Release.Name }}
rules:
- apiGroups: [""]
resources: ["pods", "services", "endpoints"]
verbs: ["get", "update"]
- apiGroups: [""]
resources: ["events"]
verbs: ["*"]
- apiGroups: [""]
resources: ["secrets"]
verbs: ["get"]
- apiGroups: ["apps"]
resources: ["deployments", "replicasets"]
verbs: ["get"]
- apiGroups: ["database.arangodb.com"]
resources: ["arangodeployments", "arangoclustersynchronizations"]
verbs: ["get", "list", "watch"]

{{- end }}
{{- end }}
1 change: 1 addition & 0 deletions chart/kube-arangodb/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ operator:
storage: false
backup: false
apps: false
k8sToK8sClusterSync: false

images:
base: alpine:3.11
Expand Down
16 changes: 13 additions & 3 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ var (
enableBackup bool // Run backup operator
enableApps bool // Run apps operator
versionOnly bool // Run only version endpoint, explicitly disabled with other
enableK2KClusterSync bool // Run k2kClusterSync operator

scalingIntegrationEnabled bool

Expand Down Expand Up @@ -141,6 +142,7 @@ var (
storageProbe probe.ReadyProbe
backupProbe probe.ReadyProbe
appsProbe probe.ReadyProbe
k2KClusterSyncProbe probe.ReadyProbe
)

func init() {
Expand All @@ -157,6 +159,7 @@ func init() {
f.BoolVar(&operatorOptions.enableStorage, "operator.storage", false, "Enable to run the ArangoLocalStorage operator")
f.BoolVar(&operatorOptions.enableBackup, "operator.backup", false, "Enable to run the ArangoBackup operator")
f.BoolVar(&operatorOptions.enableApps, "operator.apps", false, "Enable to run the ArangoApps operator")
f.BoolVar(&operatorOptions.enableK2KClusterSync, "operator.k2k-cluster-sync", false, "Enable to run the ArangoClusterSynchronizations operator")
f.BoolVar(&operatorOptions.versionOnly, "operator.version", false, "Enable only version endpoint in Operator")
f.StringVar(&operatorOptions.alpineImage, "operator.alpine-image", UBIImageEnv.GetOrDefault(defaultAlpineImage), "Docker image used for alpine containers")
f.MarkDeprecated("operator.alpine-image", "Value is not used anymore")
Expand Down Expand Up @@ -225,12 +228,13 @@ func executeMain(cmd *cobra.Command, args []string) {
klog.Flush()

// Check operating mode
if !operatorOptions.enableDeployment && !operatorOptions.enableDeploymentReplication && !operatorOptions.enableStorage && !operatorOptions.enableBackup && !operatorOptions.enableApps {
if !operatorOptions.enableDeployment && !operatorOptions.enableDeploymentReplication && !operatorOptions.enableStorage &&
!operatorOptions.enableBackup && !operatorOptions.enableApps && !operatorOptions.enableK2KClusterSync {
if !operatorOptions.versionOnly {
cliLog.Fatal().Err(err).Msg("Turn on --operator.deployment, --operator.deployment-replication, --operator.storage, --operator.backup, --operator.apps or any combination of these")
cliLog.Fatal().Err(err).Msg("Turn on --operator.deployment, --operator.deployment-replication, --operator.storage, --operator.backup, --operator.apps, --operator.k2k-cluster-sync or any combination of these")
}
} else if operatorOptions.versionOnly {
cliLog.Fatal().Err(err).Msg("Options --operator.deployment, --operator.deployment-replication, --operator.storage, --operator.backup, --operator.apps cannot be enabled together with --operator.version")
cliLog.Fatal().Err(err).Msg("Options --operator.deployment, --operator.deployment-replication, --operator.storage, --operator.backup, --operator.apps, --operator.k2k-cluster-sync cannot be enabled together with --operator.version")
}

// Log version
Expand Down Expand Up @@ -307,6 +311,10 @@ func executeMain(cmd *cobra.Command, args []string) {
Enabled: cfg.EnableApps,
Probe: &appsProbe,
},
ClusterSync: server.OperatorDependency{
Enabled: cfg.EnableK2KClusterSync,
Probe: &k2KClusterSyncProbe,
},
Operators: o,

Secrets: secrets,
Expand Down Expand Up @@ -394,6 +402,7 @@ func newOperatorConfigAndDeps(id, namespace, name string) (operator.Config, oper
EnableStorage: operatorOptions.enableStorage,
EnableBackup: operatorOptions.enableBackup,
EnableApps: operatorOptions.enableApps,
EnableK2KClusterSync: operatorOptions.enableK2KClusterSync,
AllowChaos: chaosOptions.allowed,
ScalingIntegrationEnabled: operatorOptions.scalingIntegrationEnabled,
ArangoImage: operatorOptions.arangoImage,
Expand All @@ -413,6 +422,7 @@ func newOperatorConfigAndDeps(id, namespace, name string) (operator.Config, oper
StorageProbe: &storageProbe,
BackupProbe: &backupProbe,
AppsProbe: &appsProbe,
K2KClusterSyncProbe: &k2KClusterSyncProbe,
}

return cfg, deps, nil
Expand Down
5 changes: 5 additions & 0 deletions examples/arangoclustersync.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: database.arangodb.com/v1
kind: ArangoClusterSynchronization
metadata:
name: arangoclustersync-sample
spec:
5 changes: 5 additions & 0 deletions manifests/kustomize/k2kclustersync/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- arango-k2kclustersync.yaml
3 changes: 2 additions & 1 deletion pkg/apis/deployment/definitions.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ const (
)

var (
ArangoDeploymentShortNames = []string{"arangodb", "arango"}
ArangoDeploymentShortNames = []string{"arangodb", "arango"}
ArangoClusterSynchronizationShortNames = []string{"arangoclustersync"}
)
2 changes: 2 additions & 0 deletions pkg/apis/deployment/v1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ func addKnownTypes(s *runtime.Scheme) error {
&ArangoDeploymentList{},
&ArangoMember{},
&ArangoMemberList{},
&ArangoClusterSynchronization{},
&ArangoClusterSynchronizationList{},
)
metav1.AddToGroupVersion(s, SchemeGroupVersion)
return nil
Expand Down
Loading