是否可以将redis模块(redisbloom)加载到redis helm图表(bitnami/redis或bitnami/redis-cluster)上?

问题描述 投票:0回答:3

我正在尝试将 redisbloom 模块添加到 redis helm 图表 (bitnami/redis),或者理想情况下添加到 redis cluster 图表 (bitnami/redis-cluster)。

# Chart.yaml

apiVersion: v2
name: my-app
description: My app and redis (with redisbloom module loaded)
type: application
version: 0.1.0
appVersion: 0.1.0
dependencies:
  - name: redis
    alias: redisbloom
    version: 12.1.1
    repository: https://charts.bitnami.com/bitnami

将已编译的模块

redisbloom.so
复制到每个pod,然后在启动后或使用
master.command=redis-server --load-module=<path>/redisbloom.so
加载模块似乎可能是一个潜在的解决方案 - 但是从文档中我看不到如何复制二进制文件图表。

我也不确定这本身是否足以满足主从或集群情况的工作。这个Github问题表明应该可以做到 - 但可惜我找不到支持它的文档。

可能吗?或者我是否需要创建一个自定义图表,例如使用 RedisBloom docker 映像 [redislabs/rebloom]?

提前致谢。

kubernetes redis kubernetes-helm
3个回答
4
投票

我认为您需要基于具有所需模块的 bitnami 映像构建自定义 Redis 映像,然后使用 extraVars var 指定您的模块,例如: --loadmodule /usr/lib/redis/modules/redisearch.so

我的 Dockerfile(我需要有 redisearch 模块):

#### My customization
FROM redislabs/redisearch:latest AS moduleimg
#### End of
FROM docker.io/bitnami/minideb:buster
LABEL maintainer "Bitnami <[email protected]>"

ENV HOME="/" \
    OS_ARCH="amd64" \
    OS_FLAVOUR="debian-10" \
    OS_NAME="linux"

COPY prebuildfs /
# Install required system packages and dependencies
RUN install_packages acl ca-certificates curl gzip libc6 libssl1.1 procps tar wget
RUN . /opt/bitnami/scripts/libcomponent.sh && component_unpack "wait-for-port" "1.0.0-3" --checksum 7521d9a4f9e4e182bf32977e234026caa7b03759799868335bccb1edd8f8fd12
RUN . /opt/bitnami/scripts/libcomponent.sh && component_unpack "redis" "6.2.1-0" --checksum c104089841a906f944e285828a580968608017340b67befaa1771646cbfdf6b3
RUN . /opt/bitnami/scripts/libcomponent.sh && component_unpack "gosu" "1.12.0-2" --checksum 4d858ac600c38af8de454c27b7f65c0074ec3069880cb16d259a6e40a46bbc50
RUN chmod g+rwX /opt/bitnami
RUN ln -s /opt/bitnami/scripts/redis/entrypoint.sh /entrypoint.sh
RUN ln -s /opt/bitnami/scripts/redis/run.sh /run.sh

COPY rootfs /
RUN /opt/bitnami/scripts/redis/postunpack.sh
ENV BITNAMI_APP_NAME="redis" \
    BITNAMI_IMAGE_VERSION="6.2.1-debian-10-r14" \
    PATH="/opt/bitnami/common/bin:/opt/bitnami/redis/bin:$PATH"

### My customization
RUN mkdir /opt/bitnami/redis/modules
COPY --from=moduleimg /usr/lib/redis/modules/redisearch.so* /opt/bitnami/redis/modules
### End of

EXPOSE 6379

USER 1001
ENTRYPOINT [ "/opt/bitnami/scripts/redis/entrypoint.sh" ]
CMD [ "/opt/bitnami/scripts/redis/run.sh" ]

0
投票

我会使用自定义图像,例如:

FROM redislabs/rebloom:latest as builder

FROM bitnami/redis:6.2.10
COPY --from=builder /usr/lib/redis/modules/redisbloom.so /usr/lib/redis/modules/redisbloom.so

CMD ["/run.sh", "--loadmodule", "/usr/lib/redis/modules/redisbloom.so"]

0
投票

在我的想法中,您必须基于具有所需模块的 bitnami Redis 映像构建自定义 Redis 映像,之后,您必须在 helm 图表配置上添加一些配置以加载自定义模块,这是 redisearch 的完整示例:

# Copyright VMware, Inc.
# SPDX-License-Identifier: APACHE-2.0
FROM redislabs/redisearch:latest AS searchmoduleimg


FROM docker.io/bitnami/minideb:bullseye

ARG TARGETARCH

LABEL com.vmware.cp.artifact.flavor="sha256:1e1b4657a77f0d47e9220f0c37b9bf7802581b93214fff7d1bd2364c8bf22e8e" \
      org.opencontainers.image.base.name="docker.io/bitnami/minideb:bullseye" \
      org.opencontainers.image.created="2023-11-09T18:25:18Z" \
      org.opencontainers.image.description="Application packaged by VMware, Inc" \
      org.opencontainers.image.licenses="Apache-2.0" \
      org.opencontainers.image.ref.name="7.2.3-debian-11-r1" \
      org.opencontainers.image.title="redis" \
      org.opencontainers.image.vendor="VMware, Inc." \
      org.opencontainers.image.version="7.2.3"

ENV HOME="/" \
    OS_ARCH="${TARGETARCH:-amd64}" \
    OS_FLAVOUR="debian-11" \
    OS_NAME="linux"

COPY prebuildfs /
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
# Install required system packages and dependencies
RUN install_packages ca-certificates curl libgomp1 libssl1.1 procps
RUN mkdir -p /tmp/bitnami/pkg/cache/ && cd /tmp/bitnami/pkg/cache/ && \
    COMPONENTS=( \
      "wait-for-port-1.0.7-3-linux-${OS_ARCH}-debian-11" \
      "redis-7.2.3-1-linux-${OS_ARCH}-debian-11" \
    ) && \
    for COMPONENT in "${COMPONENTS[@]}"; do \
      if [ ! -f "${COMPONENT}.tar.gz" ]; then \
        curl -SsLf "https://downloads.bitnami.com/files/stacksmith/${COMPONENT}.tar.gz" -O ; \
        curl -SsLf "https://downloads.bitnami.com/files/stacksmith/${COMPONENT}.tar.gz.sha256" -O ; \
      fi && \
      sha256sum -c "${COMPONENT}.tar.gz.sha256" && \
      tar -zxf "${COMPONENT}.tar.gz" -C /opt/bitnami --strip-components=2 --no-same-owner --wildcards '*/files' && \
      rm -rf "${COMPONENT}".tar.gz{,.sha256} ; \
    done
RUN apt-get autoremove --purge -y curl && \
    apt-get update && apt-get upgrade -y && \
    apt-get clean && rm -rf /var/lib/apt/lists /var/cache/apt/archives
RUN chmod g+rwX /opt/bitnami
RUN ln -s /opt/bitnami/scripts/redis/entrypoint.sh /entrypoint.sh
RUN ln -s /opt/bitnami/scripts/redis/run.sh /run.sh

COPY rootfs /
RUN /opt/bitnami/scripts/redis/postunpack.sh
ENV APP_VERSION="7.2.3" \
    BITNAMI_APP_NAME="redis" \
    PATH="/opt/bitnami/common/bin:/opt/bitnami/redis/bin:$PATH"

### My customization
RUN mkdir /opt/bitnami/redis/modules
COPY --from=searchmoduleimg /usr/lib/redis/modules/redisearch.so* /opt/bitnami/redis/modules

### End of

EXPOSE 6379

USER 1001
ENTRYPOINT [ "/opt/bitnami/scripts/redis/entrypoint.sh" ]
CMD [ "/opt/bitnami/scripts/redis/run.sh"]

构建 iamge 后,将这些行添加到 script-config.yaml 中的 start-master.sh 和 start-replica.sh 中:

exec redis-server \
--loadmodule /opt/bitnami/redis/modules/redisearch.so MAXSEARCHRESULTS 10000 MAXAGGREGATERESULTS 10000 \
"${ARGS[@]}"
{{- end }}

现在您可以使用自定义 mosule。

© www.soinside.com 2019 - 2024. All rights reserved.