K8S工具增强
1 node增强
1.1 Dockerfile.node
FROM node:22-alpine
# ==========================================
# 1. npm 配置
# ==========================================
RUN echo 'registry=http://nexus.cicd.svc.cluster.local:8081/repository/npm-public/' > /root/.npmrc && \
echo '//nexus.cicd.svc.cluster.local:8081/repository/npm-public/:_auth=YWRtaW46QXppMTIzLi4u' >> /root/.npmrc && \
echo 'always-auth=true' >> /root/.npmrc && \
echo 'strict-ssl=false' >> /root/.npmrc
# ==========================================
# 2. 安装 pnpm
# ==========================================
RUN npm config set registry https://registry.npmmirror.com && \
npm install -g pnpm@9.0.5 && \
npm config delete registry
# ==========================================
# 3. pnpm 配置(用 pnpm config set,不用 rc 文件)
# ==========================================
RUN pnpm config set registry http://nexus.cicd.svc.cluster.local:8081/repository/npm-public/ && \
pnpm config set //nexus.cicd.svc.cluster.local:8081/repository/npm-public/:_auth YWRtaW46QXppMTIzLi4u && \
pnpm config set always-auth true && \
pnpm config set strict-ssl false && \
pnpm config set store-dir /root/.local/share/pnpm/store # 明确缓存地址
# ==========================================
# 4. 创建缓存目录
# ==========================================
RUN mkdir -p /root/.local/share/pnpm/store
WORKDIR /app
1.2 构建镜像
docker build -f Dockerfile.node -t 10.13.8.27:30082/library/node:22-pnpm .
docker push 10.13.8.27:30082/library/node:22-pnpm
2 基础工具增强
FROM alpine:latest
RUN apk add --no-cache \
bash \
curl \
wget \
git \
jq \
yq \
sed \
grep \
tar \
gzip \
unzip \
openssh-client \
ca-certificates \
tzdata \
gettext \
parallel \
netcat-openbsd \
bind-tools \
iputils \
procps \
util-linux \
coreutils \
findutils \
tree \
vim \
nano
ENV PATH="/usr/bin:/usr/sbin:/bin:/sbin:/usr/local/bin"
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone
RUN mkdir -p /app /data /scripts
WORKDIR /app
2.2 构建镜像
docker build -f Dockerfile.cicd-tools -t 10.13.8.27:30082/library/cicd-tools:lastest .
docker push 10.13.8.27:30082/library/cicd-tools:lastest
3 基础工具增强
3.1 下载或者复制客户端
curl -LO "https://dl.k8s.io/release/v1.34.2/bin/linux/amd64/kubectl"
# cp /usr/bin/kubectl ./
3.2 Dockerfile.kubectl
FROM alpine:latest
COPY kubectl /usr/local/bin/kubectl
RUN chmod +x /usr/local/bin/kubectl && \
apk add --no-cache \
bash \
curl \
jq \
iputils \
procps \
yq \
vim \
grep \
netcat-openbsd \
coreutils \
gettext \
netcat-openbsd
ENTRYPOINT [""]
3.3 构建镜像
docker build -f Dockerfile.cicd-tools -t 10.13.8.27:30082/library/kubectl:1.34.2 .
docker push 10.13.8.27:30082/library/kubectl:1.34.2