0
点赞
收藏
分享

微信扫一扫

K8S数据持久化

SPEIKE 2022-02-11 阅读 65

K8S实现pod数据持久化

前言

1.实现方式

2.实现过程

2.1 部署nfs服务

2.2 在K8S中配置pv,pvc

2.3 pod绑定pvc

vim nginx-deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: blog-nginx
  labels:
    app: nginx
spec:
  replicas: 1
  selector:
    matchLabels:
      app: blog-nginx
      tier: frontend
  template:
    metadata:
      labels:
        app: blog-nginx
        tier: frontend
    spec:
      nodeSelector:
        nginxssr: ssr
      containers:
      - name: nginx
        image: nginx:v2
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 80
          name: nginx
        - containerPort: 443
          name: nginx-ssl
        volumeMounts:
        - name: config
          mountPath: /etc/nginx/conf.d/
        - name: dir
          mountPath: /var/www/
        resources:
          requests:
            memory: 300Mi
            cpu: 200m
          limits:
            memory: 800Mi
            cpu: 700m
      volumes:
      - name: config
        configMap:
          name: nginx-wp-config
      - name: dir
        persistentVolumeClaim:
          claimName: nginx-pvc   #填写pvc的名称
举报

相关推荐

0 条评论