Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info
iconfalse


Info

Headless 서비스 작성 방법 (ClusterIP가 없는 서비스)

Code Block
linenumberstrue
apiVersion: v1
kind: Service
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  ports:
  - port: 80
    name: web
  clusterIP: None
  selector:
    app: nginx

StatefulSet 작성 방법

Info

Deployment와 전반적인 설정은 유사합니다. Deployment와 다른 속성들만 설명 합니다.

  •  serviceName
    • serviceName으로 고유한 네트워크ID를 생성합니다.
  • terminationGracePeriodSeconds
    • 종료 요청(SIGTERM)후 Pod가 삭제되기까지 Delay시간을 줍니다.
  • volumeClaimTemplates
    • 안정적인 스토리지 제공을 위해 PVC를 작성합니다.
  • volumeMounts
    • 영구 스토리지를 연결하고자 하는 위치


StorageClass확인

Code Block
titleStorageClass
linenumberstrue
collapsetrue
sansae@sansaeAir15m2 k8s-lab-workspace % k get storageclass
NAME                    PROVISIONER          RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE
azurefile               file.csi.azure.com   Delete          Immediate              true                   34h
azurefile-csi           file.csi.azure.com   Delete          Immediate              true                   34h
azurefile-csi-premium   file.csi.azure.com   Delete          Immediate              true                   34h
azurefile-premium       file.csi.azure.com   Delete          Immediate              true                   34h
default (default)       disk.csi.azure.com   Delete          WaitForFirstConsumer   true                   34h
managed                 disk.csi.azure.com   Delete          WaitForFirstConsumer   true                   34h
managed-csi             disk.csi.azure.com   Delete          WaitForFirstConsumer   true                   34h
managed-csi-premium     disk.csi.azure.com   Delete          WaitForFirstConsumer   true                   34h
managed-premium         disk.csi.azure.com   Delete          WaitForFirstConsumer   true                   34h
sansae@sansaeAir15m2 k8s-lab-workspace % 

Statefulset Manifest

Code Block
linenumberstrue
StatefulSet Manifest
apiVersion: v1
kind: Service
metadata:
  name: nginx-stps
  labels:
    app: nginx
spec:
  ports:
  - port: 80
    name: web
  clusterIP: None
  selector:
    app: nginx
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: web
spec:
  selector:
    matchLabels:
      app: nginx
  serviceName: "nginx"
  replicas: 3 # 기본값은 1
  minReadySeconds: 10 # 기본값은 0
  template:
    metadata:
      labels:
        app: nginx
    spec:
      terminationGracePeriodSeconds: 10
      containers:
      - name: nginx
        image: registry.k8s.io/nginx-slim:0.8
        ports:
        - containerPort: 80
          name: web
        volumeMounts:
        - name: www
          mountPath: /usr/share/nginx/html
  volumeClaimTemplates:
  - metadata:
      name: www
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: azurefile
      resources:
        requests:
          storage: 1Gi


...