高级指南

K8s 基础概念

Kubernetes 核心概念介绍

K8s 基础概念

Pod

Pod 是 Kubernetes 中最小的部署单元,包含一个或多个容器。

Deployment

Deployment 用于管理 Pod 的副本数和滚动更新。

apiVersion: apps/v1
kind: Deployment
metadata:
  name: myapp
spec:
  replicas: 3
  selector:
    matchLabels:
      app: myapp
  template:
    metadata:
      labels:
        app: myapp
    spec:
      containers:
      - name: myapp
        image: myapp:latest
        ports:
        - containerPort: 3000

Service

Service 用于暴露 Pod 的网络访问。

apiVersion: v1
kind: Service
metadata:
  name: myapp
spec:
  selector:
    app: myapp
  ports:
  - port: 80
    targetPort: 3000
  type: LoadBalancer

Comments

0%