forked from rook/rook
For the specification see: <https://github.com/rook/rook/blob/master/design/ceph/object/swift-and-keystone-integration.md> * extend the API object specs for swift and keystone integration * adapt rgw to the new go-ceph version - The parameter lists of the API call have changes, as parameters ignored by the RGW Admin Ops API are no longer serialized, therefore the mock has to be adapted. - There is now validation for the user keys that are passed to the User get API, therefore things failed when we had empty keys in our User proxy object. * expand the reconcile loop for the swift and keystone integration * fix minor mistakes in design document * add env var to pass extra args to minikube Minikube decides CPU cores and memory automatically based on the available resources on the machine which may be insufficient to run rook. This commit adds an environment variable to add arbitrary arguments to the minikube command, so both can be specified if desired. * integration tests for swift and keystone The new integration of swift or s3 and keystone support by rook does not have any integration tests yet. This commit introduces integration tests for swift and keystone. The tests are done against a minimal keystone setup (keystone container image from Yaook-project (https://yaook.cloud), sqlite as database backend, cert-manager and trust-manager for test certificate setup). To prevent hardcoded credentials, passwords are generated by the tests. The integration tests use the openstack client (keystone- and swift-functionality) (https://docs.openstack.org/ python-openstackclient/ latest/). This was a concious design decision to use client tooling as close as possible to the end user instead of using other go-libraries (such as gophercloud). * add documentation on swift and keystone Currently there is no documentation on the use of Swift to access an object store as well as the use of OpenStack keystone for authentication. This commit adds documentation on the use of Swift and OpenStack keystone, as well as CRD-related documentation and an example setup. * add integration tests for S3 via keystone This commit introduces integration tests for s3 and keystone. The tests are run against the same minimal keystone setup that the tests for swift and keystone use. The integration tests use the aws s3 client to use client tooling as close as possible to the end user instead of using other go-libraries. Co-authored-by: Jan Klippel <jan.klippel@uhurutec.com> Co-authored-by: Silvio Ankermann <silvio.ankermann@cloudandheat.com> Signed-off-by: Sebastian Riese <sebastian.riese@cloudandheat.com> Signed-off-by: Jan Klippel <jan.klippel@uhurutec.com> Signed-off-by: Silvio Ankermann <silvio.ankermann@cloudandheat.com>
82 lines
2.8 KiB
Go
82 lines
2.8 KiB
Go
/*
|
|
Copyright 2016 The Rook Authors. All rights reserved.
|
|
|
|
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.
|
|
*/
|
|
|
|
package clients
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/coreos/pkg/capnslog"
|
|
"github.com/rook/rook/tests/framework/installer"
|
|
"github.com/rook/rook/tests/framework/utils"
|
|
)
|
|
|
|
const rgwPort = 80
|
|
|
|
var logger = capnslog.NewPackageLogger("github.com/rook/rook/tests", "clients")
|
|
|
|
// ObjectOperation is wrapper for k8s rook object operations
|
|
type ObjectOperation struct {
|
|
k8sh *utils.K8sHelper
|
|
manifests installer.CephManifests
|
|
}
|
|
|
|
// CreateObjectOperation creates new rook object client
|
|
func CreateObjectOperation(k8sh *utils.K8sHelper, manifests installer.CephManifests) *ObjectOperation {
|
|
return &ObjectOperation{k8sh, manifests}
|
|
}
|
|
|
|
// ObjectCreate Function to create a object store in rook
|
|
func (o *ObjectOperation) Create(namespace, storeName string, replicaCount int32, tlsEnable bool, swiftAndKeystone bool) error {
|
|
|
|
logger.Info("creating the object store via CRD")
|
|
|
|
if err := o.k8sh.ResourceOperation("apply", o.manifests.GetObjectStore(storeName, int(replicaCount), rgwPort, tlsEnable, swiftAndKeystone)); err != nil {
|
|
return err
|
|
}
|
|
|
|
// Starting an object store takes longer than the average operation, so add more retries
|
|
err := o.k8sh.WaitForLabeledPodsToRunWithRetries(fmt.Sprintf("rook_object_store=%s", storeName), namespace, 80)
|
|
if err != nil {
|
|
return fmt.Errorf("rgw did not start via crd. %+v", err)
|
|
}
|
|
|
|
// create the external service
|
|
return o.k8sh.CreateExternalRGWService(namespace, storeName)
|
|
}
|
|
|
|
func (o *ObjectOperation) Delete(namespace, storeName string) error {
|
|
|
|
logger.Infof("Deleting the object store via CRD")
|
|
if err := o.k8sh.DeleteResource("-n", namespace, "CephObjectStore", storeName); err != nil {
|
|
return err
|
|
}
|
|
|
|
if !o.k8sh.WaitUntilPodWithLabelDeleted(fmt.Sprintf("rook_object_store=%s", storeName), namespace) {
|
|
return fmt.Errorf("rgw did not stop via crd")
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// Need to improve the below function for better error handling
|
|
func (o *ObjectOperation) GetEndPointUrl(namespace string, storeName string) (string, error) {
|
|
args := []string{"get", "svc", "-n", namespace, "-l", fmt.Sprintf("rgw=%s", storeName), "-o", "jsonpath={.items[*].spec.clusterIP}"}
|
|
EndPointUrl, err := o.k8sh.Kubectl(args...)
|
|
if err != nil {
|
|
return "", fmt.Errorf("Unable to find rgw end point-- %s", err)
|
|
}
|
|
return fmt.Sprintf("%s:%d", EndPointUrl, rgwPort), nil
|
|
}
|