k8s之volumes和volumeMounts

bash 复制代码
apiVersion: apps/v1
kind: Deployment
metadata:
  name: python-deployment
spec:
  replicas: 1
  selector:
    matchLabels:
      app: python-app
  template:
    metadata:
      labels:
        app: python-app
    spec:
      containers:
        - name: python-container
          image: python:3.9
          command: ["python", "-m", "http.server", "8000"]
          ports:
            - containerPort: 8000
          volumeMounts:
            - name: data-volume
              mountPath: /app/data
              subPath: data1
      volumes:
        - name: data-volume
          hostPath:
            path: /root/data

---
apiVersion: v1
kind: Service
metadata:
  name: python-service
spec:
  selector:
    app: python-app
  ports:
    - protocol: TCP
      port: 80
      targetPort: 8000

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: python-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
    - host: domain.com
      http:
        paths:
          - path: /app1
            pathType: Prefix
            backend:
              service:
                name: python-service
                port:
                  number: 80
相关推荐
码云数智-园园1 小时前
我为什么从微服务退回单体架构
微服务·云原生·架构
DevOps老兵1 小时前
AI Infra实战05:用Helm在K8s中部署vLLM,从安装到压测全流程
人工智能·kubernetes·helm·vllm·大模型推理·ai infra
Asum1ta1 小时前
生产环境 Kubernetes 高可用集群部署实战:外部 etcd + Keepalived + HAProxy + 多 Master 架构
架构·kubernetes·etcd
dazhong20122 小时前
Docker 进阶篇(一) CentOS 7 离线升级 Docker 完整实战
docker·容器·centos
源代码•宸2 小时前
前置准备:定时微服务有什么价值
经验分享·后端·微服务·云原生·架构
雾隐隐o3 小时前
Docker Compose 多容器编排实战
运维·docker·容器
IT大白鼠3 小时前
Kubernetes 核心资源ReplicaSet 控制器详解
云原生·容器·kubernetes
μθημα4 小时前
Kubernetes 微服务网络实践:Service 与 Ingress 从入门到灰度发布
网络·微服务·kubernetes
众人皆醒我独醉4 小时前
Kubernetes GPU 调度与管理的完整机制——从节点上架到 Pod 拿到 GPU
面试·kubernetes·gpu