Skip to content

Commit

Permalink
Cleanup config model, test updates, add instructions for running locally
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Edgar <[email protected]>
  • Loading branch information
MikeEdgar committed May 16, 2024
1 parent 33c53c1 commit 93be789
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 69 deletions.
23 changes: 15 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,35 @@

include *compose.env

CONSOLE_API_IMAGE ?= localhost/eyefloaters/console-api
CONSOLE_API_ACCOUNT ?= streams-console-service-account
CONSOLE_API_NS ?= default
CONSOLE_UI_IMAGE ?= localhost/eyefloaters/console-ui
CONSOLE_API_IMAGE ?= quay.io/eyefloaters/console-api:latest
CONSOLE_UI_IMAGE ?= quay.io/eyefloaters/console-api:latest
CONSOLE_UI_NEXTAUTH_SECRET ?= $(shell openssl rand -base64 32)
CONTAINER_RUNTIME ?= $(shell which podman || which docker)

container-image-api:
mvn package -f api/pom.xml -Pdocker -DskipTests -Dquarkus.container-image.image=$(CONSOLE_API_IMAGE)

container-image-api-push: container-image-api
$(CONTAINER_RUNTIME) push $(CONSOLE_API_IMAGE)

container-image-ui:
docker build -t $(CONSOLE_UI_IMAGE) ./ui -f ./ui/Dockerfile
$(CONTAINER_RUNTIME) build -t $(CONSOLE_UI_IMAGE) ./ui -f ./ui/Dockerfile

container-image-ui-push: container-image-ui
$(CONTAINER_RUNTIME) push $(CONSOLE_UI_IMAGE)

container-images: container-image-api container-image-ui

compose-up: container-images
container-images-push: container-image-api-push container-image-ui-push

compose-up:
> compose-runtime.env
echo "CONSOLE_API_IMAGE=$(CONSOLE_API_IMAGE)" >> compose-runtime.env
echo "CONSOLE_API_SERVICE_ACCOUNT_TOKEN=$(CONSOLE_API_SERVICE_ACCOUNT_TOKEN)" >> compose-runtime.env
echo "CONSOLE_API_KUBERNETES_API_SERVER_URL=$(CONSOLE_API_KUBERNETES_API_SERVER_URL)" >> compose-runtime.env
echo "CONSOLE_UI_IMAGE=$(CONSOLE_UI_IMAGE)" >> compose-runtime.env
echo "CONSOLE_UI_NEXTAUTH_SECRET=$(CONSOLE_UI_NEXTAUTH_SECRET)" >> compose-runtime.env
docker compose --env-file compose-runtime.env up -d
$(CONTAINER_RUNTIME) compose --env-file compose-runtime.env up -d

compose-down:
docker compose --env-file compose-runtime.env down
$(CONTAINER_RUNTIME) compose --env-file compose-runtime.env down
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,38 @@ It is composed of two main parts:
The console application may either be run in a Kubernetes cluster or locally to try it out.

### Install to Kubernetes

Please refer to the [installation README](./install/README.md) file for detailed information about how to install the latest release of the console in a Kubernetes cluster.

### Run locally

Running the console locally requires the use of a remote or locally-running Kubernetes cluster that hosts the Strimzi Kafka operator
and any Apache Kafka™ clusters that will be accessed from the console. To get started, you will need to provide a console configuration
file and credentials to connect to the Kubernetes cluster where Strimzi and Kafka are available.

1. Using the [console-config-example.yaml](./console-config-example.yaml) file as an example, create your own configuration
in a file `console-config.yaml` in the repository root. The `compose.yaml` file expects this location to be used and
and difference in name or location requires an adjustment to the compose file.

2. Provide the API server endpoint and service account token that you would like to use to connect to the Kubernetes cluster. These
may be placed in a `compose.env` file that will be detected when starting the console.
```
CONSOLE_API_SERVICE_ACCOUNT_TOKEN=<TOKEN>
CONSOLE_API_KUBERNETES_API_SERVER_URL=https://my-kubernetes-api.example.com:6443
```
The service account token may be obtain using the `kubectl create token` command. For example, to create a token
that expires in 1 year:
```shell
kubectl create token <service account name> -n <service account namespace> --duration=$((365*24))h
```

3. By default, the provided configuration will use the latest console release container images. If you would like to
build your own images with changes you've made locally, you may also set the `CONSOLE_API_IMAGE` and `CONSOLE_UI_IMAGE`
in your `compose.env` and build them with `make container-images`

4. Start the environment with `make compose-up`.

5. When finished with the local console process, you may run `make compose-down` to clean up.

## Contributing

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public class KafkaClusterConfig {
private String name;
private String namespace;
private String listener;
private boolean readOnly;
private Map<String, String> properties = new HashMap<>();
private Map<String, String> adminProperties = new HashMap<>();
private Map<String, String> consumerProperties = new HashMap<>();
Expand Down Expand Up @@ -45,14 +44,6 @@ public void setListener(String listener) {
this.listener = listener;
}

public boolean isReadOnly() {
return readOnly;
}

public void setReadOnly(boolean readOnly) {
this.readOnly = readOnly;
}

public Map<String, String> getProperties() {
return properties;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

public class KafkaConfig {

List<SchemaRegistryConfig> schemaRegistries = new ArrayList<>();
List<KafkaClusterConfig> clusters = new ArrayList<>();

@JsonIgnore
Expand All @@ -18,14 +17,6 @@ public Optional<KafkaClusterConfig> getCluster(String clusterKey) {
.findFirst();
}

public List<SchemaRegistryConfig> getSchemaRegistries() {
return schemaRegistries;
}

public void setSchemaRegistries(List<SchemaRegistryConfig> schemaRegistries) {
this.schemaRegistries = schemaRegistries;
}

public List<KafkaClusterConfig> getClusters() {
return clusters;
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ public Map<String, String> start() {
bootstrap.servers: %s
- name: test-kafka3
namespace: default
# listener is named and bootstrap.servers not set (will be retrieved from Kafka CR)
listener: listener0
properties:
bootstrap.servers: %s
security.protocol: SSL
""".formatted(
externalBootstrap,
Expand Down

0 comments on commit 93be789

Please sign in to comment.