0

confluent-kafka- dotnet を使用して、kafka クライアントである dockerfile を作成しようとしています。接続には Kerberos キータブを使用する必要があるため、この Github wikiを読みました。

これが私のdockerfileです:

# ---- 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 を段階的にインストールする方法がわかりません。

4

1 に答える 1