合流kafka dotnet kerberos支持dockerfile(没有sasl机制gssapi的提供程序)

4ktjp1zp  于 2021-06-04  发布在  Kafka
关注(0)|答案(1)|浏览(707)

我正在尝试创建一个dockerfile,它是一个kafka客户机,使用合流kafka dotnet。它必须使用kerberos键表来连接,因此我阅读了githubwiki。
这是我的文件:


# ---- dotnet build stage ----

FROM mcr.microsoft.com/dotnet/core/sdk:3.1 as build

ARG BUILDCONFIG=RELEASE
ARG VERSION=1.0.0

# Installing dependencies for li

RUN apt-get update && apt-get install libsasl2-modules-gssapi-mit libsasl2-dev unzip build-essential -y

COPY ./lib/ /
RUN unzip librdkafka-1.4.4.zip && \
    cd librdkafka-1.4.4 && \
    ./configure && \
    make && \
    make install

WORKDIR /build/

COPY ./DashboardServer/DashboardServer.csproj ./DashboardServer.csproj
RUN dotnet nuget add source https://ci.appveyor.com/nuget/docker-dotnet-hojfmn6hoed7 && \
    dotnet restore ./DashboardServer.csproj

COPY ./DashboardServer ./

RUN dotnet build && dotnet publish ./DashboardServer.csproj -c ${BUILDCONFIG} -o out /p:Version=${VERSION}

# ---- final stage ----

FROM ubuntu:20.04

LABEL Maintainer=""

ENV PROGRAM_HOME=/opt/DashboardServer
ENV ASPNETCORE_ENVIRONMENT=Production

RUN apt-get update && \
    apt-get install -y wget && wget https://packages.microsoft.com/config/ubuntu/19.10/packages-microsoft-prod.deb -O packages-microsoft-prod.deb && \
    dpkg --purge packages-microsoft-prod && dpkg -i packages-microsoft-prod.deb && \
    apt-get update && \
    apt-get install aspnetcore-runtime-3.1 curl -y

RUN export DEBIAN_FRONTEND=noninteractive && apt-get install libsasl2-modules-gssapi-mit libsasl2-dev -y krb5-user

# Kafka SASL directory (keytab is placed here)

RUN mkdir /sasl/

ENV KEYTAB_LOCATION=/sasl/dashboards.service.keytab

COPY --from=build /build/out ${PROGRAM_HOME}

# Copy necessary scripts + configuration

COPY scripts /tmp/
RUN chmod +x /tmp/*.sh && \
    mv /tmp/* /usr/bin && \
    rm -rf /tmp/*

CMD [ "docker-entrypoint.sh" ]

我的c#消费者配置代码如下:

var consumerConfig = new ConsumerConfig {
                GroupId = "command-server" + KafkaHelpers.Servername,
                BootstrapServers = KafkaHelpers.BootstrapServers,
                AutoOffsetReset = AutoOffsetReset.Latest,
                SecurityProtocol = SecurityProtocol.SaslPlaintext,
                SaslKerberosServiceName = "kafka",
                SaslKerberosKeytab = Environment.GetEnvironmentVariable("KEYTAB_LOCATION"),
                SaslKerberosPrincipal = "dashboardserver/<<IPAddress>>"
            };

但是当我启动我的客户机时,我得到以下例外

Unhandled exception. Unhandled exception. System.InvalidOperationException: No provider for SASL 
mechanism GSSAPI: recompile librdkafka with libsasl2 or openssl support. Current build options: PLAIN SASL_SCRAM OAUTHBEARER

有人能帮我解决问题或给我指出正确的方向吗?我在github上找到了这个,但我似乎无法让它工作。
我不知道如何一步一步地安装librdkafka。

dy1byipe

dy1byipe1#

confluent kafka dotnet依赖于librdkafka.redist,默认情况下从该位置加载librdkafka。librdkafka.redist中的构建缺乏对大多数平台的sasl/gssapi支持(由于libsasl2及其所有支持lib的依赖性问题),因此您构建自己的librdkafka版本的方法是正确的,但是您需要告诉confluent kafka dotnet加载您的librdkafka构建,而不是librdkafka.redist构建,你可以打电话来

Confluent.Kafka.Library.Load("/usr/local/lib/librdkafka.so");

在调用任何其他合流kafka dotnet api之前。

相关问题