From cd22e09a126394de1c5fa26bc96d8c375b78513b Mon Sep 17 00:00:00 2001 From: Dustin Kaiser Date: Tue, 3 Dec 2024 10:37:22 +0100 Subject: [PATCH] Clean Up Local Minio --- services/minio/Makefile | 44 +++---------------- services/minio/README.md | 27 ------------ .../docker-compose.letsencrypt.dns.yaml.j2 | 11 ----- .../docker-compose.letsencrypt.http.yaml.j2 | 11 ----- ...er-compose.yaml.j2 => docker-compose.yaml} | 40 +++-------------- services/minio/secrets/.gitkeep | 0 services/minio/template.env | 6 --- 7 files changed, 13 insertions(+), 126 deletions(-) delete mode 100644 services/minio/README.md delete mode 100644 services/minio/docker-compose.letsencrypt.dns.yaml.j2 delete mode 100644 services/minio/docker-compose.letsencrypt.http.yaml.j2 rename services/minio/{docker-compose.yaml.j2 => docker-compose.yaml} (51%) delete mode 100644 services/minio/secrets/.gitkeep diff --git a/services/minio/Makefile b/services/minio/Makefile index f5c260f1..40b0f797 100644 --- a/services/minio/Makefile +++ b/services/minio/Makefile @@ -1,9 +1,7 @@ .DEFAULT_GOAL := help - - # Internal VARIABLES ------------------------------------------------ -# STACK_NAME defaults to name of the current directory. Should not to be changed if you follow GitOps operating procedures. +# STACK_NAME defaults to name of the current directory. STACK_NAME = $(notdir $(shell pwd)) DOCKER_MINIO_ACCESS_KEY = $(shell docker secret inspect --format {{.Spec.Name}} minio_secret_key 2>/dev/null) DOCKER_MINIO_SECRET_KEY = $(shell docker secret inspect --format {{.Spec.Name}} minio_access_key 2>/dev/null) @@ -14,52 +12,22 @@ REPO_BASE_DIR := $(shell git rev-parse --show-toplevel) include ${REPO_BASE_DIR}/scripts/common.Makefile .PHONY: up -up: .init .env ${TEMP_COMPOSE} .create-secrets ## Deploys or updates current stack "$(STACK_NAME)" using replicas=X (defaults to 1) +up: .init .env ${TEMP_COMPOSE} .create-secrets @docker stack deploy --with-registry-auth --prune --compose-file ${TEMP_COMPOSE} $(STACK_NAME) - # "in case you created more than 1 replicas, you need to label the nodes accordingly using" - # "'docker node update --label-add minioX=true' with X being from 1 to number of replicas." - -.PHONY: up-letsencrypt-http -up-letsencrypt-http: .init .env ${TEMP_COMPOSE}-letsencrypt-http .create-secrets ## Deploys minio stack using let's encrypt http challenge - @docker stack deploy --with-registry-auth --prune --compose-file ${TEMP_COMPOSE}-letsencrypt-http ${STACK_NAME} - # "in case you created more than 1 replicas, you need to label the nodes accordingly using" - # "'docker node update --label-add minioX=true' with X being from 1 to number of replicas." - -.PHONY: up-letsencrypt-dns -up-letsencrypt-dns: .init .env ${TEMP_COMPOSE}-letsencrypt-dns .create-secrets ## Deploys minio stack using let's encrypt dns challenge - @docker stack deploy --with-registry-auth --prune --compose-file ${TEMP_COMPOSE}-letsencrypt-dns ${STACK_NAME} - # "in case you created more than 1 replicas, you need to label the nodes accordingly using" - # "'docker node update --label-add minioX=true' with X being from 1 to number of replicas." .PHONY: up-dalco -up-dalco: up ## Deploys minio stack for Dalco Cluster +up-dalco: up .PHONY: up-master -up-master: up ## Deploys minio stack for Master Cluster +up-master: up .PHONY: up-local up-local: up .PHONY: ${TEMP_COMPOSE} -${TEMP_COMPOSE}: docker-compose.yaml.j2 .venv .env - $(call jinja, $<, tmp.yaml) - @${REPO_BASE_DIR}/scripts/docker-stack-config.bash -e .env tmp.yaml > $@ - @rm tmp.yaml - -.PHONY: ${TEMP_COMPOSE}-letsencrypt-http -${TEMP_COMPOSE}-letsencrypt-http: docker-compose.yaml.j2 docker-compose.letsencrypt.http.yaml.j2 .venv .env - $(call jinja, $<, tmp.yaml) - $(call jinja, docker-compose.letsencrypt.http.yaml.j2, tmp-letsencrypt.http.yaml) - @${REPO_BASE_DIR}/scripts/docker-stack-config.bash -e .env tmp.yaml tmp-letsencrypt.http.yaml > $@ - @rm tmp.yaml tmp-letsencrypt.http.yaml - +${TEMP_COMPOSE}: docker-compose.yaml .venv .env + @${REPO_BASE_DIR}/scripts/docker-stack-config.bash -e .env docker-compose.yaml > $@ -.PHONY: ${TEMP_COMPOSE}-letsencrypt-dns -${TEMP_COMPOSE}-letsencrypt-dns: docker-compose.yaml.j2 docker-compose.letsencrypt.dns.yaml.j2 .venv .env - $(call jinja, $<, tmp.yaml) - $(call jinja, docker-compose.letsencrypt.dns.yaml.j2, tmp-letsencrypt.dns.yaml) - @${REPO_BASE_DIR}/scripts/docker-stack-config.bash -e .env tmp.yaml tmp-letsencrypt.dns.yaml > $@ - @rm tmp.yaml tmp-letsencrypt.dns.yaml .create-secrets: @$(if $(DOCKER_MINIO_ACCESS_KEY), \ diff --git a/services/minio/README.md b/services/minio/README.md deleted file mode 100644 index 309e52f9..00000000 --- a/services/minio/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# Minio (S3) stack - -Creates a S3 storage stack using [minio](https://docs.min.io/docs/deploy-minio-on-docker-swarm.html). - -## Configuration - -### Distributed mode - -1. edit .env file -2. __MINIO_ACCESS_KEY__ and __MINIO_SECRET_KEY__ to be manually defined -3. define the number of instances __MINIO_NUM_MINIOS__ and the number of partitions in each instance __MINIO_NUM_PARTITIONS__ according to [minio docs](https://docs.min.io/docs/distributed-minio-quickstart-guide.html) -4. __MINIO_INTERNAL_VOLUME_DATA_PART__ may be defined to mount folders. -5. Each node where a minio instance shall run shall be labelled with __minio=true__ using __docker node update --label-add minio=true __ - -### Local dev mode - -1. edit .env file -2. __MINIO_ACCESS_KEY__ and __MINIO_SECRET_KEY__ to be manually defined -3. Defaults will create 1 instance with 1 partition - -## Usage - - ```console - make help - make up - make down - ``` diff --git a/services/minio/docker-compose.letsencrypt.dns.yaml.j2 b/services/minio/docker-compose.letsencrypt.dns.yaml.j2 deleted file mode 100644 index aeadf7c7..00000000 --- a/services/minio/docker-compose.letsencrypt.dns.yaml.j2 +++ /dev/null @@ -1,11 +0,0 @@ -version: '3.7' -services: -{% set num_minios = MINIO_NUM_MINIOS %} -{% set num_partitions = MINIO_NUM_PARTITIONS %} -{%- for i in range(num_minios|int) %} - {%- set service_id = i+1 %} - minio{{ service_id|string }}: - deploy: - labels: - - traefik.http.routers.minio.tls.certresolver=myresolver -{% endfor %} diff --git a/services/minio/docker-compose.letsencrypt.http.yaml.j2 b/services/minio/docker-compose.letsencrypt.http.yaml.j2 deleted file mode 100644 index aeadf7c7..00000000 --- a/services/minio/docker-compose.letsencrypt.http.yaml.j2 +++ /dev/null @@ -1,11 +0,0 @@ -version: '3.7' -services: -{% set num_minios = MINIO_NUM_MINIOS %} -{% set num_partitions = MINIO_NUM_PARTITIONS %} -{%- for i in range(num_minios|int) %} - {%- set service_id = i+1 %} - minio{{ service_id|string }}: - deploy: - labels: - - traefik.http.routers.minio.tls.certresolver=myresolver -{% endfor %} diff --git a/services/minio/docker-compose.yaml.j2 b/services/minio/docker-compose.yaml similarity index 51% rename from services/minio/docker-compose.yaml.j2 rename to services/minio/docker-compose.yaml index 95c8b898..635441fd 100644 --- a/services/minio/docker-compose.yaml.j2 +++ b/services/minio/docker-compose.yaml @@ -1,22 +1,11 @@ version: '3.7' services: -{% set num_minios = MINIO_NUM_MINIOS %} -{% set num_partitions = MINIO_NUM_PARTITIONS %} -{% set host_folder = MINIO_HOST_DATA_FOLDER %} -{%- for i in range(num_minios|int) %} - {%- set service_id = i+1 %} - minio{{ service_id|string }}: + minio: image: minio/minio:RELEASE.2023-06-19T19-52-50Z init: true - hostname: minio{{ service_id|string }} - volumes: # default uses a named volume, option2 is to use the variable to set specific mount path(s) - {%- for j in range(num_partitions|int) %} - {% if host_folder == 'true' %} - - /data/disk{{ j|string }}/minio:/data{{ j|string }} - {% else %} - - minio{{ service_id|string }}_data_part{{ j|string }}:/data{{ j|string }} - {% endif %} - {%- endfor %} + hostname: minio + volumes: + - minio_data:/data networks: - default - public @@ -32,11 +21,6 @@ services: delay: 10s max_attempts: 10 window: 60s - {%- if num_minios|int > 1 %} - placement: - constraints: - - {{ "node.labels.minio" ~ service_id|string ~ "==true" }} - {%- endif %} labels: - traefik.enable=true - traefik.docker.network=${PUBLIC_NETWORK} @@ -48,23 +32,13 @@ services: - traefik.http.routers.minio.tls=true - traefik.http.routers.minio.middlewares=ops_gzip@swarm command: > - server - {%- for i in range(num_minios|int) %} - {%- for j in range(num_partitions|int) %} - {% if num_minios|int > 1 %}http://minio{{ (i+1)|string }}{% endif %}/data{{ j|string }} - {%- endfor %} - {%- endfor %} + server /data secrets: - minio_secret_key - minio_access_key - -{% endfor %} volumes: -{%- for i in range(num_minios|int) %} -{%- for j in range(num_partitions|int) %} - minio{{ (i+1)|string }}_data_part{{ j|string }}: -{%- endfor %} -{%- endfor %} + minio_data: + networks: public: diff --git a/services/minio/secrets/.gitkeep b/services/minio/secrets/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/services/minio/template.env b/services/minio/template.env index de4fcf46..d9a99f67 100644 --- a/services/minio/template.env +++ b/services/minio/template.env @@ -1,10 +1,4 @@ # define MINIO Access and Secret keys MINIO_ACCESS_KEY=${S3_ACCESS_KEY} MINIO_SECRET_KEY=${S3_SECRET_KEY} -# define the number of MINIO replicas -MINIO_NUM_MINIOS=${MINIO_NUM_MINIOS} -# define the number of partitions each MINIO may be using -MINIO_NUM_PARTITIONS=${MINIO_NUM_PARTITIONS} -# optionally activate the host data folder for each partition (must be /data/diskX/minio on each node where X is the disk number if there is more than one disk per node) -MINIO_HOST_DATA_FOLDER=${MINIO_HOST_DATA_FOLDER} STORAGE_DOMAIN=${STORAGE_DOMAIN}