Container Orchestration/Kubernetes

Kubernetes에 static-file-server 생성하기

Somaz 2025. 3. 24. 17:44
728x90
반응형

Overview

Kubernetes에 간단하게 static-file-server 생성하는 방법에 대해서 알아본다.

 

https://github.com/halverneus/static-file-server

 

 

 

 


 

 

 

 

Static File Server 설치

 

 

해당 Github 주소에 들어가서 내용을 읽어보면 Configuration에 Environment Variables, YAML Configuration File,

그리고 Deployment 부분에 Without Docker, With Docker 방법이 작성되어 있다. Docker Image가 존재한다면, Kubernetes Pod로 실행하는 것은 크게 어렵지 않다.

 

 

 

 

Helm Value 작성

  • template은 필수 입니다. template 작성이 어려우시다면 아래의 글을 확인하면 된다.

2025.01.06 - [Container Orchestration/Kubernetes] - Helm Base App Chart 생성(With ArgoCD)

 

Helm Base App Chart 생성(With ArgoCD)

OverviewHelm Base App Chart 생성후에 Base Chart 만 사용해서 모든 Application을 연동하는 방법에 대해서 알아본다.https://github.com/somaz94/helm-base-app-template   Helm에 대한 내용들은 이전 포스팅을 참고하길 바

somaz.tistory.com

 

 

 

 

Overide-values.yaml

  • 현재 https를 사용할 수 없어서 http 구성중이다.
  • iptime ddns로 포트포워딩 구성이 되어 있어서 도메인이 2개 구성되어 있다.
# Default values for ke-use-nfs-server.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

replicaCount: 1

image:
  repository: halverneus/static-file-server
  pullPolicy: IfNotPresent
  # Overrides the image tag whose default is the chart appVersion.
  tag: "v1.8.11"

nameOverride: ""
fullnameOverride: ""

serviceAccount:
  # Specifies whether a service account should be created
  create: true
  # Annotations to add to the service account
  annotations: {}
  # The name of the service account to use.
  # If not set and create is true, a name is generated using the fullname template
  name: ""

podAnnotations: {}

podSecurityContext: {}
  # fsGroup: 2000

securityContext: {}
  # capabilities:
  #   drop:
  #   - ALL
  # readOnlyRootFilesystem: true
  # runAsNonRoot: true
  # runAsUser: 1000

service:
  type: ClusterIP
  port: 80
  targetPort: 8080

ingress:
  enabled: true
  className: "nginx-public-b"
  annotations: 
    # kubernetes.io/ingress.class: nginx
    # kubernetes.io/tls-acme: "true"
    nginx.ingress.kubernetes.io/force-ssl-redirect: "false"   # Disable SSL redirection
    nginx.ingress.kubernetes.io/ssl-passthrough: "false"      # Disable SSL passthrough
    nginx.ingress.kubernetes.io/rewrite-target: /
  hosts:
    - host: file-server.somaz.link
      paths:
        - path: /
          pathType: ImplementationSpecific
    - host: somaz.iptime.org    # 추가
      paths:
        - path: /
          pathType: ImplementationSpecific

# This is to setup the liveness and readiness probes more information can be found here: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-startup-probes/
# livenessProbe: {}
# readinessProbe: {}

livenessProbe:
  httpGet:
    path: /
    port: 8080
  initialDelaySeconds: 10
  periodSeconds: 10

readinessProbe:
  httpGet:
    path: /
    port: 8080
  initialDelaySeconds: 5
  periodSeconds: 10

resources: {}
  # We usually recommend not to specify default resources and to leave this as a conscious
  # choice for the user. This also increases chances charts run on environments with little
  # resources, such as Minikube. If you do want to specify resources, uncomment the following
  # lines, adjust them as necessary, and remove the curly braces after 'resources:'.
  # limits:
  #   cpu: 100m
  #   memory: 128Mi
  # requests:
  #   cpu: 100m
  #   memory: 128Mi

autoscaling:
  enabled: false
  minReplicas: 1
  maxReplicas: 100
  targetCPUUtilizationPercentage: 80
  # targetMemoryUtilizationPercentage: 80

rbac:
  enabled: false

nodeSelector: {}

tolerations: []

affinity: {}

revisionHistoryLimit: 1

envConfig:
  PORT: "8080"
  FOLDER: "/web"
  SHOW_LISTING: "true"
  ALLOW_INDEX: "true"

configs:
  enabled: false
  # # example configmap
  # items:
  #   - name: app-config
  #     datas:
  #       APP_ENV: "production"
  #       DEBUG: "false"
  #   - name: debug-config
  #     datas:
  #       APP_ENV: "development"
  #       DEBUG: "true"

persistentVolumeClaims:
  enabled: true
  items:
    - name: static-file-server-pvc
      accessModes:
        - ReadWriteMany
      storageClassName: nfs-client-nopath
      storage: 5Gi
      mountPath: /web
      selector:
        volumeName: static-file-server-pv

persistentVolumes:
  enabled: true
  items:
    - name: static-file-server-pv
      storage: 5Gi
      volumeMode: Filesystem
      accessModes:
        - ReadWriteMany
      reclaimPolicy: Retain
      storageClassName: nfs-client-nopath
      path: /volume1/nfs
      server: 10.10.10.5


# Extra volumes to add to the deployment
extraVolumes: []

# Extra volume mounts to add to the container
extraVolumeMounts: []

# AWS
certificate:
  enabled: false
  # example certificate
  # secretName: base-tls
  # commonName: base.com
  # duration: 2160h0m0s # 90d
  # renewBefore: 720h0m0s # 30d
  # dnsNames:
  # - base.com
  # issuerName: route53-issuer # issuer name
  # issuerKind: ClusterIssuer # issuer kind

# # GCP
# certificate:
#   # example certificate
#   # secretName: base-tls
#   # commonName: base.com
#   # duration: 2160h0m0s # 90d
#   # renewBefore: 720h0m0s # 30d
#   # dnsNames:
#   # - base.com
#   # issuerName: clouddns-issuer # issuer name
#   # issuerKind: ClusterIssuer # issuer kind
  
certCleanup:
  enabled: false
  # CronJobName: cert-cleanup-cronjob-base
  # olderThanDays: 100
  # YesterDays: 1

 

 

Static File Server 설치

# Dry run to verify configuration
helm install static-server . -n <namespace> -f ./values/mgmt.yaml --create-namespace --dry-run --debug >> dry-run-result

# Install Static Server
helm install static-server . -n <namespace> -f ./values/mgmt.yaml --create-namespace

# Upgrade existing installation
helm upgrade static-server . -n monitoring -f ./values/mgmt.yaml

 

 

설치 확인

 

 

 

 

 

 


 

 

 

 

 

 

마무리

이렇게 간단하게 웹에서 확인할 수 있는 Static File Server를 만들어 보았다. 개발 과정에서 내부 서버를 사용할때 트래픽이 많이 발생하지 않는다면 간단하게 구성해서 사용하는 것도 좋아보인다.

 

 

 


Reference

https://github.com/halverneus/static-file-server

728x90
반응형