๐Ÿ“—
smiley book
  • Smiley Books
  • AI
    • Readme
    • openai-whisper
      • ์ƒ˜ํ”Œ ์‹คํ–‰ํ•ด๋ณด๊ธฐ
      • GPU ์„œ๋ฒ„ ์ค€๋น„ํ•˜๊ธฐ
      • API๋กœ whisper๋ฅผ ์™ธ๋ถ€์— ์˜คํ”ˆํ•˜๊ธฐ
      • ํ”„๋กฌํ”„ํŠธ ์ง€์›
      • ์‹ค์‹œ๊ฐ„ message chat
      • ํ™”๋ฉด ์ด์˜๊ฒŒ ๋งŒ๋“ค๊ธฐ์™€ ๋กœ๊ทธ์ธ
      • ํŒŒ์ด์ฌ ๊ฐ€์ƒํ™˜๊ฒฝ
      • ์‹ค์‹œ๊ฐ„ voice chat
      • fine tunning(๋ฏธ์„ธ ์กฐ์ •) ์œผ๋กœ ์„ฑ๋Šฅ ์˜ฌ๋ฆฌ๊ธฐ
      • app์—์„œ api๋ฅผ ํ˜ธ์ถœํ•˜์—ฌ ์‹ค์‹œ๊ฐ„์œผ๋กœ ํ…์ŠคํŠธ๋กœ ๋ฐ”๊ฟ”๋ณด๊ธฐ
    • ollama - llm์„ ์‰ฝ๊ฒŒ ๋‚ด์ปด์—์„œ ์‹คํ–‰
      • ollama webui
      • ollama docker
    • stable diffusion
      • SDXL - text to image
      • SD-webui
    • ChatGPT
      • ๋‹ต๋ณ€์ด ๋Š๊ธธ๋•Œ
      • ์—ญํ• ์„ ์ •ํ•˜์ž
      • ๊ตฌ์ฒด์ ์ธ ์งˆ๋ฌธ
      • ๊ฒฐ๊ณผํ˜•ํƒœ๋ฅผ ์ง€์ •
      • ํ”„๋กฌํ”„ํŠธ๋ฅผ ์—ฌ๋Ÿฌ์ค„๋กœ ์‚ฌ์šฉํ•˜์ž.
      • ๋งˆํ‹ด ํŒŒ์šธ๋Ÿฌ ๊ธ€ ๋ฒˆ์—ญ๋ณธ
    • Prompt Engineering
    • Auto-GPT
    • Gemini
      • google ai studio
      • gemini-api
      • embedding guide
    • Huggingface
      • huggingface ์‚ฌ์šฉ๋ฒ•
      • huggingface nlp ๊ณต๋ถ€์ค‘
    • kaggle
      • download dataset
    • langchain
      • langchain์„ ๊ณต๋ถ€ํ•˜๋ฉฐ ์ •๋ฆฌ
      • basic
      • slackbot
      • rag
      • document-loader
      • website-loader
      • confluence
      • memory
      • function-call
      • langsmith
      • agent-toolkit
  • Ansible
    • templates vs files and jinja2
    • dynamic inventory
    • limit ์˜ต์…˜ ๊ฐ•์ œํ•˜๊ธฐ
    • limit ์‚ฌ์šฉํ›„ gather_fact ๋ฌธ์ œ
  • AWS
    • AWS CLI
    • EKS
      • cluster manage
      • ALB Controller
      • external-dns
      • fargate
    • ECR
    • S3
    • Certificate Manager
  • Azure
    • Azure AD OAuth Client Flow
  • Container
    • Registry
    • ๋นŒ๋“œ์‹œ์— env๊ฐ’ ์„ค์ •ํ•˜๊ธฐ
  • DB
    • PXC
      • Operator
      • PMM
      • ์‚ญ์ œ
      • GTID
      • Cross Site Replication
    • Mssql
    • Mysql
  • dotnet
    • Thread Pool
    • Connection Pool
    • Thread Pool2
  • Devops
    • Recommendation
  • GIT
    • Basic
    • Submodule
  • GitHub
    • Repository
    • GitHub Action
    • GitHub PR
    • Self Hosted Runner
    • GitHub Webhook
  • GitLab
    • CI/CD
    • CI/CD Advance
    • Ssl renew
    • CI/CD Pass env to other job
  • Go Lang
    • ๊ฐœ๋ฐœ ํ™˜๊ฒฝ ๊ตฌ์ถ•
    • multi os binary build
    • kubectl๊ฐ™์€ cli๋งŒ๋“ค๊ธฐ
    • azure ad cli
    • embed static file
    • go study
      • pointer
      • module and package
      • string
      • struct
      • goroutine
  • Kubernetes
    • Kubernetes๋Š” ๋ฌด์—‡์ธ๊ฐ€
    • Tools
    • Install with kubespray
    • Kubernetes hardening guidance
    • 11 ways not to get hacked
    • ArgoCD
      • Install
      • CLI
      • Repository
      • Apps
      • AWS ALB ์‚ฌ์šฉ
      • Notification slack
      • Backup / DR
      • Ingress
      • 2021-11-16 Github error
      • Server Config
      • auth0 ์ธ์ฆ ์ถ”๊ฐ€(oauth,OIDC)
    • Extension
      • Longhorn pvc
      • External dns
      • Ingress nginx
      • Cert Manager
      • Kube prometheus
    • Helm
      • Subchart
      • Tip
    • Loki
    • Persistent Volume
    • TIP
      • Job
      • Pod
      • Log
  • KAFKA
    • raft
  • KVM
    • kvm cpu model
  • Linux
    • DNS Bind9
      • Cert-Manager
      • Certbot
      • Dynamic Update
      • Log
    • Export and variable
    • Grep ์‚ฌ์šฉ๋ฒ•
  • Modeling
    • C4 model introduce
    • Mermaid
    • reference
  • Monitoring
    • Readme
    • 0. What is Monitoring
    • 1. install prometheus and grafana
    • 2. grafana provisioning
    • 3. grafana dashboard
    • 4. grafana portable dashboard
    • 5. prometheus ui
    • 6. prometheus oauth2
    • Prometheus
      • Metric type
      • basic
      • rate vs irate
      • k8s-prometheus
    • Grafana
      • Expolorer
    • Node Exporter
      • advance
      • textfile collector
  • Motivation
    • 3 Simple Rule
  • OPENNEBULA
    • Install(ansible)
    • Install
    • Tip
    • Windows vm
  • Reading
    • comfort zone
    • ๋ฐฐ๋ ค
    • elon musk 6 rule for insane productivity
    • Feynman Technique
    • how to interview - elon musk
    • ๊ฒฝ์ฒญ
    • Readme
  • Redis
    • Install
    • Master-slave Architecture
    • Sentinel
    • Redis Cluster
    • Client programming c#
  • SEO
    • Readme
  • Security
    • criminalip.io
      • criminalip.io
  • Stock
    • robinhood-python
  • Terraform
    • moved block
    • output
  • vault
    • Readme
  • VS Code
    • dev container
    • dev container on remote server
  • Old fashione trend
    • curity
    • MAAS
      • Install maas
      • Manage maas
      • Tip
Powered by GitBook
On this page
  • ์ด๋ฏธ์ง€ ํƒœ๊ทธ
  • delete completed pod
  • env๋ฅผ configmap์œผ๋กœ ์ด์šฉํ•˜๊ธฐ
  • envFrom๋ฅผ configmap์œผ๋กœ ์ด์šฉํ•˜๊ธฐ
  • securityContext
  • root container ์ฐจ๋‹จํ•˜๊ธฐ
  • readOnlyRootFile
  • ๊ถŒํ•œ ์ƒ์Šน ๋น„ํ™œ์„ฑํ™”
  • ์ปจํ…Œ์ด๋„ˆ ๋‹จ์œ„๋กœ ๊ถŒํ•œ ์„ค์ •

Was this helpful?

  1. Kubernetes
  2. TIP

Pod

PreviousJobNextLog

Last updated 1 year ago

Was this helpful?

์ด๋ฏธ์ง€ ํƒœ๊ทธ

์‚ฌ์šฉ์‹œ ๊ผญ ํƒœ๊ทธ ๋„˜๋ฒ„๋ฅผ ์‚ฌ์šฉ ์•„๋ฌด๊ฒƒ๋„ ์•ˆ์“ฐ๋ฉด latest๊ฐ€ ์ž๋™์œผ๋กœ ๋ถ™๋Š”๋‹ค.

latest ๋ฅผ ์‚ฌ์šฉํ•˜์ง€ ๋ง์ž. ๊ณ„์† ๋ฒ„์ „์ด ๋ฐ”๋€Œ๋ฏ€๋กœ ๋ฌธ์ œ๊ฐ€ ๋œ๋‹ค.

์‚ฌ์‹ค sha ํƒœ๊ทธ๋„ ์ค‘๋ณต์ด ๋œ๋‹ค. ๊ฐ€๋Šฅํ•˜๋ฉด container digest๋ฅผ ์‚ฌ์šฉํ•˜์ž.

digest๋Š” ์œ ์ผํ•˜๋‹ค.

docker image ls --digests

ํ™˜๊ฒฝ๋ณ€์ˆ˜์˜ ์ตœ๋Œ€๊ฐ’์€ 32KiB๋กœ ์ œํ•œ

delete completed pod

kubectl delete pod --field-selector=status.phase==Succeeded

env๋ฅผ configmap์œผ๋กœ ์ด์šฉํ•˜๊ธฐ

configmap ์ด ์žˆ๋Š” ์ƒํ™ฉ์—์„œ pod์—์„œ env๊ฐ’์œผ๋กœ configmap์„ ์ด์šฉํ•˜๊ธฐ

apiVersion: v1
kind: Pod
metadata:
  name: dapi-test-pod
spec:
  containers:
    - name: test-container
      image: k8s.gcr.io/busybox
      command: ['/bin/sh', '-c', 'env']
      env:
        # Define the environment variable
        - name: SPECIAL_LEVEL_KEY
          valueFrom:
            configMapKeyRef:
              # The ConfigMap containing the value you want to assign to SPECIAL_LEVEL_KEY
              name: special-config
              # Specify the key associated with the value
              key: special.how
  restartPolicy: Never

envFrom๋ฅผ configmap์œผ๋กœ ์ด์šฉํ•˜๊ธฐ

apiVersion: v1
kind: Pod
metadata:
  name: dapi-test-pod
spec:
  containers:
    - name: test-container
      image: k8s.gcr.io/busybox
      command: ['/bin/sh', '-c', 'env']
      envFrom:
        - configMapRef:
            name: special-config
  restartPolicy: Never

์ด๋ ‡๊ฒŒ ํ•˜๋ฉด configmap์— ์žˆ๋˜ ๋ชจ๋“  ๋‚ด์šฉ์ด env๊ฐ’์œผ๋กœ ๋ณ€ํ™˜๋œ๋‹ค.

securityContext

root๊ฐ€ ์•„๋‹Œ ์‚ฌ์šฉ์ž๋กœ ์ปจํ…Œ์ด๋„ˆ ์‹คํ–‰ํ•˜๊ธฐ

apiVersion: v1
kind: Pod
metadata:
  name: securityContext
spec:
  securityContext:
    runAsUser: 1000
    runAsGroup: 3000
    fsGroup: 2000

๋„์ปค ์ด๋ฏธ์ง€์—์„œ๋„ ์ง€์ •์ด ๊ฐ€๋Šฅํ•˜๋‚˜ ์ด๋ ‡๊ฒŒ ์ฟ ๋ฒ„๋„คํ‹ฐ์Šค์—์„œ ๋ณ€๊ฒฝ๋„ ๊ฐ€๋Šฅํ•˜๋‹ค.

1000๋ฒˆ์€ ๋ฆฌ๋ˆ…์Šค์—์„œ ์ฒ˜์Œ ์œ ์ €๊ฐ€ ๊ฐ€์ง€๋Š” ๋ฒˆํ˜ธ์ด๋ฏ€๋กœ 1000๋ฒˆ ์ด์ƒ์„ ์‚ฌ์šฉํ•˜๋Š”๊ฒŒ ์ข‹๋‹ค.

์ฟ ๋ฒ„๋„คํ‹ฐ์Šค๊ฐ€ ๋„์ปค์˜ ๋ชจ๋“  ์œ ์ € ์„ค์ •์„ ๋ฎ์–ด์“ด๋‹ค.

๊ฐ ์ปจํ…Œ์ด๋„ˆ๋งˆ๋‹ค ๋‹ค๋ฅธ uid๋ฅผ ์ถ”์ฒœํ•œ๋‹ค.

๋‘๊ฐœ์˜ ์ปจํ…Œ์ด๋„ˆ๊ฐ€ ๋™์ผํ•œ ๋ฐ์ดํ„ฐ์— ์ ‘๊ทผํ•˜๋ฉด uid๋Š” ๊ฐ™์•„์•ผํ•œ๋‹ค.

root container ์ฐจ๋‹จํ•˜๊ธฐ

์ฟ ๋ฒ„๋„คํ‹ฐ์Šค๊ฐ€ container๊ฐ€ root๋กœ ์‹คํ–‰๋˜๋Š”๊ฒƒ์„ ๋ฐฉ์ง€ํ•ด์ฃผ๋Š” ์˜ต์…˜์„ ์ œ๊ณต

apiVersion: v1
kind: Pod
# ...
spec:
  securityContext:
    runAsNonRoot: true

root๋กœ ์‹คํ–‰๋˜๋Š”๊ฒƒ์„ ๋ฐฉ์ง€ํ•ด์ค€๋‹ค.

CreateContainerConfigError: container 'root' is not allowed to run as root ๋ฐœ์ƒ

readOnlyRootFile

apiVersion: v1
kind: Pod
# ...
spec:
  securityContext:
    readOnlyRootFileSystem: true

์ปจํ…Œ์ด๋„ˆ์— ์“ฐ๊ธฐ ๊ถŒํ•œ์ด ํ•„์š”ํ•˜์ง€ ์•Š์œผ๋ฉด ์˜ต์…˜์„ ์‚ฌ์šฉํ•˜์ž.

๊ถŒํ•œ ์ƒ์Šน ๋น„ํ™œ์„ฑํ™”

apiVersion: v1
kind: Pod
# ...
spec:
  securityContext:
    allowPrivilegeEscalation: false

๋ฆฌ๋ˆ…์Šค ๋ฐ”์ด๋„ˆ๋ฆฌ๋Š” ์ด๋ฅผ ์‹คํ–‰ํ•œ ์‚ฌ์šฉ์ž์™€ ๊ฐ™์€ ๊ถŒํ•œ์œผ๋กœ ์‹คํ–‰๋œ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ์˜ˆ์™ธ๋Š” ์žˆ๋‹ค.

seuid ๋งค์ปค๋‹ˆ์ฆ์„ ์‚ฌ์šฉํ•˜๋ฉด ์ผ์‹œ์ ์œผ๋กœ ๋ฐ”์ด๋„ˆ๋ฆฌ๋ฅผ ์†Œ์œ ํ•œ ์‚ฌ์šฉ์ž(์ผ๋ฐ˜์ ์œผ๋กœ root)์˜ ๊ถŒํ•œ์œผ๋กœ ์‹คํ–‰ํ• ์ˆ˜ ์žˆ๋‹ค.

์ปจํ…Œ์ด๋„ˆ๋ฅผ ์ผ๋ฐ˜ ์‚ฌ์šฉ์ž๋กœ ์‹คํ–‰ํ•˜๋”๋ผ๋„ ์ปจํ…Œ์ด๋„ˆ๊ฐ€ setuid ๋ฐ”์ด๋„ˆ๋ฆฌ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ๊ฒฝ์šฐ์— ์ปจํ…Œ์ด๋„ˆ์—์„œ root ๊ถŒํ•œ์„ ์–ป์„์ˆ˜ ์ž‡์œผ๋ฏ€๋กœ ์ž ์žฌ์ ์ธ ๋ฌธ์ œ๊ฐ€ ๋œ๋‹ค. ์ด๋ฅผ ๋ฐฉ์ง€ํ•˜๊ธฐ์œ„ํ•ด allowPrivilegeEscalation ๋ฅผ ์‚ฌ์šฉํ•œ๋‹ค.

์ปจํ…Œ์ด๋„ˆ ๋‹จ์œ„๋กœ ๊ถŒํ•œ ์„ค์ •

์œ„ ์„ค์ •๋“ค์€ pod๊ฐ€ ์•„๋‹ˆ๋ผ ์ปจํ…Œ์ด๋„ˆ ์ˆ˜์ค€์œผ๋กœ ์˜ฌ๋ผ๊ฐˆ์ˆ˜๋„ ์žˆ๋‹ค.