Skip to content

NimTechnology

Trình bày các công nghệ CLOUD một cách dễ hiểu.

  • Kubernetes & Container
    • Docker
    • Kubernetes
      • Ingress
      • Pod
    • Helm Chart
    • OAuth2 Proxy
    • Isito-EnvoyFilter
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Vault
    • Longhorn – Storage
    • VictoriaMetrics
    • MetalLB
    • Kong Gateway
  • CI/CD
    • ArgoCD
    • ArgoWorkflows
    • Argo Events
    • Spinnaker
    • Jenkins
    • Harbor
    • TeamCity
    • Git
      • Bitbucket
  • Coding
    • DevSecOps
    • Terraform
      • GCP – Google Cloud
      • AWS – Amazon Web Service
      • Azure Cloud
    • Golang
    • Laravel
    • Python
    • Jquery & JavaScript
    • Selenium
  • Log, Monitor & Tracing
    • DataDog
    • Prometheus
    • Grafana
    • ELK
      • Kibana
      • Logstash
  • BareMetal
    • NextCloud
  • Toggle search form

[EKS/ S3 Mount Point] Create a Persistent Volume on EKS using an S3 Bucket.

Posted on February 8, 2025February 8, 2025 By nim No Comments on [EKS/ S3 Mount Point] Create a Persistent Volume on EKS using an S3 Bucket.

refer to install:
https://github.com/awslabs/mountpoint-s3/blob/main/doc/CONFIGURATION.md

Mountpoint for Amazon S3 is optimized for applications that need high read throughput to large objects, potentially from many clients at once, and to write new objects sequentially from a single client at a time.
==> S3 Mountpoint này sẽ hỗ trợ cho việc ghi file mới và đọc file từ nhiều client cùng 1 lúc

Mountpoint for Amazon S3 does not implement all the features of a POSIX file system, and there are some differences that may affect compatibility with your application.

Chúng ta tìm hiểu 1 chút về POSIX file system.

Các yếu tố cơ bản của hệ thống tệp POSIX:

  1. Cấu trúc thư mục: POSIX sử dụng một cấu trúc thư mục kiểu cây, bắt đầu từ thư mục gốc /. Mọi thứ đều được coi là tệp tin, bao gồm các thiết bị phần cứng, thư mục, và các tệp thông thường.
  2. Các loại tệp:
    • Regular files: Các tệp thông thường lưu trữ dữ liệu, chẳng hạn như văn bản, hình ảnh, âm thanh.
    • Directories: Thư mục lưu trữ thông tin về các tệp và thư mục con.
    • Symbolic links: Liên kết tượng trưng giúp tạo ra các tên tệp thay thế cho tệp gốc.
    • Special files: Những tệp này đại diện cho thiết bị phần cứng như ổ đĩa, máy in.
  3. Quyền truy cập tệp: POSIX sử dụng hệ thống quyền truy cập dựa trên ba loại người dùng:
    • User (owner): Chủ sở hữu tệp.
    • Group: Nhóm người dùng có quyền truy cập chung.
    • Others: Những người dùng còn lại.
    Quyền truy cập có thể là read (r), write (w), và execute (x), và có thể được thiết lập cho từng loại người dùng này.
  4. System calls: POSIX cung cấp nhiều hệ thống gọi (system calls) để xử lý tệp, ví dụ như:
    • open(): Mở tệp.
    • read(): Đọc dữ liệu từ tệp.
    • write(): Ghi dữ liệu vào tệp.
    • close(): Đóng tệp.
    • mkdir(): Tạo thư mục.
    • unlink(): Xóa tệp.
  5. File descriptors: Trong hệ thống POSIX, khi một tệp được mở, một “file descriptor” (mã số tệp) được cấp cho tệp đó. File descriptor là một số nguyên được sử dụng để tham chiếu tệp khi thực hiện các thao tác như đọc và ghi.
  6. Tệp đặc biệt:
    • FIFO (First In, First Out): Tệp này là một loại tệp đặc biệt dùng để giao tiếp giữa các tiến trình.
    • Sockets: Sockets trong POSIX cho phép các tiến trình giao tiếp qua mạng.

Đây là một số thông số mà chúng tôi đo được giữa s3-mountpoint với S3 và S3 mount point

Compare the Download Speed of s3-express-one-zone and s3 standard.

S3 types3 standards3-express-one-zone
File Size200MB
Number of pods200
Max Speed255 MiB/s234 MiB/s
Min Speed24.1 MiB/s18.8 MiB/s
Cost4.84 $74.86 $

Chúng tôi test 200 pod thì total banwidth khá khủng:

Bạn có thể tham khảo link này để cài:
https://github.com/awslabs/mountpoint-s3/blob/main/doc/CONFIGURATION.md

Hoặc sửa dụng terraform module sau:

variable "aws_region" {
  description = "The AWS region where the infrastructure will be deployed. This should be the region closest to your users or where you prefer to host your resources. Example: 'us-east-1', 'eu-central-1'."
  type        = string
  default     = "eu-central-1"
}

# Terraform Remote State Datasource - Remote Backend AWS S3
data "terraform_remote_state" "eks" {
  backend = "s3"
  config = {
    bucket = "private-windows-nim-eks-tf-lock"
    key    = "private-windows-eks.tfstate"
    region = "us-east-1"
  }
}


module "eks-s3-mount-point" {
  source  = "aws-terraform-module/eks-s3-mount-point/aws"
  version = "0.0.6"
  aws_region = var.aws_region
  s3-bucket-name = "s3-bucket-nimtechnology"
  eks_cluster_certificate_authority_data = data.terraform_remote_state.eks.outputs.cluster_certificate_authority_data
  eks_cluster_endpoint = data.terraform_remote_state.eks.outputs.cluster_endpoint
  eks_cluster_name = data.terraform_remote_state.eks.outputs.cluster_name
  aws_iam_openid_connect_provider_arn = data.terraform_remote_state.eks.outputs.oidc_provider_arn

}

Nó sẽ tạo 1 S3 là s3-bucket-nimtechnology

Đâu tiên Module sẽ tạo role:

Role này cấp quyền cho s3-csi-driver-sa service account trong namespace kube-system có thể acces vào S3: s3-bucket-nimtechnology

Tiếp đến nó cái s3-csi-node driver:

Tiếp theo bạn cài pv và pvc, pod để kiểm tra

apiVersion: v1
kind: PersistentVolume
metadata:
  name: s3-pv
spec:
  capacity:
    storage: 1200Gi # ignored, required
  accessModes:
    - ReadWriteMany 
  storageClassName: "" # Required for static provisioning
  claimRef: # To ensure no other PVCs can claim this PV
    namespace: default # Namespace is required even though it's in "default" namespace.
    name: s3-pvc # Name of your PVC
  mountOptions:
    - allow-delete # If you want to allow file deletion, use the --allow-delete flag at mount time. Delete operations immediately delete the object from S3, even if the file is being read from.
    - region eu-central-1 # The AWS region where the bucket is located.
    - uid=100
    - gid=101
    - dir-mode=0777
    - file-mode=0777
    - allow-other
    - allow-overwrite
  csi:
    driver: s3.csi.aws.com # required
    volumeHandle: s3-bucket-nimtechnology-volume 
    volumeAttributes:
      bucketName: s3-bucket-nimtechnology # The name of the S3 bucket.
      #authenticationSource: pod # To configure the Mountpoint CSI Driver to use Pod-Level Credentials, configure your PV using authenticationSource: pod in the volumeAttributes section

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: s3-pvc
spec:
  accessModes:
    - ReadWriteMany # Supported options: ReadWriteMany / ReadOnlyMany
  storageClassName: "" # Required for static provisioning
  resources:
    requests:
      storage: 1200Gi # Ignored, required
  volumeName: s3-pv # Name of your PV

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: s3-app
  labels:
    app: s3-app
spec:
  replicas: 3
  selector:
    matchLabels:
      app: s3-app
  template:
    metadata:
      labels:
        app: s3-app
    spec:
      containers:
      - name: s3-app
        image: centos
        command: ["/bin/sh"]
        args: ["-c", "echo 'Hello from the container!' >> /data/$(date -u).txt; tail -f /dev/null"]
        volumeMounts:
        - name: persistent-storage
          mountPath: /data
        ports:
        - containerPort: 80
      nodeSelector:
        kubernetes.io/os: linux
      volumes:
      - name: persistent-storage
        persistentVolumeClaim:
          claimName: s3-pvc
root@work-space-u20:~/eks/windows-19/irsa-s3-mountpoint# kubectl get pod
NAME                                  READY   STATUS    RESTARTS   AGE
csi-smb-controller-6d9cc98ff4-gdnxs   4/4     Running   0          19h
csi-smb-node-jq94p                    3/3     Running   0          6h18m
csi-smb-node-rrqr7                    3/3     Running   0          6h18m
csi-smb-node-tsmtp                    3/3     Running   0          6h18m
s3-app-68bf58b7d-9hlrx                1/1     Running   0          9s
s3-app-68bf58b7d-j5gc6                1/1     Running   0          9s
s3-app-68bf58b7d-s4qfq                1/1     Running   0          9s
samba-server-7d7696fb6d-rkbhp         1/1     Running   0          19h
root@work-space-u20:~/eks/windows-19/irsa-s3-mountpoint# kubectl exec -it s3-app-68bf58b7d-j5gc6 -- sh
sh-4.4# ls -la
total 32
drwxr-xr-x.   1 root root    29 Feb  7 11:00 .
drwxr-xr-x.   1 root root    29 Feb  7 11:00 ..
lrwxrwxrwx.   1 root root     7 Nov  3  2020 bin -> usr/bin
drwxrwxrwx.   2  100  101     0 Feb  7 10:59 data
drwxr-xr-x.   5 root root   360 Feb  7 11:00 dev
drwxr-xr-x.  55 root root 16384 Sep 15  2021 etc
drwxr-xr-x.   2 root root     6 Nov  3  2020 home
sh-4.4# df -h
Filesystem      Size  Used Avail Use% Mounted on
overlay         100G  4.2G   96G   5% /
tmpfs            64M     0   64M   0% /dev
mountpoint-s3   8.0E     0  8.0E   0% /data
/dev/nvme0n1p1  100G  4.2G   96G   5% /etc/hosts
shm              64M     0   64M   0% /dev/shm
tmpfs            31G   12K   31G   1% /run/secrets/kubernetes.io/serviceaccount
tmpfs            16G     0   16G   0% /proc/acpi
tmpfs            16G     0   16G   0% /sys/firmware

Sau đó mình thực hành kiểm tra folder data đã được mount với S3

Giờ bạn kiêm tra S3.

Như thế này là ok rồi he!

View Post

AWS - Amazon Web Service

Post navigation

Previous Post: [CoreDNS] How to improve the Coredns performance.
Next Post: How to aws cli authenticate with AWS

More Related Articles

[AWS] Solutions Architect Professional: Lesson 1 – Identity & Federation AWS - Amazon Web Service
[EKS] operation error EKS: CreateAccessEntry, https response error StatusCode: 409 AWS - Amazon Web Service
Experiences for IP Addresses Shortage on EKS Clusters AWS - Amazon Web Service
[AWS] Creating EKS windows on AWS and Running windows pods AWS - Amazon Web Service
[Terraform] – Terraform Beginner – Lesson 8: Terraform Functions and Conditional Expressions AWS - Amazon Web Service
[VPC] The difference between public and private subnets in Amazon VPC? AWS - Amazon Web Service

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Tham Gia Group DevOps nhé!
Để Nim có nhiều động lực ra nhiều bài viết.
Để nhận được những thông báo mới nhất.

Recent Posts

  • [Azure] The subscription is not registered to use namespace ‘Microsoft.ContainerService’ May 8, 2025
  • [Azure] Insufficient regional vcpu quota left May 8, 2025
  • [WordPress] How to add a Dynamic watermark on WordPress. May 6, 2025
  • [vnet/Azure] VNet provisioning via Terraform. April 28, 2025
  • [tracetcp] How to perform a tracert command using a specific port. April 3, 2025

Archives

  • May 2025
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • July 2024
  • June 2024
  • May 2024
  • April 2024
  • March 2024
  • February 2024
  • January 2024
  • December 2023
  • November 2023
  • October 2023
  • September 2023
  • August 2023
  • July 2023
  • June 2023
  • May 2023
  • April 2023
  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021

Categories

  • BareMetal
    • NextCloud
  • CI/CD
    • Argo Events
    • ArgoCD
    • ArgoWorkflows
    • Git
      • Bitbucket
    • Harbor
    • Jenkins
    • Spinnaker
    • TeamCity
  • Coding
    • DevSecOps
    • Golang
    • Jquery & JavaScript
    • Laravel
    • NextJS 14 & ReactJS & Type Script
    • Python
    • Selenium
    • Terraform
      • AWS – Amazon Web Service
      • Azure Cloud
      • GCP – Google Cloud
  • Kubernetes & Container
    • Apache Kafka
      • Kafka
      • Kafka Connect
      • Lenses
    • Docker
    • Helm Chart
    • Isito-EnvoyFilter
    • Kong Gateway
    • Kubernetes
      • Ingress
      • Pod
    • Longhorn – Storage
    • MetalLB
    • OAuth2 Proxy
    • Vault
    • VictoriaMetrics
  • Log, Monitor & Tracing
    • DataDog
    • ELK
      • Kibana
      • Logstash
    • Fluent
    • Grafana
    • Prometheus
  • Uncategorized
  • Admin

Copyright © 2025 NimTechnology.