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
相关推荐
帷幄庸者16 小时前
跨网的Kubernetes集群:从零构建混合云架构
容器·架构·kubernetes
bepeater123416 小时前
使用Kubernetes部署Spring Boot项目
spring boot·容器·kubernetes
终生成长者18 小时前
Kubernetes常用操作与概念总结--从服务器导出mongo数据,并下载到本地
服务器·容器·kubernetes
运维行者_20 小时前
深入解析 Docker 监控:核心指标完整清单
运维·服务器·网络·数据库·docker·容器·eureka
礼拜天没时间.20 小时前
容器网络配置——从互联到自定义桥接
运维·网络·docker·容器·centos
中草药z21 小时前
【Linux】拆解 Linux 容器化核心:Namespace 隔离 + cgroups 资源控制,附 LXC 容器生命周期实战
运维·docker·容器·虚拟化·namespace·lxc·cgroups
懒神降世21 小时前
基于iVentoy的PXE服务器的部署实战指南
运维·服务器·开发语言·云原生·vmware·openeuler·iventoy
江畔何人初1 天前
LVM中物理卷、物理区块、卷组、逻辑卷的概念以及它们之间的关系
linux·运维·云原生·容器·kubernetes
彷徨的蜗牛1 天前
架构进阶:微服务拆分的“生死线”
微服务·云原生·架构