Skip to content
This repository has been archived by the owner on Mar 16, 2022. It is now read-only.

Commit

Permalink
Updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
jroper committed Aug 16, 2019
1 parent 16cde65 commit 23d04b4
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 15 deletions.
16 changes: 5 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,30 @@ The operator should work on any Kubernetes distribution, we have tested on GKE w
### Running on GKE

1. Create a GKE cluster. We recommend at least 6 vCPUs (ie, a node pool of 3 `n1-standard-2` nodes). Also ensure that the current user is a cluster admin. Detailed instructions for creating the GKE cluster can be found in the [Knative documentation](https://github.com/knative/docs/blob/master/docs/install/Knative-with-GKE.md), follow all the steps up to (but not including) installing Knative.
2. Install Cassandra. This can be done from the Google Marketplace, by visiting the [Cassandra Cluster](https://console.cloud.google.com/marketplace/details/google/cassandra), selecting configure, selecting your GCloud project, and then installing it in the Kubernetes cluster you just created. The defaults should be good enough, in our examples we called the app instance name `cassandra`.
2. If using an event sourced entity, install Cassandra. This can be done from the Google Marketplace, by visiting the [Cassandra Cluster](https://console.cloud.google.com/marketplace/details/google/cassandra), selecting configure, selecting your GCloud project, and then installing it in the Kubernetes cluster you just created. The defaults should be good enough, in our examples we called the app instance name `cassandra`. Note there is an option to use an in memory journal if you just want to test it out, of course, as soon as your pods shut down (or if they are rebalanced), your journals will be lost.
3. Install the CloudState operator:

```
kubectl apply -f https://raw.githubusercontent.com/lightbend/stateful-serverless/v0.3/src/operator/stateful-serverless.yaml
kubectl apply -f https://raw.githubusercontent.com/cloudstateio/cloudstate/master/operator/stateful-serverless.yaml
```

You are now ready to install an event sourced function. We have a shopping cart example in the `samples/js-shopping-cart` directory of this project. This can be installed by following these instructions:

1. Configure a Cassandra journal. If you called your Cassandra deployment `cassandra` and deployed it to the default namespace, this can be installed by running:

```
kubectl apply -f https://raw.githubusercontent.com/lightbend/stateful-serverless/v0.3/src/samples/js-shopping-cart/journal.yaml
kubectl apply -f https://raw.githubusercontent.com/cloudstateio/cloudstate/master/samples/js-shopping-cart/cassandra-journal.yaml
```

Otherwise, download the above file and update the `service` parameter to match the first node of your Cassandra stateful set.

2. Install the shopping cart, this can be done by running:

```
kubectl apply -f https://raw.githubusercontent.com/lightbend/stateful-serverless/v0.3/src/samples/js-shopping-cart/eventsourced.yaml
kubectl apply -f https://raw.githubusercontent.com/cloudstateio/cloudstate/master/samples/js-shopping-cart/js-shopping-cart.yaml
```

3. The operator will install a service that will expose this on an external IP address, watch the service to find out what the IP address is (it may take a minute or so to provision):

```
kubectl get svc shopping-cart -w
```

4. To test, instantiate a gRPC client in your favourite language for [this descriptor](https://raw.githubusercontent.com/lightbend/stateful-serverless/v0.3/src/samples/js-shopping-cart/proto/shoppingcart.proto). You may need to also download the [`lightbend/serverless/entitykey.proto`](https://raw.githubusercontent.com/lightbend/stateful-serverless/v0.3/src/backend/core/src/main/proto/lightbend/serverless/entitykey.proto) and [`google/protobuf/empty.proto`](https://raw.githubusercontent.com/lightbend/stateful-serverless/v0.3/src/samples/js-shopping-cart/proto/google/protobuf/empty.proto) descriptors to compile it in your language. The shopping cart descriptor is deployed with debug on, so try getting the logs of the `shopping-cart` container in each of the deployed pods to see what's happening when commands are sent.
The operator will install a service, you can then create an ingress for that service. To test, instantiate a gRPC client in your favourite language for [this descriptor](https://raw.githubusercontent.com/cloudstateio/cloudstate/master/examples/shoppingcart/shoppingcart.proto). You may need to also download the [`cloudstate/entitykey.proto`](https://raw.githubusercontent.com/cloudstateio/cloudstate/master/protols/frontend/cloudstate/entity.proto) and [`google/protobuf/empty.proto`](https://raw.githubusercontent.com/protocolbuffers/protobuf/master/src/google/protobuf/empty.proto) descriptors to compile it in your language. The shopping cart descriptor is deployed with debug on, so try getting the logs of the `shopping-cart` container in each of the deployed pods to see what's happening when commands are sent.

### Points of interest

Expand Down
26 changes: 26 additions & 0 deletions samples/js-shopping-cart/journal-cassandra.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Deployment spec for a journal. A journal is a logical abstraction over a database
# deployment, and captures how to deploy and connect to that database. Multiple
# StatefulServices's would use a single journal.
apiVersion: cloudstate.io/v1alpha1
kind: Journal
metadata:
name: cassandra
spec:

# The type of Journal - valid values would come from an enum of supported databases.
type: Cassandra

# The deployment type, ie, how this Journal is deployed. Valid values would depend on
# the Journal type, but all types would support "Unmanaged", which indicates that the
# operator doesn't manage/deploy the database itself, ie, the user has to deploy
# the database themselves. For Cassandra, future supported values might include
# "GoogleCloudMarketplace", which would deploy Cassandra using Google's Application
# CRD, or "InstaclustrOperator", which would deploy Cassandra using Instaclustr's
# Cassandra operator.
deployment: Unmanaged

# Type and deployment specific configuration for the journal.
config:

# The name of the unmanaged Cassandra service to connect to.
service: cassandra-cassandra-0.cassandra-cassandra-svc.cassandra.svc.cluster.local
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Deployment spec for a journal. A journal is a logical abstraction over a database
# deployment, and captures how to deploy and connect to that database. Multiple
# EventSourcedFunction's would use a single journal.
# StatefulService's would use a single journal.
apiVersion: cloudstate.io/v1alpha1
kind: Journal
metadata:
name: inmemory
spec:

# The type of Journal - valid values would come from an enum of supported databases.
# Currently, Cassandra is the only supported database.
# This is the InMemory journal, which obviously should not be used in production.
type: InMemory

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@ spec:
# Journal configuration
journal:

# Name of a deployed EventSourcedJournal to use.
name: inmemory
# Name of a deployed Journal to use.
name: cassandra

# Journal specific configuration
config:

# Since the journal is a Cassandra journal, we need to specify the keyspace to use.
keyspace: shoppingcart

containers:
- image: cloudstateio/js-shopping-cart:latest

0 comments on commit 23d04b4

Please sign in to comment.