diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6a33c8a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +dockerfile +.gitignore +LICENSE +README.md \ No newline at end of file diff --git a/dockerfile b/dockerfile new file mode 100644 index 0000000..8470182 --- /dev/null +++ b/dockerfile @@ -0,0 +1,7 @@ +FROM python:3.9-alpine + +WORKDIR /app + +COPY . . + +CMD [ "python3", "/app/main.py" ] \ No newline at end of file diff --git a/main.py b/main.py index 58c6ddb..c6060d0 100644 --- a/main.py +++ b/main.py @@ -1,2 +1,29 @@ # A simple script that creates a file of inputted size saved at the inputted destination. -# aimed at testing storage is functioning on Longhorn running in a kubernetes cluster. \ No newline at end of file +# aimed at testing storage is functioning on Longhorn running in a kubernetes cluster. + +import os +import time + +# Get env vars: +print('Fetching configuration from environment') +size = os.getenv('STOR_SIZE') # In bytes (x1000) +path = os.getenv('STOR_PATH') + +print('Path: '+ path + ', Size: ' + size + 'B') + +def generate(number, path, size): + filepath = path + '/' + str(number) + 'stor.bin' + with open(filepath, mode='wb') as out: + out.write(os.urandom(int(size))) + + print('File of ' + size + 'B created at ' + filepath) + pass + +passes = 0 +while passes < 1000: + generate(passes,path,size) + passes += 1 + +while True: + print("Program running...") + time.sleep(10) # Is this s or ms? \ No newline at end of file