diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..757fee3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.idea \ No newline at end of file diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 171763c..0000000 --- a/Dockerfile +++ /dev/null @@ -1,5 +0,0 @@ -FROM docker:stable - -COPY entrypoint.sh /entrypoint.sh -RUN chmod +x /entrypoint.sh -ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md index a1e96a5..3844699 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,33 @@ # redpanda github action -This [GitHub Action](https://github.com/features/actions) sets up Redpanda instance. +This [GitHub Action](https://github.com/features/actions) sets up Redpanda instance in Single Broker or Three Broker Cluster mode. -Docker images source [redpanda-data/redpanda](docker.vectorized.io/vectorized/redpanda). +Docker images source [redpanda-data/redpanda](https://hub.docker.com/r/redpandadata/redpanda). --------- # Usage See [action.yml](action.yml) -Basic: +Single Broker Mode: ```yaml - name: start redpanda - uses: redpanda-data/github-action@v0.1.3 + uses: redpanda-data/github-action@v1.0.0 with: version: "latest" + cluster_mode: "false" ``` +Now you should be able to connect to `redpanda` (kafka-api) running at `localhost:19092` -Now you should be able to connect to `redpanda` (kafka-api) running at `localhost:9092` - +Cluster Mode: +```yaml + - name: start redpanda + uses: redpanda-data/github-action@v1.0.0 + with: + version: "latest" + cluster_mode: "true" +``` +Now you should be able to connect to `redpanda` (kafka-api) running at `localhost:19092,localhost:29092,localhost:39092` ---------- @@ -133,10 +142,10 @@ sudo yum install redpanda ## Beta releases on Docker -This is an example with the `v21.3.5-beta3` version prior to the 21.3.5 release. +This is an example with the `v24.2.14` version prior to the `24.2.11` release. ``` # example! -docker.vectorized.io/vectorized/redpanda:v21.3.5-beta3 +redpandadata/redpanda:v24.2.12 ``` diff --git a/action.yml b/action.yml index 7f2dd73..288ef15 100644 --- a/action.yml +++ b/action.yml @@ -1,6 +1,6 @@ name: "redpanda-action" -description: "Setup Redpanda" -author: "fernandes" +description: "Setup Redpanda Single or Cluster Mode" +author: "Debabrata Patnaik/Celso Fernandes/Alexander Gallego" branding: icon: fast-forward color: red @@ -9,6 +9,34 @@ inputs: description: "Version of Redpanda to use" required: false default: "latest" + cluster_mode: + description: "Whether to run Redpanda in three node cluster mode" + required: false + default: "false" runs: - using: "docker" - image: "Dockerfile" + using: composite + steps: + - name: Cluster Input Details + shell: bash + run: | + echo "Starting redpanda broker/cluster with version: redpandadata/redpanda:${{ inputs.version }}" + echo "Cluster Mode: ${{ inputs.cluster_mode }}" + - name: Start Redpanda Single Node Broker + if: inputs.cluster_mode != 'true' + run: REDPANDA_IMAGE_TAG="${{ inputs.version }}" docker compose -f ${{ github.action_path }}/docker-compose-single.yml up -d + shell: bash + - name: Start Redpanda Three Node Cluster + shell: bash + if: inputs.cluster_mode == 'true' + run: REDPANDA_IMAGE_TAG="${{ inputs.version }}" docker compose -f ${{ github.action_path }}/docker-compose-three-node-cluster.yml up -d + - name: Print Redpanda cluster details + shell: bash + if: success() + run: | + echo "Redpanda configured" + echo "Container Details" + docker container ls | grep redpanda + echo "Network Details" + docker network ls | grep redpanda + echo "Volume Details" + docker volume ls | grep redpanda diff --git a/docker-compose-single.yml b/docker-compose-single.yml new file mode 100644 index 0000000..0c9448a --- /dev/null +++ b/docker-compose-single.yml @@ -0,0 +1,41 @@ +name: redpanda-quickstart-one-broker +networks: + redpanda_network: + driver: bridge +volumes: + redpanda-0: null +services: + redpanda-0: + command: + - redpanda + - start + - --kafka-addr internal://0.0.0.0:9092,external://0.0.0.0:19092 + # Address the broker advertises to clients that connect to the Kafka API. + # Use the internal addresses to connect to the Redpanda brokers' + # from inside the same Docker network. + # Use the external addresses to connect to the Redpanda brokers' + # from outside the Docker network. + - --advertise-kafka-addr internal://redpanda-0:9092,external://localhost:19092 + - --pandaproxy-addr internal://0.0.0.0:8082,external://0.0.0.0:18082 + # Address the broker advertises to clients that connect to the HTTP Proxy. + - --advertise-pandaproxy-addr internal://redpanda-0:8082,external://localhost:18082 + - --schema-registry-addr internal://0.0.0.0:8081,external://0.0.0.0:18081 + # Redpanda brokers use the RPC API to communicate with each other internally. + - --rpc-addr redpanda-0:33145 + - --advertise-rpc-addr redpanda-0:33145 + # Mode dev-container uses well-known configuration properties for development in containers. + - --mode dev-container + # Tells Seastar (the framework Redpanda uses under the hood) to use 1 core on the system. + - --smp 1 + - --default-log-level=info + image: docker.redpanda.com/redpandadata/redpanda:${REDPANDA_IMAGE_TAG} + container_name: redpanda-0 + volumes: + - redpanda-0:/var/lib/redpanda/data + networks: + - redpanda_network + ports: + - 18081:18081 + - 18082:18082 + - 19092:19092 + - 19644:9644 \ No newline at end of file diff --git a/docker-compose-three-node-cluster.yml b/docker-compose-three-node-cluster.yml new file mode 100644 index 0000000..3acaeed --- /dev/null +++ b/docker-compose-three-node-cluster.yml @@ -0,0 +1,98 @@ +networks: + redpanda_network: + driver: bridge +volumes: + redpanda-0: null + redpanda-1: null + redpanda-2: null +services: + redpanda-0: + command: + - redpanda + - start + - --kafka-addr internal://0.0.0.0:9092,external://0.0.0.0:19092 + # Address the broker advertises to clients that connect to the Kafka API. + # Use the internal addresses to connect to the Redpanda brokers' + # from inside the same Docker network. + # Use the external addresses to connect to the Redpanda brokers' + # from outside the Docker network. + - --advertise-kafka-addr internal://redpanda-0:9092,external://localhost:19092 + - --pandaproxy-addr internal://0.0.0.0:8082,external://0.0.0.0:18082 + # Address the broker advertises to clients that connect to the HTTP Proxy. + - --advertise-pandaproxy-addr internal://redpanda-0:8082,external://localhost:18082 + - --schema-registry-addr internal://0.0.0.0:8081,external://0.0.0.0:18081 + # Redpanda brokers use the RPC API to communicate with each other internally. + - --rpc-addr redpanda-0:33145 + - --advertise-rpc-addr redpanda-0:33145 + # Mode dev-container uses well-known configuration properties for development in containers. + - --mode dev-container + # Tells Seastar (the framework Redpanda uses under the hood) to use 1 core on the system. + - --smp 1 + - --default-log-level=info + image: docker.redpanda.com/redpandadata/redpanda:${REDPANDA_IMAGE_TAG} + container_name: redpanda-0 + volumes: + - redpanda-0:/var/lib/redpanda/data + networks: + - redpanda_network + ports: + - 18081:18081 + - 18082:18082 + - 19092:19092 + - 19644:9644 + redpanda-1: + command: + - redpanda + - start + - --kafka-addr internal://0.0.0.0:9092,external://0.0.0.0:29092 + - --advertise-kafka-addr internal://redpanda-1:9092,external://localhost:29092 + - --pandaproxy-addr internal://0.0.0.0:8082,external://0.0.0.0:28082 + - --advertise-pandaproxy-addr internal://redpanda-1:8082,external://localhost:28082 + - --schema-registry-addr internal://0.0.0.0:8081,external://0.0.0.0:28081 + - --rpc-addr redpanda-1:33145 + - --advertise-rpc-addr redpanda-1:33145 + - --mode dev-container + - --smp 1 + - --default-log-level=info + - --seeds redpanda-0:33145 + image: docker.redpanda.com/redpandadata/redpanda:${REDPANDA_IMAGE_TAG} + container_name: redpanda-1 + volumes: + - redpanda-1:/var/lib/redpanda/data + networks: + - redpanda_network + ports: + - 28081:28081 + - 28082:28082 + - 29092:29092 + - 29644:9644 + depends_on: + - redpanda-0 + redpanda-2: + command: + - redpanda + - start + - --kafka-addr internal://0.0.0.0:9092,external://0.0.0.0:39092 + - --advertise-kafka-addr internal://redpanda-2:9092,external://localhost:39092 + - --pandaproxy-addr internal://0.0.0.0:8082,external://0.0.0.0:38082 + - --advertise-pandaproxy-addr internal://redpanda-2:8082,external://localhost:38082 + - --schema-registry-addr internal://0.0.0.0:8081,external://0.0.0.0:38081 + - --rpc-addr redpanda-2:33145 + - --advertise-rpc-addr redpanda-2:33145 + - --mode dev-container + - --smp 1 + - --default-log-level=info + - --seeds redpanda-0:33145 + image: docker.redpanda.com/redpandadata/redpanda:${REDPANDA_IMAGE_TAG} + container_name: redpanda-2 + volumes: + - redpanda-2:/var/lib/redpanda/data + networks: + - redpanda_network + ports: + - 38081:38081 + - 38082:38082 + - 39092:39092 + - 39644:9644 + depends_on: + - redpanda-0 \ No newline at end of file diff --git a/entrypoint.sh b/entrypoint.sh deleted file mode 100644 index b699ae5..0000000 --- a/entrypoint.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -docker_run="docker run" - -run_redpanda="$docker_run -d -p 9092:9092 -p 9644:9644 vectorized/redpanda:${INPUT_VERSION} redpanda start --overprovisioned --smp 1 --memory 1G --reserve-memory 0M --node-id 0 --check=false" -sh -c "$run_redpanda"