背景:
早上小伙伴打来电话,问我想要将内存挂载成硬盘使用(环境all in kubernetes),这不是内存虚拟盘吗?tmpfs…没有搞过,google一下关键词:
kubernetes tmpfs
Kubernetes tmpfs
第一个链接打开是官方文档:
恩也有中文版:
简单的介绍都是。
yaml示例
谷歌的第二个链接打开yaml的示例一个可以参照一下:
最后修改一下我的yaml and apply:
apiVersion: apps/v1
kind: Deployment
metadata:
name: pvp-game-1
spec:
replicas: 1
strategy:
rollingUpdate:
maxSurge: 0
maxUnavailable: 1
selector:
matchLabels:
app: pvp-game-1
template:
metadata:
labels:
app: pvp-game-1
spec:
containers:
- name: pvp-game-1
image: registry.cn-beijing.aliyuncs.com/develop-xxxx/pvp-game:202211042229
volumeMounts:
- mountPath: /share_assets
name: tmp
env:
- name: HOST_NAME
value: pvp-game-1
envFrom:
- configMapRef:
name: pvpgame1
ports:
- containerPort: 8955
name: game-http
- containerPort: 8970
name: game1-http
- containerPort: 28667
name: nacos-tcp
resources:
requests:
memory: "8192M"
cpu: "4"
limits:
memory: "8192M"
cpu: "4"
livenessProbe:
httpGet:
scheme: HTTP
path: /keepalive
port: 28667
initialDelaySeconds: 10
periodSeconds: 10
successThreshold: 1
failureThreshold: 3
readinessProbe:
httpGet:
scheme: HTTP
path: /keepalive
port: 28667
initialDelaySeconds: 20
periodSeconds: 10
volumes:
- name: tmp
emptyDir:
medium: Memory
sizeLimit: 500Mi
imagePullSecrets:
- name: aliyun
---
apiVersion: v1
kind: Service
metadata:
name: pvp-game-1
labels:
app: pvp-game-1
spec:
ports:
- port: 8955
name: game-http
targetPort: 8955
- port: 8970
name: game1-http
targetPort: 8970
- port: 28667
name: nacos-tcp
targetPort: 28667
selector:
app: pvp-game-1
参照官方文档medium sizeLimit .500Mi是程序小伙伴让设置的
最后apply yaml文件:
kubectl apply -f pvp-game1.yaml -n develop
验证一下:
kubectl get pods -n develop|grep pvp-game
kubectl exec -it pvp-game-1-c58694b5c-bf4nl bash -n develo
df -h
不求甚解,解决…