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

Move helm charts git history #289

Closed
wants to merge 1,772 commits into from
Closed

Conversation

RafalKorepta
Copy link
Contributor

@RafalKorepta RafalKorepta commented Nov 8, 2024

From https://github.com/redpanda-data/helm-charts the following directories was copied:

  • charts/
    • redpanda/
    • operator/
    • console/
    • connectors/
  • pkg/
  • cmd/

There is rewrite cmd/genschema, cmd/genpartial and cmd/gotohelm as all programs in redpanda-operator are anchored in the root.

Commands

# In helm-charts-clone

git filter-repo --commit-callback "
msg = commit.message.decode('utf-8')
newmsg = re.sub('#(?=\d+)', 'redpanda-data/helm-charts#', msg)
commit.message = newmsg.encode('utf-8')
" --path charts/redpanda --path charts/operator --path charts/console --path charts/connectors --path cmd --path-rename cmd/genpartial/:genpartial/ --path-rename cmd/genschema/:genschema/ --path-rename cmd/gotohelm/:gotohelm/ --path pkg

# In redpanda-operator repo clone

git remote add helm-charts-clone ../helm-charts-clone
git pull helm-charts-clone main --allow-unrelated-histories --no-ff --no-rebase

As our CI checks if go lang files have BSL license header one additional commit was added to this PR.

Reference
https://htmlpreview.github.io/?https://github.com/newren/git-filter-repo/blob/docs/html/git-filter-repo.html
https://dev.to/art_ptushkin/how-to-migrate-a-directory-from-git-repository-to-another-one-preserving-git-history-bitbucket-example-15m5

K8S-443

chrisseto and others added 30 commits May 22, 2024 15:01
This commit adds support for the `lookup` function from helm. It does so by
injecting a Kubernetes API client into the `helmette.Dot` struct to avoid
relying on global variables. This is a divergence from helm itself but is
thoroughly documented as such.

Unlike helm's `lookup`, gotohelm returns `nil, false` in the case of not found
errors rather than an empty dictionary.
This commit moves all `lookup` calls into gocode and relies on gotohelm's more
clear return values to prevent nil pointer exceptions from occurring.

Fixes #1277
This commit bumps the redpanda chart version to `v5.8.6`.
Current go template does not support for statement iteration. To work around
the range loop using `until` buildin function. As the `until` counts from 0,
the `for` loop needs to have integer iterator that starts from 0.
To correctly handle negative numbers that are parsed as `ast.UnaryExpr` the
transplier will past `Literal`.
To handle Redpanda configuration in go code the `first` function needs to be
included to helmette as part of the sprig definition.

Negative numbers are recognized as `ast.UnaryExpr` with sub token. Now they can be transpiled.

P.S. The `[]byte` array can be represented only in Go, but not in template.
Prior to this commit, there were no test cases that exercised any of the
redpanda version check helpers that are littered throughout the chart. Given a
handful of difficulties with the first attempt of migrating said helpers to go,
this commit adds in a matrix of regression tests to ensure that the conversion
either preserves existing behavior or fixes any latent bugs.
In commit 666e0cb, a typo was accidentally
introduced that broke the connectors integration of the redpanda chart. This
issue went unnoticed until discovered by an end user due to a lack of any test
case that specified `connectors.enabled=true`.

This commit corrects the typo and adds a minimal regression test. A manual
check was also performed to ensure that the behavior of
`connectors.enabled=true` is the same prior to
`666e0cbf4775d7a814b48cf29bcd66815de46041`

Fixes #1321
Previously, gotohelm could panic or generate in valid templates in certain
cases when encountering assignment to embedded fields in either the shorted or
elongated form as the selector tranpilation case did not correctly handle
embedding.

This commit update `getFields` to instead returned a flattened list of all
fields, including ones inherited from embedded structs. It also updates the
`Selector` AST to elide itself if it is accessing an embedded field. As a side
effect, this has removed the need to generate nested groups of
`mustMergeOverwrite` when calculating the zero values of structs with embedded
fields.
This commit converts the servicemonitor.yaml template to a golang equivalent.

Notably, the default value for `monitoring.tlsConfig` has changed to `null` to
make the gocode more ergonomic.
Previously, gotohelm required special casing for functions that returned `(T,
error)` as helm/sprig functions have no notion of returning errors.

This commit adds automatic detection for such cases. Any function annotated
with `+gotohelm:builtin=` that returns `(T, error)` will automatically be
wrapped with `list nil` to simulate a successful return.
Prior to this commit, the semver regression test suite was accidentally
performing tests soley against v24.1.0 due taking the address of a loop
variable.

This commit appropriately "captures" the `version` variable and adds in support
for asserting on failures of `helm template.

See also https://go.dev/blog/loopvar-preview
This commit converts the collection of redpanda version gate functions from
helm to go.
Without this, it ends up on the same depth as `matchLabels:` in my testing:

        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 100
            podAffinityTerm:
              topologyKey: kubernetes.io/hostname
              labelSelector:
                matchLabels:
                app.kubernetes.io/component: redpanda-statefulset
                app.kubernetes.io/instance: redpanda
                app.kubernetes.io/name: redpanda
This commit migrates `common-volumes`, `default-volumes`,
`default-mounts`, and `common-mounts` to go.
Prior to this commit, the redpanda helm chart would almost always generate
`Certificates`, even if they we're not being used. This can be frustrating for
users that are not using cert-manager or want to manage the integration themselves.

This commit makes it easier to disable most of the certificates that the chart
generates by fixing a mistranslated boolean check, respecting the `enabled`
field on elements of `tls.certs`, and providing a few example test cases.
Based on broker configuration template https://docs.redpanda.com/23.3/reference/node-configuration-sample/
the `cluster-id` and `organization` was defined at the top level. It
should be defined under `redpanda` part of the `redpanda.yaml`.

Based on redpanda-data/redpanda#9713 `organization`
is being removed from the cluster configuration.
Floating point constants in go, when possible, are represented as division of
rational numbers. For example, 0.1 would be represented as 1/10. This syntax is
passed directly to helm which does not support such division.

This commit handles floating point constants and forcibly represents them as
decimals in all cases.

Refresh of gotohelm-float-consts
Prior to this commit, writing gotohelm code need to be very tactical when
dealing with numeric values. This lead to type casts being littered around the
codebase and likely a handful of unnoticed bugs.

This commit upgrades the transpiler to inject type casts into transpiled code
at function boundaries and struct field references.

While this solution is not perfect, it should dramatically reduce needless type
casting and make code slightly more idiomatic.
This commit adds the `AsNumeric` and `AsIntegral` helper functions to the
`helmette` package to aid working with numeric values in gotohelm code.

A future commit will disallow type assertions and type checks of numeric values
in favor of these helpers as they are the closest approximation to keeping helm
and go behavior the same.
Prior to this commit is was value to use type checks or assertions within
gotohelm code with numeric values. For example: `x.(int)`. Due to the numerous
limitations of go templates and helm, it's not feasible to fully support such
expressions as there's no type information that could be used to distinguish
between ints, int64s, and float64s.

This commit causes the transpiler to fail if it encounters such a statement and
instead points users to the recently added `AsNumeric` and `AsIntegral`
functions.
Instance methods are transpiled into templates that receives as a first
argument the instance of the struct. Any function call that have pointer
receiver would be translated to template `include` statement with one argument
which is struct itself.

There is special case for Values.AsMap method as it is not defined as
seperated template, but rather it is build in feature of the helm engine.

In future improvements instance methods transpilation could support arguments.
RafalKorepta and others added 15 commits November 21, 2024 19:34
Prior to this commit the operator chart's declared permissions had grown
out of sync with those declared by the operator itself. This commit
re-synchronizes the permissions, adds in regression tests to prevent
such drift from happening again, and releases the updated chart.

Co-authored-by: Rafal Korepta <[email protected]>
Prior to this commit gotohelm did not support first class functions. This made
certain operations tedious to implement as cases would have to be manually copied.
This commit adds support for passing functions as arguments and invoking said
functions. Closures themselves are not supported.
Prior to this commit the `podTemplate` value only permitted overriding a few
special cased fields. This commit makes the implementation generic enough to
allow:
- Adding additional containers
- Adding additional init containers
- Adding additional environment variables to _any_ container
- overriding any value on podSpec.

In particular, this commit is aimed at allowing users to specify `priority` or
`priorityClassName` on the redpanda statefulset to prevent undesired evictions.

K8S-423
@RafalKorepta RafalKorepta force-pushed the rk/add-helm-charts-git-history branch 3 times, most recently from 9c9f73a to c2e2381 Compare December 2, 2024 13:50
@RafalKorepta RafalKorepta force-pushed the rk/add-helm-charts-git-history branch from c2e2381 to b87729c Compare December 2, 2024 14:48
@redpanda-data redpanda-data deleted a comment from CLAassistant Dec 2, 2024
@david-yu
Copy link
Contributor

david-yu commented Dec 2, 2024

Just signed the CLA, btw what would be the experience moving forward for installing helm charts? Would it be hosted on the same Helm repo just the code will be place now in a single mono-repo?

Also should we rename this repo or keep as redpanda-operator?

@RafalKorepta
Copy link
Contributor Author

Also should we rename this repo or keep as redpanda-operator?

I'm open for any suggestion.

what would be the experience moving forward for installing helm charts?

It's described in our internal RFC where:

  • charts will be packages in tgz
  • uploaded to Github release in helm-chart repo (same as git tag as in redpanda-operator)
  • the helm-chart index file would be updated to reference those tgz files from github release (helm-chart repo)

Would it be hosted on the same Helm repo just the code will be place now in a single mono-repo?

It would be hosted in helm-chart repo. Just redpanda, console, connectors and operator helm chart will have the same version from the git tag created in this redpanda-operator repo.

auto-merge was automatically disabled December 3, 2024 15:52

Rebase failed

@RafalKorepta
Copy link
Contributor Author

Due to issues with Github after force push new PR was opened #338

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

Successfully merging this pull request may close these issues.