記事に帰る

デブオプスと開発元の資源

資源のページにようこそ。ここには自分でいつもチェックしたいの事あります。 僕が居るたら他の人も居るかもしれないと思いました。 手伝えることを見つける欲しいんです。訂正か発案があれば連絡してください


免責事項

免責 ここにある事は全部参考のためにあります。 あなただけあなたのシステムを担当します。


目次

固めたクバネティスのデプロイメントマニフェスト

apiVersion: apps/v1
kind: Deployment
metadata:
  name: example-name
  labels:
    app: example-app-label
spec:
  selector:
    matchLabels:
      app: example-app-label
  template:
    metadata:
      labels:
        app: example-app-label
    spec:
      #prevent pod from having access to your cluster
      automountServiceAccountToken: false
      containers:
      - name: example-container-name
        image: example-image-name:latest
        imagePullPolicy: IfNotPresent
        securityContext:
          #disable the ability for a process in your pod to escalate it's privileges
          allowPrivilegeEscalation: false
          #drop all linux system capabilities
          capabilities:
            drop: ["ALL"]

Nodeのドカーイメージ根本のユーザーじゃなく使います

FROM node:22-bookworm-slim AS production
WORKDIR /my-app

ENV NODE_ENV=production
# Run as non-root user
RUN addgroup --gid 2002 --system nodejs && \
    adduser --system --uid 2002 --gid 2002 nodejs

# Copy files from local, build layer, etc then update permissions
# adjust to the folder containing all your files if you prefer
COPY --chown=nodejs:nodejs /my-app/node_modules ./node_modules
COPY --chown=nodejs:nodejs /my-app/dist ./dist
COPY --chown=nodejs:nodejs /my-app/package.json ./package.json

USER nodejs
#update with whatever yours needs to be
CMD ["node", "/my-app/index.js"]

強いデプロイメントのチェックリスト

  • ヘルスのチェックを扱う.
  • レディチェックを扱う.
  • デプロイメントのマニフェストにPreStopって言う
  • デプロイメントのマニフェストにterminationGracePeriodSecondsって言う
  • SIGTERMSIGKILLのシグナルを扱う