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
相关推荐
正经教主22 分钟前
【docker基础】 第七课:Docker Compose 多容器实战
运维·docker·容器
正经教主31 分钟前
【docker基础】Redis的docker部署
redis·docker·容器
DolphinScheduler社区41 分钟前
Apache DolphinScheduler 3.4.2 正式发布!新增 Amazon EMR Serverless 插件,增强监控与补数据能力
大数据·云原生·serverless·apache·海豚调度·版本发版
成为你的宁宁1 小时前
【基于 Prometheus Operator 实现 K8s 环境下 Redis Cluster 集群监控部署】
redis·kubernetes·prometheus
是一个Bug1 小时前
Docker 与 Kubernetes:从“集装箱”到“远洋舰队”
docker·容器·kubernetes
heimeiyingwang1 小时前
【架构实战】注册中心选型:Nacos vs Eureka vs Consul
微服务·云原生·架构
java_cj1 小时前
阅读 k8s 源码的准备工作
云原生·容器·kubernetes
开发者联盟league2 小时前
使用Jenkins整合Sonarqube/Gitlab/Harbor/Kubernetes实现CICD
kubernetes·gitlab·jenkins
蜀道山老天师2 小时前
OpenClaw 从零部署 + 飞书机器人完整接入(实操篇)
运维·docker·容器·飞书
robinLi09132 小时前
docker mac 下载不同系统架构镜像
macos·docker·容器