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
相关推荐
qwy7152292581631 小时前
1-Docker Engine 安装前置环境配置
运维·docker·容器
sszdzq4 小时前
docker 安装 doris
运维·docker·容器
海的透彻6 小时前
docker容器进程探究
运维·docker·容器
❀͜͡傀儡师6 小时前
ShadowBroker:实时全球情报地图,开源情报(OSINT)的终极聚合平台
docker·容器·llama
么卡6 小时前
我在 Debian 11 上把 K8s 单机搭起来了,过程没你想的那么顺(/opt 目录版)
kubernetes
AI攻城狮7 小时前
Adaptive Thinking 的代价:当 AI 自己决定"想多少"
人工智能·云原生·aigc
Dontla8 小时前
Kubernetes Liveness Probe存活探针 / Readiness Probe就绪探针介绍(Startup Probe启动探针)重启容器
云原生·容器·kubernetes
格林威9 小时前
工业相机 SDK 在 Docker 容器中的部署与权限配置(含 USB/GigE)
开发语言·人工智能·数码相机·计算机视觉·docker·容器·工业相机
AI攻城狮9 小时前
Vibe Coding 时代:为什么你不应该盲目启用 AI 编码插件
人工智能·云原生·aigc
Gofarlic_OMS10 小时前
Windchill的license合规使用报告自动化生成与审计追踪系统
大数据·运维·人工智能·云原生·自动化·云计算