diff --git a/howto/setup-state-store/README.md b/howto/setup-state-store/README.md index 2f0913940..f5a17adc6 100644 --- a/howto/setup-state-store/README.md +++ b/howto/setup-state-store/README.md @@ -43,5 +43,9 @@ kubectl apply -f statestore.yaml ## Reference * [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) * [Supported State Stores](./supported-state-stores.md) diff --git a/howto/setup-state-store/setup-cassandra.md b/howto/setup-state-store/setup-cassandra.md new file mode 100644 index 000000000..0b19db0f2 --- /dev/null +++ b/howto/setup-state-store/setup-cassandra.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: +spec: + type: state.cassandra + metadata: + - name: hosts + value: # Required. Example: cassandra.cassandra.svc.cluster.local + - name: username + value: # Optional. default: "" + - name: password + value: # Optional. default: "" + - name: consistency + value: # Optional. default: "All" + - name: table + value: # Optional. default: "items" + - name: keyspace + value: # Optional. default: "dapr" + - name: protoVersion + value: # Optional. default: "4" + - name: replicationFactor + value: # 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: +spec: + type: state.cassandra + metadata: + - name: hosts + value: + - name: username + secretKeyRef: + name: + key: + - name: password + secretKeyRef: + name: + 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. diff --git a/howto/setup-state-store/setup-consul.md b/howto/setup-state-store/setup-consul.md new file mode 100644 index 000000000..49e85826e --- /dev/null +++ b/howto/setup-state-store/setup-consul.md @@ -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: +spec: + type: state.consul + metadata: + - name: datacenter + value: # Required. Example: dc1 + - name: httpAddr + value: # Required. Example: "consul.default.svc.cluster.local:8500" + - name: aclToken + value: # Optional. default: "" + - name: scheme + value: # Optional. default: "http" + - name: keyPrefixPath + value: # 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: +spec: + type: state.consul + metadata: + - name: datacenter + value: + - name: httpAddr + value: + - name: aclToken + secretKeyRef: + name: + 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. diff --git a/howto/setup-state-store/setup-etcd.md b/howto/setup-state-store/setup-etcd.md new file mode 100644 index 000000000..7e508b864 --- /dev/null +++ b/howto/setup-state-store/setup-etcd.md @@ -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: +spec: + type: state.etcd + metadata: + - name: endpoints + value: # Required. Example: "etcd-etcd.default.svc.cluster.local:2379" + - name: dialTimeout + value: # Required. Example: "5s" + - name: operationTimeout + value: # 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. diff --git a/howto/setup-state-store/setup-memcached.md b/howto/setup-state-store/setup-memcached.md new file mode 100644 index 000000000..44dacec0c --- /dev/null +++ b/howto/setup-state-store/setup-memcached.md @@ -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: +spec: + type: state.memcached + metadata: + - name: hosts + value: # Required. Example: "memcached.default.svc.cluster.local:11211" + - name: maxIdleConnections + value: # Optional. default: "2" + - name: timeout + value: # 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. diff --git a/howto/setup-state-store/supported-state-stores.md b/howto/setup-state-store/supported-state-stores.md index 9de04c49a..f38537b91 100644 --- a/howto/setup-state-store/supported-state-stores.md +++ b/howto/setup-state-store/supported-state-stores.md @@ -5,3 +5,7 @@ | ------------- | -------|------ | | Redis | :white_check_mark: | :white_check_mark: | 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: |