1
0
Fork 0
mirror of https://github.com/arangodb/kube-arangodb.git synced 2024-12-14 11:57:37 +00:00

Merge branch 'master' into feature/sync-reconciliation

This commit is contained in:
Ewout Prangsma 2018-05-31 09:38:02 +02:00
commit 15e6c52922
No known key found for this signature in database
GPG key ID: 4DBAD380D93D0698
3 changed files with 200 additions and 0 deletions

View file

@ -0,0 +1,110 @@
# ArangoDeploymentReplication Custom Resource
The ArangoDB Replication Operator creates and maintains ArangoDB
`arangosync` configurations in a Kubernetes cluster, given a replication specification.
This replication specification is a `CustomResource` following
a `CustomResourceDefinition` created by the operator.
Example minimal replication definition:
```yaml
apiVersion: "replication.database.arangodb.com/v1alpha"
kind: "ArangoDeploymentReplication"
metadata:
name: "replication-from-a-to-b"
spec:
source:
deploymentName: cluster-a
destination:
deploymentName: cluster-b
auth:
clientAuthSecretName: client-auth-cert
```
This definition results in:
- the arangosync `SyncMaster` in deployment `cluster-b` is called to configure a synchronization
from `cluster-a` to `cluster-b`, using the client authentication certificate stored in
`Secret` `client-auth-cert`.
## Specification reference
Below you'll find all settings of the `ArangoDeploymentReplication` custom resource.
### `spec.source.deploymentName: string`
This setting specifies the name of an `ArangoDeployment` resource that runs a cluster
with sync enabled.
This cluster configured as the replication source.
### `spec.source.deploymentNamespace: string`
This setting specifies the Kubernetes namespace of an `ArangoDeployment` resource specified in `spec.source.deploymentName`.
If this setting is empty, the namespace of the `ArangoDeploymentReplication` is used.
### `spec.source.masterEndpoints: []string`
This setting specifies zero or more master endpoint URL's of the source cluster.
Use this setting if the source cluster is not running inside a Kubernetes cluster
that is reachable from the Kubernetes cluster the `ArangoDeploymentReplication` resource is deployed in.
Specifying this setting and `spec.source.deploymentName` at the same time is not allowed.
### `spec.source.auth.jwtSecretName: string`
This setting specifies the name of a `Secret` containing a JWT `token` used to authenticate
with the SyncMaster at the specified source.
This setting is required, unless `spec.source.deploymentName` has been set.
### `spec.source.tls.caSecretName: string`
This setting specifies the name of a `Secret` containing a TLS CA certificate `ca.crt` used to verify
the TLS connection created by the SyncMaster at the specified source.
This setting is required, unless `spec.source.deploymentName` has been set.
### `spec.destination.deploymentName: string`
This setting specifies the name of an `ArangoDeployment` resource that runs a cluster
with sync enabled.
This cluster configured as the replication destination.
### `spec.destination.deploymentNamespace: string`
This setting specifies the Kubernetes namespace of an `ArangoDeployment` resource specified in `spec.destination.deploymentName`.
If this setting is empty, the namespace of the `ArangoDeploymentReplication` is used.
### `spec.destination.masterEndpoints: []string`
This setting specifies zero or more master endpoint URL's of the destination cluster.
Use this setting if the destination cluster is not running inside a Kubernetes cluster
that is reachable from the Kubernetes cluster the `ArangoDeploymentReplication` resource is deployed in.
Specifying this setting and `spec.destination.deploymentName` at the same time is not allowed.
### `spec.destination.auth.jwtSecretName: string`
This setting specifies the name of a `Secret` containing a JWT `token` used to authenticate
with the SyncMaster at the specified destination.
This setting is required, unless `spec.destination.deploymentName` has been set.
### `spec.destination.tls.caSecretName: string`
This setting specifies the name of a `Secret` containing a TLS CA certificate `ca.crt` used to verify
the TLS connection created by the SyncMaster at the specified destination.
This setting is required, unless `spec.destination.deploymentName` has been set.
### `spec.auth.clientAuthSecretName: string`
This setting specifies the name of a `Secret` containing a client authentication certificate,
used to authenticate the SyncMaster in the destination cluster with the SyncMaster in the
source cluster.

View file

@ -23,6 +23,14 @@ The following test scenario's must be covered by automated tests:
- Restart Node
- API server unavailable
- Persistent Volumes:
- hint: RBAC file might need to be changed
- hint: get info via - client-go.CoreV1()
- Number of volumes should stay in reasonable bounds
- For some cases it might be possible to check that, the amount before and after the test stays the same
- A Cluster start should need 6 Volumes (DBServer + Agents)
- The release of a volume-claim should result in a release of the volume
## Test environments
- Kubernetes clusters

View file

@ -0,0 +1,82 @@
//
// DISCLAIMER
//
// Copyright 2018 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//
// Author Jan Christoph Uhde <jan@uhdejc.com>
//
package tests
import (
"fmt"
"strings"
"testing"
"github.com/dchest/uniuri"
"github.com/stretchr/testify/assert"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1alpha"
kubeArangoClient "github.com/arangodb/kube-arangodb/pkg/client"
//"github.com/arangodb/kube-arangodb/pkg/util"
)
// TODO - add description
func TestPersistence(t *testing.T) {
longOrSkip(t)
k8sNameSpace := getNamespace(t)
k8sClient := mustNewKubeClient(t)
volumesList, err := k8sClient.CoreV1().PersistentVolumes().List(metav1.ListOptions{})
assert.NoError(t, err, "error while listing volumes")
claimsList, err := k8sClient.CoreV1().PersistentVolumeClaims(k8sNameSpace).List(metav1.ListOptions{})
assert.NoError(t, err, "error while listing volume claims")
fmt.Printf("----------------------------------------")
fmt.Printf("%v %v", volumesList, claimsList)
fmt.Printf("----------------------------------------")
fmt.Printf("%v %v", len(volumesList.Items), len(claimsList.Items))
fmt.Printf("----------------------------------------")
mode := api.DeploymentModeCluster
engine := api.StorageEngineRocksDB
deploymentClient := kubeArangoClient.MustNewInCluster()
deploymentTemplate := newDeployment(strings.Replace(fmt.Sprintf("tpers-%s-%s-%s", mode[:2], engine[:2], uniuri.NewLen(4)), ".", "", -1))
deploymentTemplate.Spec.Mode = api.NewMode(mode)
deploymentTemplate.Spec.StorageEngine = api.NewStorageEngine(engine)
deploymentTemplate.Spec.TLS = api.TLSSpec{}
//deploymentTemplate.Spec.Environment = api.NewEnvironment(api.EnvironmentDevelopment)
//deploymentTemplate.Spec.Image = util.NewString("arangodb/arangodb:3.3.4")
//deploymentTemplate.Spec.DBServers.Count = util.NewInt(numNodes + 1)
deploymentTemplate.Spec.SetDefaults(deploymentTemplate.GetName()) // this must be last
assert.NoError(t, deploymentTemplate.Spec.Validate())
// Create deployment
_, err = deploymentClient.DatabaseV1alpha().ArangoDeployments(k8sNameSpace).Create(deploymentTemplate)
assert.NoError(t, err, "failed to create deplyment: %s", err)
_, err = waitUntilDeployment(deploymentClient, deploymentTemplate.GetName(), k8sNameSpace, deploymentIsReady())
assert.NoError(t, err, fmt.Sprintf("Deployment not running in time: %s", err)) // <-- fails here at the moment
// TODO - add tests that check the number of volumes and claims
// Cleanup
removeDeployment(deploymentClient, deploymentTemplate.GetName(), k8sNameSpace)
}