You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "maranmaran (via GitHub)" <gi...@apache.org> on 2024/05/03 15:52:28 UTC

[PR] feat: support seeding default superuser via application.properties [pulsar-manager]

maranmaran opened a new pull request, #565:
URL: https://github.com/apache/pulsar-manager/pull/565

   Fixes #563 
   
   ### Motivation
   
   I'm working on integrating apache pulsar into [.NET Aspire](https://github.com/dotnet/aspire)
   Next to pulsar I wish to deliver a management UI, pulsar manager. Like Kafka and Rabbit do.
   
   Here's [my implementation](https://github.com/maranmaran/aspire/tree/feature/hosting-apache-pulsar/src/Aspire.Hosting.Apache.Pulsar)
   
   Right now, in order for me to seed default superuser, I must do this gymnastics of waiting for container and backend to be ready then acquire token, then issue put request.
   
   This is clumsy a little and there should be a way to provide some default superuser via configuration. Like rabbit does, SQL, bunch of other tools.
   
   In particular I'm afraid that Aspire team [won't accept a solution like this one](https://github.com/maranmaran/aspire/blob/feature/hosting-apache-pulsar/src/Aspire.Hosting.Apache.Pulsar/PulsarManagerSeedDefaultSuperUser.cs)
   
   Where I subscribe lifecycle hooks of container and then retry loop till I seed the user.
   It works, but it feels too "hacky"
   
   ### Modifications
   
   In `PulsarApplicationListener` implemented `seedDefaultSuperuser`
   
   ### Verifying this change
   
   - [x] Make sure that the change passes the `./gradlew build` checks.
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: support seeding default superuser via application.properties [pulsar-manager]

Posted by "pmunin (via GitHub)" <gi...@apache.org>.
pmunin commented on PR #565:
URL: https://github.com/apache/pulsar-manager/pull/565#issuecomment-2538783793

   for those who are interested in using master version of the image, but does not want too much hassle with local build, here is the workaround:
   
   docker-compose.yaml:
   ```yaml
     pulsar:
       ...
     pulsar-manager:
       build:
         context: https://github.com/apache/pulsar-manager.git#master
         dockerfile: ${PWD}/pulsar-manager.Dockerfile
       ports:
         - "9527:9527"
         - "7750:7750"
       depends_on:
         pulsar:
           condition: service_healthy
       environment:
         SPRING_CONFIGURATION_FILE: /pulsar-manager/custom-config/application.properties
       volumes:
         - ./custom-config:/pulsar-manager/custom-config
   ```
   
   In your project folder (where you run `docker compose up -d`) you create a pulsar-manager.Dockerfile:
   ```Dockerfile
   # # Stage 1: Build the application
   FROM openjdk:8-jdk AS builder
   
   # Install build tools including Node.js for front-end build
   RUN apt-get update && \
       apt-get install -y git curl && \
       curl -fsSL https://deb.nodesource.com/setup_16.x | bash - && \
       apt-get install -y nodejs && \
       npm install -g yarn
   
   WORKDIR /pulsar-manager
   COPY . .
   
   # ENV NODE_OPTIONS=--openssl-legacy-provider
   RUN cd front-end && npm install && npm run build:prod
   
   # # Build the backend
   RUN set -eux; apt-get update; apt-get install -y --no-install-recommends ca-certificates curl netbase wget ; rm -rf /var/lib/apt/lists/*
   RUN set -ex; if ! command -v gpg > /dev/null; then apt-get update; apt-get install -y --no-install-recommends gnupg dirmngr ; rm -rf /var/lib/apt/lists/*; fi
   RUN set -eux; apt-get update; apt-get install -y --no-install-recommends bzip2 unzip xz-utils fontconfig libfreetype6 ca-certificates p11-kit ; rm -rf /var/lib/apt/lists/*
   ENV JAVA_HOME=/usr/local/openjdk-8
   RUN { echo '#/bin/sh'; echo 'echo "$JAVA_HOME"'; } > /usr/local/bin/docker-java-home && chmod +x /usr/local/bin/docker-java-home && [ "$JAVA_HOME" = "$(docker-java-home)" ] # backwards compatibility
   ENV PATH=/usr/local/openjdk-8/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
   ENV LANG=C.UTF-8
   ENV JAVA_VERSION=8u342
   RUN set -eux; arch="$(dpkg --print-architecture)"; case "$arch" in 'amd64') downloadUrl='https://github.com/AdoptOpenJDK/openjdk8-upstream-binaries/releases/download/jdk8u342-b07/OpenJDK8U-jre_x64_linux_8u342b07.tar.gz'; ;; 'arm64') downloadUrl='https://github.com/AdoptOpenJDK/openjdk8-upstream-binaries/releases/download/jdk8u342-b07/OpenJDK8U-jre_aarch64_linux_8u342b07.tar.gz'; ;; *) echo >&2 "error: unsupported architecture: '$arch'"; exit 1 ;; esac; wget --progress=dot:giga -O openjdk.tgz "$downloadUrl"; wget --progress=dot:giga -O openjdk.tgz.asc "$downloadUrl.sign"; export GNUPGHOME="$(mktemp -d)"; gpg --batch --keyserver keyserver.ubuntu.com --recv-keys EAC843EBD3EFDB98CC772FADA5CD6035332FA671; gpg --batch --keyserver keyserver.ubuntu.com --keyserver-options no-self-sigs-only --recv-keys CA5F11C6CE22644D42C6AC4492EF8D39DC13168F; gpg --batch --list-sigs --keyid-format 0xLONG CA5F11C6CE22644D42C6AC4492EF8D39DC13168F | tee /dev/stderr | grep '0xA5CD6035332FA671' | grep 'Andrew 
 Haley'; gpg --batch --verify openjdk.tgz.asc openjdk.tgz; gpgconf --kill all; rm -rf "$GNUPGHOME"; mkdir -p "$JAVA_HOME"; tar --extract --file openjdk.tgz --directory "$JAVA_HOME" --strip-components 1 --no-same-owner ; rm openjdk.tgz*; { echo '#!/usr/bin/env bash'; echo 'set -Eeuo pipefail'; echo 'trust extract --overwrite --format=java-cacerts --filter=ca-anchors --purpose=server-auth "$JAVA_HOME/lib/security/cacerts"'; } > /etc/ca-certificates/update.d/docker-openjdk; chmod +x /etc/ca-certificates/update.d/docker-openjdk; /etc/ca-certificates/update.d/docker-openjdk; find "$JAVA_HOME/lib" -name '*.so' -exec dirname '{}' ';' | sort -u > /etc/ld.so.conf.d/docker-openjdk.conf; ldconfig; java -version
   RUN ./gradlew build -x test 
   
   # ================================ Mostly original https://github.com/apache/pulsar-manager/blob/master/docker/Dockerfile  ================================
   FROM eclipse-temurin:17-jre-jammy
   COPY --from=builder /pulsar-manager /pulsar-manager
   
   # ARG BUILD_DATE
   # ARG VCS_REF
   # ARG VERSION
   # LABEL org.label-schema.build-date=$BUILD_DATE \
   #       org.label-schema.name="Apache Pulsar Manager" \
   #       org.label-schema.description="An Apache Pulsar Manager for management Pulsar clusters" \
   #       org.label-schema.url="https://github.com/apache/pulsar-manager" \
   #       org.label-schema.vcs-ref=$VCS_REF \
   #       org.label-schema.vcs-url="https://github.com/apache/pulsar-manager" \
   #       org.label-schema.vendor="Apache Software Foundation" \
   #       org.label-schema.version=$VERSION \
   #       org.label-schema.schema-version="1.0"
   
   RUN apt-get update
   
   RUN apt-get install --yes nginx supervisor postgresql \
     && rm  -rf /tmp/* \
     && rm -rf /var/lib/apt/lists/*
   
   RUN mkdir -p /run/nginx
   
   WORKDIR /pulsar-manager
   
   RUN ls -Al /pulsar-manager/build/distributions/pulsar-manager.tar
   
   COPY --from=builder /pulsar-manager/build/distributions/pulsar-manager.tar .
   
   RUN tar -xf pulsar-manager.tar
   
   RUN rm -r pulsar-manager.tar
   
   COPY docker/supervisord.conf /etc/
   
   COPY docker/supervisord-token.conf /etc/
   
   COPY docker/supervisord-private-key.conf /etc/
   
   COPY docker/supervisord-secret-key.conf /etc/
   
   COPY docker/supervisord-configuration-file.conf /etc/
   
   COPY docker/default.conf /etc/nginx/conf.d/
   
   COPY docker/startup.sh /pulsar-manager/
   
   COPY docker/init_db.sql /pulsar-manager/
   
   COPY docker/entrypoint.sh /pulsar-manager/
   
   COPY --from=builder /pulsar-manager/front-end/dist /usr/share/nginx/html/
   
   ENTRYPOINT [ "/pulsar-manager/entrypoint.sh" ]
   ```
   
   And in your project folder you also create a `custom-config/application.properties` templating it from [src/main/resources/application.properties](https://github.com/apache/pulsar-manager/blob/master/src/main/resources/application.properties)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: support seeding default superuser via application.properties [pulsar-manager]

Posted by "eolivelli (via GitHub)" <gi...@apache.org>.
eolivelli commented on PR #565:
URL: https://github.com/apache/pulsar-manager/pull/565#issuecomment-2538342740

   can you please ask on dev@pulsar.apache.org  for the release ?
   
   we don't have a time based release, we do releases only when there is someone who needs them (or in case of security hotfixes, of course)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: support seeding default superuser via application.properties [pulsar-manager]

Posted by "pmunin (via GitHub)" <gi...@apache.org>.
pmunin commented on PR #565:
URL: https://github.com/apache/pulsar-manager/pull/565#issuecomment-2538337619

   thanks for doing this. When is this going to be released (new image version pushed to docker)?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: support seeding default superuser via application.properties [pulsar-manager]

Posted by "maranmaran (via GitHub)" <gi...@apache.org>.
maranmaran commented on PR #565:
URL: https://github.com/apache/pulsar-manager/pull/565#issuecomment-2093730646

   👋 👋 @lhotari Hey man, some tiny hiccups, I just adjusted my IDE and am good to go. 
   The build and tests should be okay now (`./gradlew build  ✅ `).
   
   I have another [branch ready to update docs](https://github.com/maranmaran/pulsar-manager/tree/docs/default-superuser?tab=readme-ov-file#setting-up-super-user) about this change.
   
   Additionally, I have experienced this https://github.com/apache/pulsar-manager/issues/567 and I can't run the backend.
   I have some proposal fix for it. Would you be so kind and just put some 👀 on the GH issue?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] feat: support seeding default superuser via application.properties [pulsar-manager]

Posted by "lhotari (via GitHub)" <gi...@apache.org>.
lhotari merged PR #565:
URL: https://github.com/apache/pulsar-manager/pull/565


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org