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
相关推荐
Chan161 小时前
【 SpringCloud | 微服务 MQ基础 】
java·spring·spring cloud·微服务·云原生·rabbitmq
2201_761199042 小时前
k8s4部署
云原生·容器·kubernetes
慌ZHANG3 小时前
云原生技术驱动 IT 架构现代化转型:企业实践与落地策略全解
云原生
小柏ぁ3 小时前
calico/node is not ready: BIRD is not ready: BGP not established with xxx
运维·docker·kubernetes
三劫散仙4 小时前
kubernetes jenkins pipeline优化拉取大仓库性能指定分支+深度
容器·kubernetes·jenkins
西京刀客4 小时前
k8s热更新-subPath 不支持热更新
云原生·容器·kubernetes·configmap·subpath
weixin_434936284 小时前
k8S 命令
linux·容器·kubernetes
nuczzz7 小时前
GPU虚拟化
docker·kubernetes·k8s·gpu·nvidia
Johny_Zhao7 小时前
2025年6月Docker镜像加速失效终极解决方案
linux·网络·网络安全·docker·信息安全·kubernetes·云计算·containerd·yum源·系统运维
爱瑞瑞8 小时前
云原生学习笔记(五) 构建 Docker 镜像与运行容器
云原生