บทนำ
บทความนี้อธิบายวิธีการตั้งค่า Container Storage บน Sangfor Kubernetes Engine (SKE) v2.2.0 ซึ่งรองรับ Storage 3 ประเภท ได้แก่ EDS (Enterprise Distributed Storage), aSAN และ NFS โดยครอบคลุมการตั้งค่า Storage แต่ละประเภท การติดตั้ง CSI Plugin และการสร้าง StorageClass สำหรับ Kubernetes Cluster
Container Storage เป็นส่วนสำคัญของ Kubernetes Cluster ที่ช่วยให้ Containerized Application สามารถจัดเก็บข้อมูลแบบ Persistent ได้ SKE รองรับ CSI (Container Storage Interface) Plugin ที่เชื่อมต่อกับ Storage Backend ต่างๆ เพื่อให้สามารถ Provision Storage แบบ Dynamic ได้
ข้อกำหนดเบื้องต้น
- ติดตั้งและเปิดใช้งาน SKE v2.2.0 บน SCP เรียบร้อยแล้ว
- มี Kubernetes Cluster ที่อยู่ในสถานะ Running
- มี Storage Backend (EDS, aSAN หรือ NFS Server) ที่พร้อมใช้งาน
เปรียบเทียบ Container Storage
ตารางเปรียบเทียบคุณสมบัติของ Storage แต่ละประเภท:
| คุณสมบัติ | aSAN CSI | EDS CSI | NFS CSI |
|---|---|---|---|
| Datastore Creation Mode | Dynamic Provisioning | Dynamic Provisioning | Dynamic Provisioning |
| Max Datastores per Node | 200 | 200 | 200 |
| Datastore Type | File System / Block Device | File System | File System |
| Access Mode | ReadWriteOnce | ReadWriteMany | ReadWriteMany |
| Elastic Expansion | รองรับ | รองรับ | ไม่รองรับ |
ขั้นตอนที่ 1: ตั้งค่า EDS File Storage
สำหรับการใช้ EDS เป็น Container Storage ต้องตั้งค่า EDS File Storage บน EDS Server ก่อน:
- เข้าสู่ระบบ EDS แล้วขอ Access Key ID และ Secret สำหรับ Mutual Authentication ระหว่าง SCP กับ EDS
- ไปที่ System > System Settings > Third-Party Platforms หากมี Access Key Pair เดิมที่ไม่ได้ใช้งานแล้ว ให้ลบออก
- คลิก Add เพื่อเพิ่ม Access Key Pair สำหรับ Mutual Authentication ระหว่าง EDS กับ SCP
- หลังจากเพิ่ม Access Key Pair แล้ว สามารถ Export, Edit หรือ View ได้
- เข้าสู่ระบบ SCP แล้วไปที่ System > System > Services > Advanced Services > File Storage
- คลิก Activate Service
- ตั้งค่า EDS Storage Pool Parameter หาก EDS Interface เป็นแบบ Multiplexed ให้ใช้ IP เดียวกันสำหรับ Management และ Business Interface (Default Port: 443)
ขั้นตอนที่ 2: ตั้งค่า EDS CSI Shared Service (VPC)
เมื่อเพิ่ม EDS Storage Pool ระบบจะสร้าง Shared Service Network โดยอัตโนมัติ:
- ไปที่ Networking > Shared Service Network > Shared Services แล้วค้นหา Shared Service ที่ตรงกับ Storage Pool
- คลิก Shared Service Network แล้วเปิด/ปิดการเข้าถึงจาก Tenant VPC
หมายเหตุ: โดย Default VPC จะไม่สามารถเข้าถึง Shared Services ได้ ต้องเปิดใช้งานด้วยตนเอง
ขั้นตอนที่ 3: ตั้งค่า aSAN
สำหรับการใช้ aSAN CSI Plugin ต้องตั้งค่า aSAN Server บน SCP ก่อน:
- เข้าสู่ระบบ SCP แล้วไปที่ Networking > Shared Service Network > Shared Services ค้นหา Storage Service และ Tenant ที่ต้องการ แล้ว Activate Storage Service
ขั้นตอนที่ 4: ตั้งค่า NFS
สำหรับการใช้ NFS ต้องมี NFS Server ที่จัดเตรียมโดยลูกค้า:
- ตรวจสอบให้แน่ใจว่า NFS Service พร้อมใช้งานก่อนดำเนินการ
- NFS Server ต้องสามารถเข้าถึงได้จาก Kubernetes Cluster Node
ขั้นตอนที่ 5: ติดตั้ง CSI Plugin
สามารถติดตั้ง CSI Plugin ได้ 2 วิธี:
- วิธีที่ 1: ติดตั้ง CSI Plugin ขณะสร้าง Kubernetes Cluster
- วิธีที่ 2: ติดตั้ง CSI Plugin จากหน้า Plugin Management
ขั้นตอน (วิธีที่ 2):
- เข้าสู่ระบบ SCP แล้วไปที่ Resources > Compute > Kubernetes Engine > Cluster Management > Plugins
- คลิก Install ในคอลัมน์ Operation ของ CSI Plugin ที่ต้องการ:
- SKE CSI - Kubernetes CSI Plugin ที่รองรับ NFS และ EDS
- aSAN CSI - Kubernetes CSI Plugin ที่รองรับ aSAN
ขั้นตอนที่ 6: สร้าง StorageClass
- เข้าสู่ระบบ SCP แล้วไปที่ Resources > Compute > Kubernetes Engine > Cluster Management > Storage > Storage Classes
- คลิก New แล้วตั้งค่า StorageClass Parameter ตามประเภท Storage ที่ต้องการ
ตัวอย่าง: การใช้ NFS PV กับ kubectl
หลังจากสร้าง StorageClass แล้ว สามารถสร้าง PVC และใช้งานกับ Workload ผ่าน kubectl ได้ดังนี้:
สร้าง PVC:
# pvc.yaml; kubectl apply -f pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: nfs-test-001
namespace: default
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
storageClassName: demo-sc
ตั้งค่า Workload ให้ใช้ PVC:
# deployment.yaml; kubectl apply -f deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: deployment-nfs
spec:
replicas: 1
selector:
matchLabels:
name: deployment-nfs
template:
metadata:
name: deployment-nfs
labels:
name: deployment-nfs
spec:
nodeSelector:
"kubernetes.io/os": linux
containers:
- name: deployment-nfs
image: mirrors.sangfor.com/nginx:latest
imagePullPolicy: IfNotPresent
volumeMounts:
- name: nfs
mountPath: "/var/data"
volumes:
- name: nfs
persistentVolumeClaim:
claimName: nfs-test-001
หมายเหตุ
- aSAN CSI รองรับทั้ง File System และ Block Device ในขณะที่ EDS CSI และ NFS CSI รองรับเฉพาะ File System
- NFS Server จัดเตรียมโดยลูกค้า ต้องตรวจสอบว่า NFS Service พร้อมใช้งานก่อนดำเนินการ
- ในโหมด VPC ต้องเปิด Access จาก VPC ไปยัง Shared Service Network ด้วยตนเอง
ข้อคิดเห็น
0 ข้อคิดเห็น
โปรด ลงชื่อเข้าใช้ เพื่อแสดงข้อคิดเห็น