Skip to content
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

Helm Chart: Add support for only one replica #18577

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ChillerDragon
Copy link

Community Contribution License

All community contributions in this pull request are licensed to the project maintainers
under the terms of the Apache 2 license.
By creating this pull request I represent that I have the right to license the
contributions to the project maintainers under the Apache 2 license.

Description

Add support for only one replica in the helm chart

Motivation and Context

using replicas: 1 used to render something like this:

"/usr/bin/docker-entrypoint.sh minio server http://release-name-minio-{0...0}.release-name-minio-svc.my-k8s-ns.svc.cluster.local/export -S /etc/minio/certs/ --address :9000 --console-address :9001"

Where {0...0} is not supported by the minio server. Now extended with the if statement it will render out the following:

"/usr/bin/docker-entrypoint.sh minio server http://release-name-minio-0.release-name-minio-svc.my-k8s-ns.svc.cluster.local/export -S /etc/minio/certs/ --address :9000 --console-address :9001"

The line I edited is one big cluster fuck its basically looping over num pools and then creating a range for num replicas. And I added a additional if else statement in the loop saying it should not create a range if start and end are equal and instead just put the digit as is.

How to test this PR?

I used the helm template preview vscode extension to look at the rendered yaml. But any helm template renderer should work fine.

image

Then play with the pools: and replicas: amount and ensure it never produces invalid urls such as {0...0} while still maintaing multi pool support where every url is unique. Here a few examples so you don't have to do it:

The default

replicas: 16
pools: 1
"/usr/bin/docker-entrypoint.sh minio server  http://release-name-minio-{0...15}.release-name-minio-svc.my-k8s-ns.svc.cluster.local/export -S /etc/minio/certs/ --address :9000 --console-address :9001"

The case im trying to fix which used to render {0...0}:

replicas: 1
pools: 1
"/usr/bin/docker-entrypoint.sh minio server  http://release-name-minio-0.release-name-minio-svc.my-k8s-ns.svc.cluster.local/export -S /etc/minio/certs/ --address :9000 --console-address :9001"

Support for multiple pools is still kept:

replicas: 1
pools: 2
 "/usr/bin/docker-entrypoint.sh minio server  http://release-name-minio-0.release-name-minio-svc.my-k8s-ns.svc.cluster.local/export  http://release-name-minio-1.release-name-minio-svc.my-k8s-ns.svc.cluster.local/export -S /etc/minio/certs/ --address :9000 --console-address :9001"

And support for multi pool and multi node:

replicas: 2
pools: 2
"/usr/bin/docker-entrypoint.sh minio server  http://release-name-minio-{0...1}.release-name-minio-svc.my-k8s-ns.svc.cluster.local/export  http://release-name-minio-{2...3}.release-name-minio-svc.my-k8s-ns.svc.cluster.local/export -S /etc/minio/certs/ --address :9000 --console-address :9001"

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Optimization (provides speedup with no functional changes)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • Fixes a regression (If yes, please add commit-id or PR # here)
  • Unit tests added/updated
  • Internal documentation updated
  • Create a documentation update request here

using ``replicas: 1`` used to render something like this:
```
"/usr/bin/docker-entrypoint.sh minio server http://release-name-minio-{0...0}.release-name-minio-svc.platform-datawarehouse-develop.svc.cluster.local/export -S /etc/minio/certs/ --address :9000 --console-address :9001"
```

Where ``{0...0}`` is not supported by the minio server.
Now extended with the if statement it will render out the following:
```
"/usr/bin/docker-entrypoint.sh minio server http://release-name-minio-0.release-name-minio-svc.platform-datawarehouse-develop.svc.cluster.local/export -S /etc/minio/certs/ --address :9000 --console-address :9001"
```
@@ -100,7 +100,7 @@ spec:
command: [
"/bin/sh",
"-ce",
"/usr/bin/docker-entrypoint.sh minio server {{- range $i := until $poolCount }}{{ $factor := mul $i $nodeCount }}{{ $endIndex := add $factor $nodeCount }}{{ $beginIndex := mul $i $nodeCount }} {{ $scheme }}://{{ template `minio.fullname` $ }}-{{ `{` }}{{ $beginIndex }}...{{ sub $endIndex 1 }}{{ `}`}}.{{ template `minio.fullname` $ }}-svc.{{ $.Release.Namespace }}.svc.{{ $.Values.clusterDomain }}{{if (gt $drivesPerNode 1)}}{{ $bucketRoot }}-{{ `{` }}0...{{ sub $drivesPerNode 1 }}{{ `}` }}{{ else }}{{ $bucketRoot }}{{end }}{{- end }} -S {{ .Values.certsPath }} --address :{{ .Values.minioAPIPort }} --console-address :{{ .Values.minioConsolePort }} {{- template `minio.extraArgs` . }}"
"/usr/bin/docker-entrypoint.sh minio server {{- range $i := until $poolCount }}{{ $factor := mul $i $nodeCount }}{{ $endIndex := add $factor $nodeCount }}{{ $beginIndex := mul $i $nodeCount }} {{ $scheme }}://{{ template `minio.fullname` $ }}-{{ if lt ($beginIndex) (sub $endIndex 1) }}{{ `{` }}{{ $beginIndex }}...{{ sub $endIndex 1 }}{{ `}`}}{{ else }}{{ $beginIndex }}{{ end }}.{{ template `minio.fullname` $ }}-svc.{{ $.Release.Namespace }}.svc.{{ $.Values.clusterDomain }}{{if (gt $drivesPerNode 1)}}{{ $bucketRoot }}-{{ `{` }}0...{{ sub $drivesPerNode 1 }}{{ `}` }}{{ else }}{{ $bucketRoot }}{{end }}{{- end }} -S {{ .Values.certsPath }} --address :{{ .Values.minioAPIPort }} --console-address :{{ .Values.minioConsolePort }} {{- template `minio.extraArgs` . }}"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For single replica it must be just single disk local so there is no reason to provide headless name.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is a headless name 🙈. I Am not following sorry.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where you are specifying minio server https://hostname/local/disk

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that a problem I introduced? Or something unrelated you want me to fix? Does providing the headless name break something? It has been over 2 months so I have to look closely at this mess of a one liner again but at first glance it seems to me like it would require the line to grow even longer. Adding another condition in front of {{ $scheme }}://... if that fixes no actual issues I do not think its worth the complexity it adds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants