mirror of https://github.com/dapr/docs.git
				
				
				
			Add how to's for etcd, consul and cassandra (#213)
* add how to for etcd, consul and cassandra * Update setup-cassandra.md * add memcached how to
This commit is contained in:
		
							parent
							
								
									63465c8e17
								
							
						
					
					
						commit
						271aa2cf99
					
				|  | @ -43,5 +43,9 @@ kubectl apply -f statestore.yaml | ||||||
| ## Reference | ## Reference | ||||||
| 
 | 
 | ||||||
| * [Setup Redis](./setup-redis.md) | * [Setup Redis](./setup-redis.md) | ||||||
|  | * [Setup Cassandra](./setup-cassandra.md) | ||||||
|  | * [Setup etcd](./setup-etcd.md) | ||||||
|  | * [Setup Consul](./setup-consul.md) | ||||||
|  | * [Setup Memcached](./setup-memcached.md) | ||||||
| * [Setup Azure CosmosDB](./setup-azure-cosmosdb.md) | * [Setup Azure CosmosDB](./setup-azure-cosmosdb.md) | ||||||
| * [Supported State Stores](./supported-state-stores.md) | * [Supported State Stores](./supported-state-stores.md) | ||||||
|  |  | ||||||
|  | @ -0,0 +1,98 @@ | ||||||
|  | # Setup Cassandra  | ||||||
|  | 
 | ||||||
|  | ## Locally | ||||||
|  | 
 | ||||||
|  | You can run Cassandra locally with the Datastax Docker image: | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | docker run -e DS_LICENSE=accept --memory 4g --name my-dse -d datastax/dse-server -g -s -k | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | You can then interact with the server using `localhost:9042`. | ||||||
|  | 
 | ||||||
|  | ## Kubernetes | ||||||
|  | 
 | ||||||
|  | The easiest way to install Cassandra on Kubernetes is by using the [Helm chart](https://github.com/helm/charts/tree/master/incubator/cassandra): | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | helm install --namespace "cassandra" -n "cassandra" incubator/cassandra | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | This will install Cassandra into the `cassandra` namespace by default. | ||||||
|  | To interact with Cassandra, find the service with: `kubectl get svc -n cassandra`. | ||||||
|  | 
 | ||||||
|  | For example, if installing using the example above, the Cassandra DNS would be: | ||||||
|  | 
 | ||||||
|  | `cassandra.cassandra.svc.cluster.local` | ||||||
|  | 
 | ||||||
|  | ## Create a Dapr component | ||||||
|  | 
 | ||||||
|  | The next step is to create a Dapr component for Cassandra. | ||||||
|  | 
 | ||||||
|  | Create the following YAML file named `cassandra.yaml`: | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | apiVersion: dapr.io/v1alpha1 | ||||||
|  | kind: Component | ||||||
|  | metadata: | ||||||
|  |   name: <name> | ||||||
|  | spec: | ||||||
|  |   type: state.cassandra | ||||||
|  |   metadata: | ||||||
|  |   - name: hosts | ||||||
|  |     value: <REPLACE-WITH-COMMA-DELIMITED-HOSTS> # Required. Example: cassandra.cassandra.svc.cluster.local | ||||||
|  |   - name: username | ||||||
|  |     value: <REPLACE-WITH-PASSWORD> # Optional. default: "" | ||||||
|  |   - name: password | ||||||
|  |     value: <REPLACE-WITH-PASSWORD> # Optional. default: "" | ||||||
|  |   - name: consistency | ||||||
|  |     value: <REPLACE-WITH-CONSISTENCY> # Optional. default: "All" | ||||||
|  |   - name: table | ||||||
|  |     value: <REPLACE-WITH-TABLE> # Optional. default: "items" | ||||||
|  |   - name: keyspace | ||||||
|  |     value: <REPLACE-WITH-KEYSPACE> # Optional. default: "dapr" | ||||||
|  |   - name: protoVersion | ||||||
|  |     value: <REPLACE-WITH-PROTO-VERSION> # Optional. default: "4" | ||||||
|  |   - name: replicationFactor | ||||||
|  |     value: <REPLACE-WITH-REPLICATION-FACTOR> #  Optional. default: "1" | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described [here](../../concepts/components/secrets.md) | ||||||
|  | 
 | ||||||
|  | The following example uses the Kubernetes secret store to retrieve the username and password: | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | apiVersion: dapr.io/v1alpha1 | ||||||
|  | kind: Component | ||||||
|  | metadata: | ||||||
|  |   name: <name> | ||||||
|  | spec: | ||||||
|  |   type: state.cassandra | ||||||
|  |   metadata: | ||||||
|  |   - name: hosts | ||||||
|  |     value: <REPLACE-WITH-HOSTS> | ||||||
|  |   - name: username | ||||||
|  |     secretKeyRef: | ||||||
|  |       name: <KUBERNETES-SECRET-NAME> | ||||||
|  |       key: <KUBERNETES-SECRET-KEY> | ||||||
|  |   - name: password | ||||||
|  |     secretKeyRef: | ||||||
|  |       name: <KUBERNETES-SECRET-NAME> | ||||||
|  |       key: <KUBERNETES-SECRET-KEY> | ||||||
|  |   ... | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | ## Apply the configuration | ||||||
|  | 
 | ||||||
|  | ### In Kubernetes | ||||||
|  | 
 | ||||||
|  | To apply the Cassandra state store to Kubernetes, use the `kubectl` CLI: | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | kubectl apply -f cassandra.yaml | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | ### Running locally | ||||||
|  | 
 | ||||||
|  | The Dapr CLI will automatically create a directory named `components` in your current working directory with a Redis component. | ||||||
|  | To use Cassandra, replace the redis.yaml file with the cassandra.yaml above. | ||||||
|  | @ -0,0 +1,90 @@ | ||||||
|  | # Setup Consul  | ||||||
|  | 
 | ||||||
|  | ## Locally | ||||||
|  | 
 | ||||||
|  | You can run Consul locally using Docker: | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | docker run -d --name=dev-consul -e CONSUL_BIND_INTERFACE=eth0 consul | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | You can then interact with the server using `localhost:8500`. | ||||||
|  | 
 | ||||||
|  | ## Kubernetes | ||||||
|  | 
 | ||||||
|  | The easiest way to install Consul on Kubernetes is by using the [Helm chart](https://github.com/helm/charts/tree/master/stable/consul): | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | helm install --name consul stable/consul | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | This will install Consul into the `default` namespace. | ||||||
|  | To interact with Consul, find the service with: `kubectl get svc consul`. | ||||||
|  | 
 | ||||||
|  | For example, if installing using the example above, the Consul host address would be: | ||||||
|  | 
 | ||||||
|  | `consul.default.svc.cluster.local:8500` | ||||||
|  | 
 | ||||||
|  | ## Create a Dapr component | ||||||
|  | 
 | ||||||
|  | The next step is to create a Dapr component for Consul. | ||||||
|  | 
 | ||||||
|  | Create the following YAML file named `consul.yaml`: | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | apiVersion: dapr.io/v1alpha1 | ||||||
|  | kind: Component | ||||||
|  | metadata: | ||||||
|  |   name: <name> | ||||||
|  | spec: | ||||||
|  |   type: state.consul | ||||||
|  |   metadata: | ||||||
|  |   - name: datacenter | ||||||
|  |     value: <REPLACE-WITH-DATA-CENTER> # Required. Example: dc1 | ||||||
|  |   - name: httpAddr | ||||||
|  |     value: <REPLACE-WITH-CONSUL-HTTP-ADDRESS> # Required. Example: "consul.default.svc.cluster.local:8500" | ||||||
|  |   - name: aclToken | ||||||
|  |     value: <REPLACE-WITH-ACL-TOKEN> # Optional. default: "" | ||||||
|  |   - name: scheme | ||||||
|  |     value: <REPLACE-WITH-SCHEME> # Optional. default: "http" | ||||||
|  |   - name: keyPrefixPath | ||||||
|  |     value: <REPLACE-WITH-TABLE> # Optional. default: "" | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described [here](../../concepts/components/secrets.md) | ||||||
|  | 
 | ||||||
|  | The following example uses the Kubernetes secret store to retrieve the acl token: | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | apiVersion: dapr.io/v1alpha1 | ||||||
|  | kind: Component | ||||||
|  | metadata: | ||||||
|  |   name: <name> | ||||||
|  | spec: | ||||||
|  |   type: state.consul | ||||||
|  |   metadata: | ||||||
|  |   - name: datacenter | ||||||
|  |     value: <REPLACE-WITH-DATACENTER> | ||||||
|  |   - name: httpAddr | ||||||
|  |     value: <REPLACE-WITH-HTTP-ADDRESS> | ||||||
|  |   - name: aclToken | ||||||
|  |     secretKeyRef: | ||||||
|  |       name: <KUBERNETES-SECRET-NAME> | ||||||
|  |       key: <KUBERNETES-SECRET-KEY> | ||||||
|  |   ... | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | ## Apply the configuration | ||||||
|  | 
 | ||||||
|  | ### In Kubernetes | ||||||
|  | 
 | ||||||
|  | To apply the Consul state store to Kubernetes, use the `kubectl` CLI: | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | kubectl apply -f consul.yaml | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | ### Running locally | ||||||
|  | 
 | ||||||
|  | The Dapr CLI will automatically create a directory named `components` in your current working directory with a Redis component. | ||||||
|  | To use Consul, replace the redis.yaml file with the consul.yaml above. | ||||||
|  | @ -0,0 +1,67 @@ | ||||||
|  | # Setup etcd  | ||||||
|  | 
 | ||||||
|  | ## Locally | ||||||
|  | 
 | ||||||
|  | You can run etcd locally using Docker: | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | docker run -d --name etcd bitnami/etcd | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | You can then interact with the server using `localhost:2379`. | ||||||
|  | 
 | ||||||
|  | ## Kubernetes | ||||||
|  | 
 | ||||||
|  | The easiest way to install etcd on Kubernetes is by using the [Helm chart](https://github.com/helm/charts/tree/master/incubator/etcd): | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | helm repo add incubator http://storage.googleapis.com/kubernetes-charts-incubator | ||||||
|  | helm install --name etcd incubator/etcd | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | This will install etcd into the `default` namespace. | ||||||
|  | To interact with etcd, find the service with: `kubectl get svc etcd-etcd`. | ||||||
|  | 
 | ||||||
|  | For example, if installing using the example above, the etcd host address would be: | ||||||
|  | 
 | ||||||
|  | `etcd-etcd.default.svc.cluster.local:2379` | ||||||
|  | 
 | ||||||
|  | ## Create a Dapr component | ||||||
|  | 
 | ||||||
|  | The next step is to create a Dapr component for etcd. | ||||||
|  | 
 | ||||||
|  | Create the following YAML file named `etcd.yaml`: | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | apiVersion: dapr.io/v1alpha1 | ||||||
|  | kind: Component | ||||||
|  | metadata: | ||||||
|  |   name: <name> | ||||||
|  | spec: | ||||||
|  |   type: state.etcd | ||||||
|  |   metadata: | ||||||
|  |   - name: endpoints | ||||||
|  |     value: <REPLACE-WITH-COMMA-DELIMITED-ENDPOINTS> # Required. Example: "etcd-etcd.default.svc.cluster.local:2379" | ||||||
|  |   - name: dialTimeout | ||||||
|  |     value: <REPLACE-WITH-DIAL-TIMEOUT> # Required. Example: "5s" | ||||||
|  |   - name: operationTimeout | ||||||
|  |     value: <REPLACE-WITH-OPERATION-TIMEOUT> # Optional. default: "10S" | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described [here](../../concepts/components/secrets.md) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | ## Apply the configuration | ||||||
|  | 
 | ||||||
|  | ### In Kubernetes | ||||||
|  | 
 | ||||||
|  | To apply the etcd state store to Kubernetes, use the `kubectl` CLI: | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | kubectl apply -f etcd.yaml | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | ### Running locally | ||||||
|  | 
 | ||||||
|  | The Dapr CLI will automatically create a directory named `components` in your current working directory with a Redis component. | ||||||
|  | To use etcd, replace the redis.yaml file with the etcd.yaml above. | ||||||
|  | @ -0,0 +1,66 @@ | ||||||
|  | # Setup Memcached  | ||||||
|  | 
 | ||||||
|  | ## Locally | ||||||
|  | 
 | ||||||
|  | You can run Memcached locally using Docker: | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | docker run --name my-memcache -d memcached | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | You can then interact with the server using `localhost:11211`. | ||||||
|  | 
 | ||||||
|  | ## Kubernetes | ||||||
|  | 
 | ||||||
|  | The easiest way to install Memcached on Kubernetes is by using the [Helm chart](https://github.com/helm/charts/tree/master/stable/memcached): | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | helm install --name memcached stable/memcached | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | This will install Memcached into the `default` namespace. | ||||||
|  | To interact with Memcached, find the service with: `kubectl get svc memcached`. | ||||||
|  | 
 | ||||||
|  | For example, if installing using the example above, the Memcached host address would be: | ||||||
|  | 
 | ||||||
|  | `memcached.default.svc.cluster.local:11211` | ||||||
|  | 
 | ||||||
|  | ## Create a Dapr component | ||||||
|  | 
 | ||||||
|  | The next step is to create a Dapr component for Memcached. | ||||||
|  | 
 | ||||||
|  | Create the following YAML file named `memcached.yaml`: | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | apiVersion: dapr.io/v1alpha1 | ||||||
|  | kind: Component | ||||||
|  | metadata: | ||||||
|  |   name: <name> | ||||||
|  | spec: | ||||||
|  |   type: state.memcached | ||||||
|  |   metadata: | ||||||
|  |   - name: hosts | ||||||
|  |     value: <REPLACE-WITH-COMMA-DELIMITED-ENDPOINTS> # Required. Example: "memcached.default.svc.cluster.local:11211" | ||||||
|  |   - name: maxIdleConnections | ||||||
|  |     value: <REPLACE-WITH-MAX-IDLE-CONNECTIONS> # Optional. default: "2" | ||||||
|  |   - name: timeout | ||||||
|  |     value: <REPLACE-WITH-TIMEOUT> # Optional. default: "1000ms" | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | The above example uses secrets as plain strings. It is recommended to use a secret store for the secrets as described [here](../../concepts/components/secrets.md) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | ## Apply the configuration | ||||||
|  | 
 | ||||||
|  | ### In Kubernetes | ||||||
|  | 
 | ||||||
|  | To apply the Memcached state store to Kubernetes, use the `kubectl` CLI: | ||||||
|  | 
 | ||||||
|  | ``` | ||||||
|  | kubectl apply -f memcached.yaml | ||||||
|  | ``` | ||||||
|  | 
 | ||||||
|  | ### Running locally | ||||||
|  | 
 | ||||||
|  | The Dapr CLI will automatically create a directory named `components` in your current working directory with a Redis component. | ||||||
|  | To use Memcached, replace the redis.yaml file with the memcached.yaml above. | ||||||
|  | @ -5,3 +5,7 @@ | ||||||
| | ------------- | -------|------ | | | ------------- | -------|------ | | ||||||
| | Redis  | :white_check_mark:  | :white_check_mark: | | Redis  | :white_check_mark:  | :white_check_mark: | ||||||
| | Azure CosmosDB | :white_check_mark: | :x: | | | Azure CosmosDB | :white_check_mark: | :x: | | ||||||
|  | | Cassandra | :white_check_mark: | :x: | | ||||||
|  | | Hashicorp Consul | :white_check_mark: | :x: | | ||||||
|  | | etcd | :white_check_mark: | :x: | | ||||||
|  | | Memcached | :white_check_mark: | :x: | | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue