Kubernetes 集群管理
Kubernetes(K8s)是业界标准的容器编排平台,用于自动化部署、扩展和管理容器化应用。
Pod 是 Kubernetes 中最小的可部署单元,包含一个或多个容器:
apiVersion: v1kind: Podmetadata: name: my-podspec: containers: - name: app image: nginx:latest ports: - containerPort: 80Deployment
Section titled “Deployment”管理 Pod 的声明式更新和扩缩容:
apiVersion: apps/v1kind: Deploymentmetadata: name: web-deploymentspec: replicas: 3 selector: matchLabels: app: web template: metadata: labels: app: web spec: containers: - name: web image: my-app:latestService
Section titled “Service”提供稳定的网络端点,将流量负载均衡到一组 Pod:
- ClusterIP:集群内部访问
- NodePort:通过节点端口外部访问
- LoadBalancer:云负载均衡器
- ConfigMap:存储非敏感的配置信息
- Secret:存储敏感数据(密码、密钥)
- PersistentVolume:持久化存储