-
Notifications
You must be signed in to change notification settings - Fork 1
Configure Minio buckets, policies, and users #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 44 commits
Commits
Show all changes
45 commits
Select commit
Hold shift + click to select a range
939bc38
Add k8s job to interact with minio server
craddm b6497ea
Merge remote-tracking branch 'upstream/cilium' into configure-minio
craddm f71086b
use job to give set up a container with minio credentials
craddm 7afd928
Merge remote-tracking branch 'upstream/main' into configure-minio
craddm e26c69b
Mount script and policies using configmap, then run job to configure …
craddm d915ff1
Create Minio buckets using helm chart
craddm 757a85f
Fix typo
craddm 3b49c27
strip json from filename for policy name
craddm d8da113
Add pulumi random to requirements
craddm 5933dcb
create some initial secrets with account details
craddm 0ebd29f
Add depends on secrets
craddm 363f016
specify user names in minio tenant values
craddm 2a38503
Merge remote-tracking branch 'upstream/main' into configure-minio
craddm ca3f047
Use minio_alias variable in template
craddm fad0c0b
Add some additional comments to the code
craddm a6280d1
Merge remote-tracking branch 'upstream/main' into configure-minio
craddm 1a677ae
Merge branch 'main' into configure-minio
craddm 089ef92
Merge remote-tracking branch 'upstream/main' into configure-minio
craddm 5f132e6
Merge branch 'main' into configure-minio
craddm 46a41c4
Take minio config code out of main and into its own component file
craddm cbdbe8a
Add minio config component to init
craddm 181be87
Refactoring minio configuration files
craddm 8818825
Make network policies depend on minio config completion
craddm 9df84ba
Correct shell script syntax
craddm a6fd45f
Delete unneeded files
craddm 0913ef9
Add policy to be used for argo workflows pods
craddm d7c7595
Add policy for argo workflow pods
craddm e9fea99
Add rule to allow minio config job to access MinIO service
craddm deffadd
Move policies to separate directory and load them dynamically
craddm e298a73
Merge branch 'main' into configure-minio
craddm 55e0119
Modify minio component to expose namespaces and charts as attributes
craddm 384a7de
Remove unneeded imports and fix references to instance variables
craddm 4de7a87
Rename policy files
craddm 6b695e9
Pass minio resources to MinioConfigJob
craddm 7743103
Add network rules to allow Minio Config jobs to access Minio
craddm af03327
Add ingress and egress buckets
LakshithadeSilva b6a8a6c
Setup anonymous access on ingress/egress buckests
LakshithadeSilva 5861beb
Merge branch 'main' into configure-minio
craddm 2e7fec3
Delete superfluous minio policy folder
craddm aeac722
Remove unused 'load_policy' function
LakshithadeSilva 9e801c5
Update infra/fridge/__main__.py
craddm 8adcfef
Update infra/fridge/requirements.txt
craddm 64b3be3
Fix linting
craddm ea2cf73
Merge branch 'main' into configure-minio
craddm 7905150
Modify script for configuring MinIO to use environment variables
craddm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| import os | ||
| from pulumi import ComponentResource, ResourceOptions | ||
| from pulumi_kubernetes.batch.v1 import ( | ||
| Job, | ||
| JobSpecArgs, | ||
| ) | ||
| from pulumi_kubernetes.core.v1 import ( | ||
| ConfigMap, | ||
| ConfigMapVolumeSourceArgs, | ||
| ContainerArgs, | ||
| EnvVarArgs, | ||
| Namespace, | ||
| PodSpecArgs, | ||
| PodTemplateSpecArgs, | ||
| SecurityContextArgs, | ||
| VolumeMountArgs, | ||
| VolumeArgs, | ||
| ) | ||
| from pulumi_kubernetes.helm.v4 import Chart | ||
| from pulumi_kubernetes.meta.v1 import ObjectMetaArgs | ||
|
|
||
|
|
||
| class MinioConfigArgs: | ||
| def __init__( | ||
| self, minio_tenant_ns: Namespace, minio_tenant: Chart, minio_credentials: dict | ||
| ): | ||
| self.minio_tenant_ns = minio_tenant_ns | ||
| self.minio_tenant = minio_tenant | ||
| self.minio_credentials = minio_credentials | ||
|
|
||
|
|
||
| class MinioConfigJob(ComponentResource): | ||
| def __init__( | ||
| self, name: str, args: MinioConfigArgs, opts: ResourceOptions | None = None | ||
| ) -> None: | ||
| super().__init__("fridge:k8s:MinioConfigJob", name, {}, opts) | ||
| child_opts = ResourceOptions.merge(opts, ResourceOptions(parent=self)) | ||
|
|
||
| minio_setup_sh = """ | ||
| echo "Configuring ingress and egress buckets with anonymous S3 policies" | ||
| mc anonymous set upload $1/egress | ||
| mc anonymous set download $1/ingress | ||
| """ | ||
|
|
||
| # Create a ConfigMap for MinIO configuration | ||
| minio_config_map = ConfigMap( | ||
| "minio-configuration", | ||
| metadata=ObjectMetaArgs( | ||
| name="minio-configuration", | ||
| namespace=args.minio_tenant_ns.metadata.name, | ||
| ), | ||
| data={ | ||
| "MINIO_ALIAS": "argoartifacts", | ||
| "MINIO_URL": "http://minio.argo-artifacts.svc.cluster.local:80", | ||
| "MINIO_NAMESPACE": args.minio_tenant_ns.metadata.name, | ||
| "setup.sh": minio_setup_sh, | ||
| }, | ||
| opts=child_opts, | ||
| ) | ||
|
|
||
| # Create a Job to configure MinIO | ||
| Job( | ||
| "minio-config-job", | ||
| metadata=ObjectMetaArgs( | ||
| name="minio-config-job", | ||
| namespace=args.minio_tenant_ns.metadata.name, | ||
| labels={"app": "minio-config-job"}, | ||
| ), | ||
| spec=JobSpecArgs( | ||
| backoff_limit=1, | ||
| template=PodTemplateSpecArgs( | ||
| spec=PodSpecArgs( | ||
| containers=[ | ||
| ContainerArgs( | ||
| name="minio-config-job", | ||
| image="minio/mc:latest", | ||
| command=[ | ||
| "/bin/sh", | ||
| "-c", | ||
| ], | ||
| args=[ | ||
| "mc --insecure alias set argoartifacts http://minio.argo-artifacts.svc.cluster.local:80 $(MINIO_ROOT_USER) $(MINIO_ROOT_PASSWORD) &&" | ||
| "/tmp/scripts/setup.sh argoartifacts;", | ||
| ], | ||
| resources={ | ||
| "requests": { | ||
| "cpu": "100m", | ||
| "memory": "128Mi", | ||
| }, | ||
| "limits": { | ||
| "cpu": "100m", | ||
| "memory": "128Mi", | ||
| }, | ||
| }, | ||
| env=[ | ||
| EnvVarArgs(name="MC_CONFIG_DIR", value="/tmp/.mc"), | ||
| EnvVarArgs( | ||
| name="MINIO_ROOT_USER", | ||
| value=args.minio_credentials.get( | ||
| "minio_root_user", "" | ||
| ), | ||
| ), | ||
| EnvVarArgs( | ||
| name="MINIO_ROOT_PASSWORD", | ||
| value=args.minio_credentials.get( | ||
| "minio_root_password", "" | ||
| ), | ||
| ), | ||
| ], | ||
| security_context=SecurityContextArgs( | ||
| allow_privilege_escalation=False, | ||
| capabilities={"drop": ["ALL"]}, | ||
| run_as_group=1000, | ||
| run_as_non_root=True, | ||
| run_as_user=1000, | ||
| seccomp_profile={"type": "RuntimeDefault"}, | ||
| ), | ||
| volume_mounts=[ | ||
| VolumeMountArgs( | ||
| name="minio-config-volume", | ||
| mount_path="/tmp/scripts/", | ||
| ) | ||
| ], | ||
| ) | ||
| ], | ||
| volumes=[ | ||
| VolumeArgs( | ||
| name="minio-config-volume", | ||
| config_map=ConfigMapVolumeSourceArgs( | ||
| name=minio_config_map.metadata.name, | ||
| default_mode=0o777, | ||
| ), | ||
| ) | ||
| ], | ||
| restart_policy="Never", | ||
| ), | ||
| ), | ||
| ), | ||
| opts=child_opts, | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to pass some commands as an argument here and others in a script?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@craddm possibly explain better, but 'mc' expects the alias to set first so the subsequent commands can refer to that alias. The script includes a bunch of mc commands, but alternatively we can have those here as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, does it not work if the
mc alias setcommand is in the script?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified this so all the commands are in the script, and the script now gets everything from the environment variables instead