SiamCafe.net Blog
Technology

Skaffold Dev Edge Deployment

skaffold dev edge deployment
Skaffold Dev Edge Deployment | SiamCafe Blog
2025-10-02· อ. บอม — SiamCafe.net· 10,285 คำ

Skaffold Edge Deployment

Skaffold Dev Loop Edge Deployment K3s Kubernetes Continuous Development Docker Helm Kustomize GitOps Fleet IoT CDN ARM

ComponentCloudEdgeDifference
KubernetesEKS GKE AKSK3s KubeEdgeEdge ใช้ Lightweight K8s
HardwareHigh-end ServerRaspberry Pi NUC Mini PCEdge จำกัด CPU/RAM
Architecturex86_64ARM64 / x86_64Edge อาจเป็น ARM
NetworkStable High-speedUnstable Low-bandwidthEdge Internet ไม่เสถียร
RegistryECR GCR DockerHubLocal Registry MirrorEdge ใช้ Mirror ลด Pull Time

Skaffold Configuration

# === skaffold.yaml for Edge Development ===

# apiVersion: skaffold/v4beta6
# kind: Config
# metadata:
#   name: edge-app
#
# profiles:
#   - name: dev
#     build:
#       artifacts:
#         - image: edge-app
#           docker:
#             dockerfile: Dockerfile
#       local:
#         push: false
#     deploy:
#       kubectl:
#         manifests:
#           - k8s/dev/*.yaml
#
#   - name: edge
#     build:
#       artifacts:
#         - image: edge-app
#           docker:
#             dockerfile: Dockerfile.edge
#             buildArgs:
#               TARGETARCH: arm64
#       local:
#         push: true
#     deploy:
#       helm:
#         releases:
#           - name: edge-app
#             chartPath: charts/edge-app
#             valuesFiles:
#               - values-edge.yaml
#             setValues:
#               resources.limits.cpu: "500m"
#               resources.limits.memory: "256Mi"
#
#   - name: prod-edge
#     build:
#       artifacts:
#         - image: edge-app
#           docker:
#             dockerfile: Dockerfile.edge
#       tagPolicy:
#         gitCommit: {}
#     deploy:
#       kustomize:
#         paths:
#           - k8s/overlays/prod-edge

from dataclasses import dataclass

@dataclass
class SkaffoldProfile:
    profile: str
    builder: str
    deployer: str
    target: str
    use_case: str

profiles = [
    SkaffoldProfile("dev",
        "Docker (local, no push)",
        "kubectl (raw manifests)",
        "Local Minikube/Kind",
        "Local Development ทดสอบเร็ว"),
    SkaffoldProfile("edge-dev",
        "Docker (local, push to edge registry)",
        "kubectl + port-forward",
        "K3s on Edge Device",
        "Dev Loop บน Edge จริง"),
    SkaffoldProfile("edge",
        "Docker (ARM64 cross-compile)",
        "Helm (values-edge.yaml)",
        "K3s Edge Cluster",
        "Deploy ไป Edge Staging"),
    SkaffoldProfile("prod-edge",
        "Docker (git tag, multi-arch)",
        "Kustomize (prod-edge overlay)",
        "K3s Edge Production",
        "Production Edge Deployment"),
]

print("=== Skaffold Profiles ===")
for p in profiles:
    print(f"\n  [{p.profile}]")
    print(f"    Builder: {p.builder}")
    print(f"    Deployer: {p.deployer}")
    print(f"    Target: {p.target}")
    print(f"    Use: {p.use_case}")

Edge Cluster Setup

# === K3s Edge Cluster Setup ===

# Install K3s on Edge Node (ARM64 Raspberry Pi / x86 Mini PC)
# curl -sfL https://get.k3s.io | sh -s - \
#   --write-kubeconfig-mode 644 \
#   --disable traefik \
#   --disable servicelb \
#   --node-name edge-node-01

# Get kubeconfig for Skaffold
# scp edge-node:/etc/rancher/k3s/k3s.yaml ~/.kube/edge-config
# Edit server: https://edge-node-ip:6443

# Set context for Skaffold
# export KUBECONFIG=~/.kube/edge-config
# skaffold dev -p edge

# Local Registry Mirror on Edge (reduce pull time)
# docker run -d -p 5000:5000 --name registry \
#   -v /var/lib/registry:/var/lib/registry registry:2
# k3s: registries.yaml
# mirrors:
#   "docker.io":
#     endpoint:
#       - "http://localhost:5000"

@dataclass
class EdgeSetupStep:
    step: int
    action: str
    command: str
    time: str

setup = [
    EdgeSetupStep(1, "Install K3s on Edge",
        "curl -sfL https://get.k3s.io | sh -",
        "2-5 นาที"),
    EdgeSetupStep(2, "Copy kubeconfig",
        "scp edge:/etc/rancher/k3s/k3s.yaml ~/.kube/edge",
        "30 วินาที"),
    EdgeSetupStep(3, "Setup Registry Mirror",
        "docker run -d -p 5000:5000 registry:2",
        "1 นาที"),
    EdgeSetupStep(4, "Configure Skaffold Profile",
        "เพิ่ม edge profile ใน skaffold.yaml",
        "5 นาที"),
    EdgeSetupStep(5, "Start Dev Loop",
        "KUBECONFIG=~/.kube/edge skaffold dev -p edge",
        "ทันที"),
    EdgeSetupStep(6, "Deploy Production",
        "skaffold run -p prod-edge --tag=$(git rev-parse --short HEAD)",
        "2-5 นาที"),
]

print("=== Edge Setup ===")
for s in setup:
    print(f"  Step {s.step}: {s.action}")
    print(f"    Command: {s.command}")
    print(f"    Time: {s.time}")

Multi-Edge GitOps

# === Multi-Edge Deployment with Fleet/ArgoCD ===

@dataclass
class EdgeLocation:
    location: str
    hardware: str
    k3s_version: str
    apps: str
    network: str

locations = [
    EdgeLocation("Bangkok Store #1",
        "Intel NUC i5, 16GB RAM, 256GB SSD",
        "K3s v1.28",
        "POS API, Inventory Sync, Local Cache",
        "Fiber 100Mbps + 4G Failover"),
    EdgeLocation("Chiang Mai Store #2",
        "Raspberry Pi 5, 8GB RAM, 128GB SD",
        "K3s v1.28 (ARM64)",
        "POS API (lite), Inventory Sync",
        "4G LTE Primary"),
    EdgeLocation("Factory IoT Gateway",
        "Jetson Nano, 4GB RAM",
        "K3s v1.28 (ARM64)",
        "Sensor Collector, AI Inference, MQTT Bridge",
        "WiFi + Ethernet"),
    EdgeLocation("CDN Edge PoP",
        "AMD EPYC, 64GB RAM, 1TB NVMe",
        "K3s v1.28",
        "Cache Server, Image Optimizer, WAF",
        "10Gbps Fiber"),
]

print("=== Edge Locations ===")
for l in locations:
    print(f"\n  [{l.location}]")
    print(f"    Hardware: {l.hardware}")
    print(f"    K3s: {l.k3s_version}")
    print(f"    Apps: {l.apps}")
    print(f"    Network: {l.network}")

เคล็ดลับ

Skaffold คืออะไร

CLI Continuous Development Kubernetes Build Push Deploy อัตโนมัติ skaffold dev Docker Buildpacks kubectl Helm Kustomize Profile Environment

Edge Deployment คืออะไร

Deploy ใกล้ผู้ใช้ Latency ต่ำ Bandwidth ลด Reliability Offline Privacy K3s KubeEdge IoT Retail CDN AI Inference ARM Raspberry Pi

ตั้งค่า Skaffold อย่างไร

skaffold.yaml build artifacts deploy kubectl helm kustomize profile dev edge prod port-forward sync hot-reload ARM cross-compile

Deploy ไป Edge อย่างไร

K3s install kubeconfig Registry Mirror skaffold run profile edge Fleet ArgoCD GitOps Multi-edge Helm Values Kustomize Overlay Resource Limits

สรุป

Skaffold Edge Deployment K3s Dev Loop Docker Helm Kustomize Profile ARM Registry Mirror Fleet GitOps Multi-edge IoT CDN Retail Production

📖 บทความที่เกี่ยวข้อง

Skaffold Dev Agile Scrum Kanbanอ่านบทความ → Skaffold Dev Multi-cloud Strategyอ่านบทความ → Skaffold Dev Multi-tenant Designอ่านบทความ → Skaffold Dev MLOps Workflowอ่านบทความ → Skaffold Dev AR VR Developmentอ่านบทความ →

📚 ดูบทความทั้งหมด →