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
相关推荐
Elastic 中国社区官方博客5 小时前
为 Elastic Cloud Serverless 和 Elasticsearch 引入统一的 API 密钥
大数据·运维·elasticsearch·搜索引擎·云原生·serverless
空中海5 小时前
Kubernetes 生产实践、可观测性与扩展入门
java·贪心算法·kubernetes
Devin~Y6 小时前
大厂Java面试实录:Spring Boot/Cloud、Kafka、Redis、K8s 与 Spring AI(RAG/Agent)三轮连环问
java·spring boot·redis·mysql·spring cloud·kafka·kubernetes
深色風信子6 小时前
Docker newapi
运维·docker·容器·newapi
旷世奇才李先生7 小时前
Spring Cloud Alibaba 2026实战:微服务治理全解析
微服务·云原生·架构
GL_Rain9 小时前
快速搭建Halo博客 + 崩溃秒恢复方案(Docker极简部署)
运维·docker·容器
lar_slw10 小时前
k8s部署前端项目
前端·容器·kubernetes
米高梅狮子13 小时前
06.Kubernetes Secret和Kubernetes Controllers
云原生·容器·kubernetes
雨奔13 小时前
Kubernetes 实操:创建 LimitRange 和 Pod 并管理内存资源
云原生·容器·kubernetes
LSL666_14 小时前
什么是微服务
微服务·云原生·架构