Home > other >  Using hostPath about mongo kubernetes mount not persistent
Using hostPath about mongo kubernetes mount not persistent

Time:10-06

before made a middleware services for the company based on kubernetes cloud platform, main is to use image generation middleware for use in kubernetes, done with mongo but haven't got the chance, today is a big problem was used for the first time, directing the persistent file with hostPath mount lost causes container restart data is less than a host computer, hope can help to have a look at the great god, grateful!!!!!!

First of all, this is the list of middleware screenshots:



then I use kubectl describe pod once, you can see I put in the container mongo/data directory mounted to the host machine/data/mongo/midware/mongo - yapi directory:


then exec enter the mongo's container, check according to the front end of the configuration of the user to select generate mongo configuration file:
root @ mongo - yapi - f9db75b6 - NLKKN:/etc/mongo# cat mongod. Conf
SystemLog:
Verbosity: 0
Quiet: true
TraceAllExceptions: true
# path:/data/mongo. Log
# logAppend: true
# logRotate: rename
# destination: the file
TimeStampFormat: iso8601 - local
ProcessManagement:
The fork: false
# pidFilePath:/data/mongo. Pid
Net:
Port: 27017
BindIp: 0.0.0.0
MaxIncomingConnections: 20000
WireObjectCheck: true
Security:
Authorization: disabled
JavascriptEnabled: true
Storage:
dbPath:/data/db
IndexBuildRetry: true
Journal:
Enabled: true
CommitIntervalMs: 100
DirectoryPerDB: false

60 syncPeriodSecs:Engine: wiredTiger
Mmapv1:
PreallocDataFiles: false
16 nsSize:
Quota:
Enforced: false
MaxFilesPerDB: 8
SmallFiles: false
WiredTiger:
EngineConfig:
CacheSizeGB: 1
JournalCompressor: after
DirectoryForIndexes: false
CollectionConfig:
BlockCompressor: after
IndexConfig:
PrefixCompression: true
OperationProfiling:
SlowOpThresholdMs: 100


mongo's persistent files are stored in the container is here/data/db directory, theoretically in/data on host/mongo/midware/mongo yapi/db directory also should have mongo's persistent file:



mongo's persistent file, but not on host... Into the container, check under/data directory permissions is like this:


in the container, I create a new directory in/data folder test, and touch in the folder a file 111. TXT, retired from a container in hosting the directory you can see the new folders and files:



you can see I do within the container/data directory mounted to the host machine/data/mongo/midware/mongo - yapi/directory, then even permissions or the file attributes of problem, I do all test again, in a container persistent file is copied from the mongo:


then I to the host machine directory view:


Results the persistent file all out... So was wondering what is this problem, because of the serious affect the use of the mongo, so the problem is try so hard, the hope can guide the great god, thank you!!!!!!

CodePudding user response:

The same problem, hostpath completely useless, the case cannot repetition of others
  • Related