Christmas-Community icon indicating copy to clipboard operation
Christmas-Community copied to clipboard

DNS resolution in k8s

Open BigPig22 opened this issue 1 year ago • 3 comments

The docker alpine image is known for problems with dns resolution in k8s.

Can you therefore please add either the bind-tools packages via apk install or switch to the slim version of the node base image?

See: https://stackoverflow.com/questions/65181012/does-alpine-have-known-dns-issue-within-kubernetes

BigPig22 avatar Dec 17 '23 19:12 BigPig22

It looks like installing bind-tools on alpine only fixes the shell commands but won't fix node. I'll need to build a debian-based image.

Wingysam avatar Dec 17 '23 21:12 Wingysam

I can offer a Dockerfile (create PR) for a distroless image I got working for Christams-Community-Groups v1.35.0 (and therefore should work for Christams-Community v1.35.0 at least) but then never used since it only decreased the size by 20 MB

jskiddie avatar Dec 17 '23 23:12 jskiddie

@BigPig22 sorry forgot to comment, if you want you can try, but I only tested it on 1.35.0 not nightly, add "node-fetch": "^2.7.0", to package.json if you run into problems (e.g. Error [ERR_REQUIRE_ESM]: Must use import to load ES Module:)

FROM node:20-alpine as builder-distroless

RUN apk --no-cache add curl
#  RUN apk --no-cache add touch

ENV NODE_ENV production
ENV PORT 80
ENV DB_EXPOSE_PORT 8080
ENV DB_PREFIX /data/dbs/
ENV SECRET_DIRNAME /data

WORKDIR /usr/src/app
COPY . .
RUN npm install --production --silent \
    && mkdir -p /data/dbs
RUN touch /data/dbs/.dockerkeep
#RUN npm run build

#ENV NODE_ENV=production
#WORKDIR /app/express
#RUN npm install
RUN curl -sf https://gobinaries.com/tj/node-prune | /bin/sh && \
    node-prune


# Tag as :distroless and :<version>-distroless
# build this version using --target release-distroless 
FROM gcr.io/distroless/nodejs20-debian11 as release-distroless

#COPY --from=builder-distroless /app/react/build /app/react/build
COPY --from=builder-distroless /usr/src/app/node_modules /usr/src/app/node_modules
COPY --from=builder-distroless /data/dbs /data/dbs
COPY --from=builder-distroless /usr/src/app/src /usr/src/app/src
COPY --from=builder-distroless /usr/src/app/package.json usr/src/app/package.json

WORKDIR /usr/src/app
EXPOSE 80
CMD ["src/index.js"]

jskiddie avatar Mar 01 '24 20:03 jskiddie