8000 feature: support zarf image modification in reconciliation by nfoucha · Pull Request #500 · konpyutaika/nifikop · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

feature: support zarf image modification in reconciliation #500

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 3 commits into from
Apr 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

### Added

- [PR #500](https://github.com/konpyutaika/nifikop/pull/500) - **[Operator/NiFiCluster]** Added support for [Zarf](https://zarf.dev/) patched container images

### Changed

- [PR #538](https://github.com/konpyutaika/nifikop/pull/538) - **[Operator]** Upgrade golang to 1.24.2.
Expand Down
28 changes: 28 additions & 0 deletions pkg/resources/nifi/nifi.go
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,34 @@ func (r *Reconciler) reconcileNifiPod(log zap.Logger, desiredPod *corev1.Pod) (e
}
currentPod.Spec.Containers = currentContainers
}
// Patch image name if Zarf has modified the pod spec
if _, ok := currentPod.Labels["zarf-agent"]; ok {
var oldImage, currentImage string
for _, c := range currentPod.Spec.Containers {
if c.Name == "nifi" {
imageChunks := strings.Split(c.Image, "/")
oldTag := strings.Split(imageChunks[len(imageChunks)-1], "-zarf")[0]
oldRepoChunks := imageChunks[1 : len(imageChunks)-1]
oldImage = fmt.Sprintf("%s/%s", strings.Join(oldRepoChunks, "/"), oldTag)
currentImage = c.Image
}
}
log.Debug("Patching Nifi container image for Zarf",
zap.String("current", currentImage),
zap.String("original", oldImage))
desiredContainers := []corev1.Container{}
for _, c := range desiredPod.Spec.Containers {
if c.Name == "nifi" {
// If the incoming image matches the spec from before the zarf patch then the pod is in sync
if c.Image == oldImage {
// We want to prevent a reconcile loop by setting the incoming image to the zarf image spec
c.Image = currentImage
}
}
desiredContainers = append(desiredContainers, c)
}
desiredPod.Spec.Containers = desiredContainers
}
// Check if the resource actually updated
patchResult, err := patch.DefaultPatchMaker.Calculate(currentPod, desiredPod, opts...)
if err != nil {
Expand Down
0