couchdbcatalog

package
v0.9.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 8, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

README

FireCamp CouchDB Internals

The FireCamp CouchDB container is based on the apache couchdb image. The data volume will be mounted to the /data directory inside container. The CouchDB data will be stored at the /data/couchdb directory, and the config files are at the /data/conf directory.

Topology

By default, database will have 3 replicas and the replicas will be evenly distributed to the availability zones in the cluster. If the cluster has 3 availability zones, each zone will have one replica. The production cluster should have 3 availability zones, to tolerate the availability zone failure.

Security

The Authentication and Authorization are enabled by default. The admin account is created. The require_valid_user is set to true for both cluster port and node-local port, to reject the requests from the anonymous users. The default admin user is "admin", and password "changeme". You could set the admin user and password to firecamp-service-cli when creating the CouchDB service.

The peruser option is broken in 2.1.0, see CouchDB issue 749. Once CouchDB fixes it, peruser will be supported.

The CouchDB SSL will be supported in the future.

The Cross-Region Resource Sharing (cors) is disabled by default. If you want to enable it, simply set couchdb-enable-cors to true and set credentials, origins, headers and methods when creating the CouchDB service.

The httpd config whitelist is disabled to avoid updating the configuration by mistake via the HTTP API.

Logging

The logs are sent to the Cloud Logs, such as AWS CloudWatch logs.

Tutorials

This is a simple tutorial about how to create a CouchDB service and how to use it. This tutorial assumes the cluster name is "t1", the AWS Region is "us-east-1", and the CouchDB service name is "mycouch".

Create a CouchDB service

Follow the Installation Guide guide to create a 3 nodes cluster across 3 availability zones. Create a CouchDB cluster:

firecamp-service-cli -op=create-service -service-type=couchdb -region=us-east-1 -cluster=t1 -replicas=3 -volume-size=100 -service-name=mycouch -admin=admin -password=changeme

This creates a 3 replicas CouchDB on 3 availability zones. The database replicas will be distributed to different availability zone, to tolerate one availability zone failure. Every replica has 100GB volume. The DNS names of the members would be: mycouch-0.t1-firecamp.com, mycouch-1.t1-firecamp.com, mycouch-2.t1-firecamp.com.

Create Database and Documents

  1. Check CouchDB is running: curl admin:changeme@mycouch-0.t1-firecamp.com:5984/
{"couchdb":"Welcome","version":"2.1.0","features":["scheduler"],"vendor":{"name":"The Apache Software Foundation"}}
  1. Check all dbs: curl admin:changeme@mycouch-0.t1-firecamp.com:5984/_all_dbs
["_global_changes","_replicator","_users"]
  1. Create a db: curl -X PUT admin:changeme@mycouch-0.t1-firecamp.com:5984/fruits
{"ok":true}
  1. List all dbs: curl admin:changeme@mycouch-0.t1-firecamp.com:5984/_all_dbs
["_global_changes","_replicator","_users","fruits"]
  1. Create a doc: curl -X PUT admin:changeme@mycouch-0.t1-firecamp.com:5984/fruits/001 -d '{ "item": "apple", "prices": 1.59 }'
{"ok":true,"id":"001","rev":"1-c3e92e9cc218153b17972aff94f77475"}
  1. Create another doc: curl -X PUT admin:changeme@mycouch-0.t1-firecamp.com:5984/fruits/002 -d '{ "item": "orange", "prices": 1.99 }'
{"ok":true,"id":"002","rev":"1-28e160edec1821bcfb2230dc7ca75a7d"}
  1. List all docs: curl admin:changeme@mycouch-0.t1-firecamp.com:5984/fruits/_all_docs
{"total_rows":2,"offset":0,"rows":[
{"id":"001","key":"001","value":{"rev":"1-c3e92e9cc218153b17972aff94f77475"}},
{"id":"002","key":"002","value":{"rev":"1-28e160edec1821bcfb2230dc7ca75a7d"}}
]}
  1. Get one doc: curl admin:changeme@mycouch1-0.t1-firecamp.com:5984/fruits/001
{"_id":"001","_rev":"1-c3e92e9cc218153b17972aff94f77475","item":"apple","prices":1.59}

Documentation

Index

Constants

View Source
const (

	// ContainerImage is the main running container.
	ContainerImage = common.ContainerNamePrefix + "couchdb:" + defaultVersion
	// InitContainerImage initializes the couchdb cluster.
	InitContainerImage = common.ContainerNamePrefix + "couchdb-init:" + defaultVersion
)

Variables

This section is empty.

Functions

func GenDefaultCreateServiceRequest

func GenDefaultCreateServiceRequest(platform string, region string, azs []string, cluster string,
	service string, res *common.Resources, opts *manage.CatalogCouchDBOptions) *manage.CreateServiceRequest

GenDefaultCreateServiceRequest returns the default service creation request.

func GenDefaultInitTaskRequest

func GenDefaultInitTaskRequest(req *manage.ServiceCommonRequest, logConfig *cloudlog.LogConfig, azs []string,
	serviceUUID string, replicas int64, manageurl string, admin string, adminPass string) *containersvc.RunTaskOptions

GenDefaultInitTaskRequest returns the default service init task request.

func GenInitTaskEnvKVPairs

func GenInitTaskEnvKVPairs(region string, cluster string, manageurl string, service string,
	azs []string, replicas int64, admin string, adminPass string) []*common.EnvKeyValuePair

GenInitTaskEnvKVPairs generates the environment key-values for the init task.

func GetAdminFromServiceConfigs added in v0.9.6

func GetAdminFromServiceConfigs(content string) (admin string, adminPass string)

func ValidateRequest

func ValidateRequest(r *manage.CatalogCreateCouchDBRequest) error

ValidateRequest checks if the request is valid

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL