| 14 | |
| 15 | |
| 16 | class Minio(K8sResource): |
| 17 | def __init__( |
| 18 | self, namespace: str = DEFAULT_K8S_NAMESPACE, apply_node_selectors: bool = False |
| 19 | ) -> None: |
| 20 | super().__init__(namespace) |
| 21 | self.apply_node_selectors = apply_node_selectors |
| 22 | |
| 23 | def create(self) -> None: |
| 24 | self.kubectl( |
| 25 | "delete", |
| 26 | "persistentvolumeclaim", |
| 27 | "minio-pv-claim", |
| 28 | "--ignore-not-found", |
| 29 | "true", |
| 30 | ) |
| 31 | |
| 32 | # the PVC will be created afterwards |
| 33 | for yaml_file in [ |
| 34 | "minio-standalone-deployment", |
| 35 | "minio-standalone-service", |
| 36 | ]: |
| 37 | self.kubectl( |
| 38 | "create", |
| 39 | "-f", |
| 40 | f"{MINIO_YAML_DIRECTORY_URL}/{yaml_file}.yaml", |
| 41 | ) |
| 42 | |
| 43 | if self.apply_node_selectors: |
| 44 | self.kubectl( |
| 45 | "patch", |
| 46 | "deployment", |
| 47 | "minio-deployment", |
| 48 | "--type", |
| 49 | "json", |
| 50 | "-p", |
| 51 | '[{"op": "add", "path": "/spec/template/spec/nodeSelector", "value": {"supporting-services": "true"} }]', |
| 52 | ) |
| 53 | |
| 54 | # the PVC needs to be created after patching the deployment |
| 55 | self.kubectl( |
| 56 | "create", |
| 57 | "-f", |
| 58 | f"{MINIO_YAML_DIRECTORY_URL}/minio-standalone-pvc.yaml", |
| 59 | ) |
| 60 | |
| 61 | self.wait( |
| 62 | resource="deployment.apps/minio-deployment", |
| 63 | condition="condition=Available=True", |
| 64 | timeout_secs=600, |
| 65 | ) |
| 66 | |
| 67 | self.create_buckets(["persist", "copytos3", "copyfroms3"]) |
| 68 | |
| 69 | def create_buckets(self, buckets: list[str]) -> None: |
| 70 | cmds = [ |
| 71 | f"mc config host add myminio http://minio-service.{self.namespace()}:9000 minio minio123" |
| 72 | ] |
| 73 | for bucket in buckets: |
no outgoing calls
no test coverage detected