Skip to content

Commit

Permalink
DEVX-815: Automatically spin up a CCloud stack for developers to test (
Browse files Browse the repository at this point in the history
  • Loading branch information
ybyzek authored May 6, 2020
1 parent 7f630fd commit 0fd820e
Show file tree
Hide file tree
Showing 9 changed files with 885 additions and 470 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ log.*
*.csr
*.srl
*_creds
**/stack-configs/
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@ The best demo to start with is [cp-demo](https://github.com/confluentinc/cp-demo

| Demo | Local | Docker | Description
| ------------------------------------------ | ----- | ------ | ---------------------------------------------------------------------------
| [Beginner Cloud](ccloud/beginner-cloud/README.md) | Y | N | Fully automated demo interacting with your Confluent Cloud cluster using Confluent Cloud CLI <br><img src="clients/cloud/images/confluent-cli.png" width="300">
| [Confluent Cloud CLI](ccloud/beginner-cloud/README.md#confluent-cloud-cli) | Y | N | Fully automated demo interacting with your Confluent Cloud cluster using Confluent Cloud CLI <br><img src="clients/cloud/images/confluent-cli.png" width="300">
| [Clients to Cloud](clients/cloud/README.md) | [Y](clients/cloud/README.md) | N | Client applications in different programming languages connecting to [Confluent Cloud](https://www.confluent.io/confluent-cloud/?utm_source=github&utm_medium=demo&utm_campaign=ch.examples_type.community_content.top) <br><img src="clients/cloud/images/clients-all.png" width="450">
| [Cloud ETL](cloud-etl/README.md) | [Y](cloud-etl/README.md) | N | Cloud ETL solution using fully-managed Confluent Cloud connectors and fully-managed ksqlDB <br><img src="cloud-etl/docs/images/topology.png" width="450">
| [Fully Managed Stack](ccloud/ccloud-stack/README.md) | Y | N | Creates a fully-managed stack in Confluent Cloud, including a new environment, service account, Kafka cluster, KSQL app, Schema Registry, and ACLs. The demo also generates a config file for use with client applications.<br><img src="clients/cloud/images/confluent-cloud.png" width="300">
| [On-Prem Kafka to Cloud](ccloud/README.md) | [Y](ccloud/README.md) | [Y](ccloud/README.md) | This more advanced demo showcases an on-prem Kafka cluster and [Confluent Cloud](https://www.confluent.io/confluent-cloud/?utm_source=github&utm_medium=demo&utm_campaign=ch.examples_type.community_content.top) cluster, and data copied between them with Confluent Replicator <br><img src="ccloud/docs/images/services-in-cloud.jpg" width="450">
| [GKE to Cloud](kubernetes/replicator-gke-cc/README.md) | N | [Y](kubernetes/replicator-gke-cc/README.md) | Uses Google Kubernetes Engine, [Confluent Cloud](https://www.confluent.io/confluent-cloud/?utm_source=github&utm_medium=demo&utm_campaign=ch.examples_type.community_content.top), and [Confluent Replicator](https://www.confluent.io/confluent-replicator/?utm_source=github&utm_medium=demo&utm_campaign=ch.examples_type.community_content.top) to explore a multicloud deployment <br><img src="kubernetes/replicator-gke-cc/docs/images/operator-demo-phase-2.png" width="450">

Expand Down
38 changes: 36 additions & 2 deletions ccloud/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
![image](../images/confluent-logo-300-2.png)

* [Overview](#overview)
* [Beginner Cloud](#beginner-cloud)
* [Warning](#warning)
* [Confluent Cloud CLI Demo](#confluent-cloud-cli)
* [Fully Managed Stack in Confluent Cloud](#fully-managed-stack-in-confluent-cloud)
* [Hybrid Cloud](#hybrid-cloud)
* [Client Code Examples](#client-code-examples)
* [Build Your Own Cloud Demo](#build-your-own-cloud-demo)
Expand All @@ -15,7 +17,12 @@ It has a web interface and local command line interface that you can use to mana

This repo has a few resources to help you validate your solutions on Confluent Cloud.

# Beginner Cloud
# Warning

All demos/scripts that connect to Confluent Cloud use real Confluent Cloud resources.
To avoid unexpected charges, carefully evaluate the cost of resources before launching any demo and ensure all resources are destroyed after you are done running it.

# Confluent Cloud CLI

[This beginner demo](beginner-cloud/README.md) is a fully scripted demo that shows users how to interact with Confluent Cloud using the Confluent Cloud CLI.
It steps through the following workflow:
Expand All @@ -32,6 +39,33 @@ It steps through the following workflow:
* Delete the API key, service account, Kafka topics, Kafka cluster, environment, and the log files


# Fully Managed Stack in Confluent Cloud

The [ccloud stack](ccloud-stack/ccloud_stack_create.sh) is a script that creates a stack of fully managed services in Confluent Cloud.
It is a quick way to create fully managed components in Confluent Cloud, which you can then use for learning and building other demos.
Please do not use this in a production environment.
The script uses the Confluent Cloud CLI to dynamically do the following in Confluent Cloud:

* Create a new environment
* Create a new service account
* Create a new Kafka cluster and associated credentials
* Enable Schema Registry and associated credentials
* Create a new KSQL app and associated credentials
* Create ACLs with wildcard for the service account
* Generate a local configuration file with all above connection information, useful for other demos/automation

To create the stack:

```bash
./ccloud_stack_create.sh
```

To destroy the stack, pass the client properties file auto-generated in the step above:

```bash
./ccloud stack_destroy.sh stack-configs/java-service-account-<SERVICE_ACCOUNT_ID>.config
```

# Cloud ETL

The [cloud ETL demo](https://docs.confluent.io/current/tutorials/examples/cloud-etl/docs/index.html?utm_source=github&utm_medium=demo&utm_campaign=ch.examples_type.community_content.ccloud) showcases a cloud ETL solution leveraging all fully-managed services on Confluent Cloud.
Expand Down
17 changes: 9 additions & 8 deletions ccloud/beginner-cloud/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
![image](../../images/confluent-logo-300-2.png)

# Beginner Cloud
# Confluent Cloud CLI

## Overview

You can use [Confluent Cloud CLI](https://docs.confluent.io/current/cloud/cli/install.html#ccloud-install-cli?utm_source=github&utm_medium=demo&utm_campaign=ch.examples_type.community_content.beginner-cloud) to interact with your [Confluent Cloud](https://confluent.cloud/?utm_source=github&utm_medium=demo&utm_campaign=ch.examples_type.community_content.beginner-cloud) cluster.

Expand All @@ -17,9 +19,9 @@ You can use [Confluent Cloud CLI](https://docs.confluent.io/current/cloud/cli/in
* Run a Java consumer: showcase a Wildcard ACL
* Delete the API key, service account, Kafka topics, Kafka cluster, environment, and the log files

# Run the demo
## Run the demo

## DISCLAIMER
### DISCLAIMER

This demo is for reference purposes only and should be used to see a sample workflow using Confluent Cloud CLI

Expand All @@ -29,7 +31,7 @@ If you choose to run it against your Confluent Cloud cluster, be aware that it:
- is for demo purposes only
- should be used only on a non-production cluster

## Pre-requisites
### Pre-requisites

* Access to a Confluent Cloud cluster
* Local install of the new [Confluent Cloud CLI](https://docs.confluent.io/current/cloud/cli/install.html#ccloud-install-cli?utm_source=github&utm_medium=demo&utm_campaign=ch.examples_type.community_content.beginner-cloud) v1.0.0 or later
Expand All @@ -39,13 +41,13 @@ If you choose to run it against your Confluent Cloud cluster, be aware that it:
* `mvn` installed on your host
* `jq` installed on your host

## Run demo
### Run demo

```bash
./start.sh
```

# Advanced demo usage
## Advanced demo usage

The demo script provides variables allowing you to alter the default Kafka cluster name, cloud provider, and region. For example:

Expand All @@ -60,7 +62,7 @@ Here are the variables and their default values:
| CLUSTER_CLOUD | aws |
| CLUSTER_REGION | us-west-2 |

# Clean up after the demo
## Clean up after the demo

If a demo run ended prematurely, it may not have totally cleaned up after itself and a new run may error out with the following message:

Expand All @@ -82,7 +84,6 @@ Use this script with extreme caution and only in non-production environments.
./cleanup.sh
```


# Other Resources

See other [Confluent Cloud demos](../README.md).
44 changes: 44 additions & 0 deletions ccloud/ccloud-stack/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
![image](../../images/confluent-logo-300-2.png)

# Fully Managed Stack in Confluent Cloud

## Overview

This script creates a stack of fully managed services in Confluent Cloud.
It is a quick way to create fully managed resources in Confluent Cloud, which you can then use for learning and building other demos.
Do not use this in a production environment.
The script uses the Confluent Cloud CLI to dynamically do the following in Confluent Cloud:

* Create a new environment
* Create a new service account
* Create a new Kafka cluster and associated credentials
* Enable Schema Registry and associated credentials
* Create a new KSQL app and associated credentials
* Create ACLs with wildcard for the service account
* Generate a local configuration file with all above connection information, useful for other demos/automation

## DISCLAIMER

This demo is learning purposes only.
If you choose to run it against your Confluent Cloud cluster, be aware that it creates resources and incurs charges.
It is for demo purposes only and should be used only on a non-production cluster.

## Create

To create the stack:

```bash
./ccloud_stack_create.sh
```

## Destroy

To destroy the stack, pass the client properties file auto-generated in the step above:

```bash
./ccloud stack_destroy.sh stack-configs/java-service-account-<SERVICE_ACCOUNT_ID>.config
```

# Other Resources

See other [Confluent Cloud demos](../README.md).
61 changes: 61 additions & 0 deletions ccloud/ccloud-stack/ccloud_stack_create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/bin/bash

#########################################
# This script uses real Confluent Cloud resources.
# To avoid unexpected charges, carefully evaluate the cost of resources before launching the script and ensure all resources are destroyed after you are done running it.
#########################################


# Source library
. ../../utils/helper.sh

check_ccloud_version 1.0.0 || exit 1
check_jq || exit 1
check_ccloud_logged_in || exit 1

prompt_continue_cloud_demo || exit 1

enable_ksql=false
read -p "Do you also want to create a Confluent Cloud KSQL app (hourly charges may apply)? [y/n] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
enable_ksql=true
fi

echo
echo "Creating..."
cloud_create_demo_stack $enable_ksql

echo
echo "Validating..."
SERVICE_ACCOUNT_ID=$(ccloud kafka cluster list -o json | jq -r '.[0].name' | awk -F'-' '{print $4;}')
CONFIG_FILE=stack-configs/java-service-account-$SERVICE_ACCOUNT_ID.config
check_ccloud_config $CONFIG_FILE || exit 1
../ccloud-generate-cp-configs.sh $CONFIG_FILE > /dev/null
source delta_configs/env.delta

if $enable_ksql ; then
MAX_WAIT=720
echo "Waiting up to $MAX_WAIT seconds for Confluent Cloud KSQL cluster to be UP"
retry $MAX_WAIT check_ccloud_ksql_endpoint_ready $KSQL_ENDPOINT || exit 1
fi

ccloud_demo_preflight_check $CLOUD_KEY $CONFIG_FILE $enable_ksql || exit 1

echo
echo "ACLs for service account: $SERVICE_ACCOUNT_ID"
ccloud kafka acl list --service-account $SERVICE_ACCOUNT_ID

echo
echo "Local client configuration file written to $CONFIG_FILE"
echo

echo
echo "To destroy this Confluent Cloud stack run ->"
echo " ./ccloud_stack_destroy.sh $CONFIG_FILE"
echo

echo
ENVIRONMENT=$(ccloud environment list | grep demo-env-$SERVICE_ACCOUNT_ID | tr -d '\*' | awk '{print $1;}')
echo "Tip: 'ccloud' CLI has been set to the new environment $ENVIRONMENT"
28 changes: 28 additions & 0 deletions ccloud/ccloud-stack/ccloud_stack_destroy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash


# Source library
. ../../utils/helper.sh

check_ccloud_version 1.0.0 || exit 1
check_jq || exit 1
check_ccloud_logged_in || exit 1

if [ -z "$1" ]; then
echo "ERROR: Must supply argument that is the client configuration file created from './ccloud_stack_create.sh'. (Is it in stacks-config/ folder?) "
exit 1
else
CONFIG_FILE=$1
fi

check_ccloud_config $CONFIG_FILE || exit 1
../ccloud-generate-cp-configs.sh $CONFIG_FILE > /dev/null
source delta_configs/env.delta
SERVICE_ACCOUNT_ID=$(ccloud_cli_get_service_account $CLOUD_KEY $CONFIG_FILE) || exit 1

echo
echo "Destroying..."
cloud_delete_demo_stack $SERVICE_ACCOUNT_ID

echo
echo "Tip: 'ccloud' CLI currently has no environment set"
Loading

0 comments on commit 0fd820e

Please sign in to comment.