Repository navigation
feat(hooks): add kustomize, kube:apply, and tekton:pipelinerun commands - #26
Merged
Merged
Conversation
Hooks need to render the Kustomize bundle a repository keeps its Tekton Pipeline in. The module is tracked with Git LFS. Unlike the generic Kefka adapter, this one sets the guest PWD so relative paths resolve against the shell directory, and it closes a running instance when the hook context ends. Assisted-by: Claude Opus 5.5 via Claude Code Signed-off-by: Xe Iaso <xe@tigrisdata.com>
Hook commands need Server-Side Apply and create against the pod's ServiceAccount. client-go would bring k8s.io/api and a large dependency tree for three calls, so this client does per-apiVersion discovery, apply with field manager objgitd and no forced conflicts, and create. It rereads the ServiceAccount token for each request, because bound tokens rotate. kubetest is a fake API server for the tests. Assisted-by: Claude Opus 5.5 via Claude Code Signed-off-by: Xe Iaso <xe@tigrisdata.com>
kube:apply reads a YAML stream, checks every object, then applies each one with Server-Side Apply. tekton:pipelinerun creates a new run from a generateName template, with the pushed commit and branch in its params and repo, ref, and commit metadata for a later lookup. Without a client the commands are stubs that say how to turn them on. Assisted-by: Claude Opus 5.5 via Claude Code Signed-off-by: Xe Iaso <xe@tigrisdata.com>
Push hooks and the SSH sh command now have kustomize, kube:apply, and tekton:pipelinerun. The new -allow-kubernetes flag, off by default, gives the two Kubernetes commands the pod's in-cluster ServiceAccount. It needs -allow-hooks, and objgitd exits at startup when the in-cluster config cannot load. Assisted-by: Claude Opus 5.5 via Claude Code Signed-off-by: Xe Iaso <xe@tigrisdata.com>
kustomize.wasm is an LFS object. A checkout without LFS embeds the pointer file, so CI checks out with lfs: true and the Docker build stops when the file is not WebAssembly. Assisted-by: Claude Opus 5.5 via Claude Code Signed-off-by: Xe Iaso <xe@tigrisdata.com>
The Role lets ServiceAccount objgit/objgitd create and patch Pipelines and Tasks, and create PipelineRuns, in namespace ci. It lives outside manifest/ because that kustomization's namespace field would move the RoleBinding. TestCluster checks the client against a real API server when a cluster is configured. A kind run showed that Server-Side Apply needs patch even for a new object, so the fake API server now checks that too. Assisted-by: Claude Opus 5.5 via Claude Code Signed-off-by: Xe Iaso <xe@tigrisdata.com>
Add a usage page with the hook recipe, the flag, the RBAC, the command reference, and the security warning. Link it from the hook, Kubernetes, and architecture pages, and add ALLOW_KUBERNETES=false to the example deployment. Assisted-by: Claude Opus 5.5 via Claude Code Signed-off-by: Xe Iaso <xe@tigrisdata.com>
A script can change the OBJGIT_* variables, so a push to one repository could make its cluster changes look like another's in the audit log and in the PipelineRun annotations. The commands now take a kube.Origin from the daemon. The branch parameter is only set for a branch, so the SSH sh shell on a tag or commit keeps the template value. Also refuse an apiVersion that is not a plain group and version, since an escaped slash or a query string there reaches a different API path, and reject a document separator with content after it instead of dropping the documents that follow. Assisted-by: Claude Opus 5.5 via Claude Code Signed-off-by: Xe Iaso <xe@tigrisdata.com>
The embedded kustomize.wasm added 24 MB to the objgitd binary, and each new program would add more. Hook commands now come from .wasm files in the directories of -wasm-path (default /app/wasm/bin and /usr/libexec/objgit/bin), so an administrator can add a program to an image or a volume without a new daemon build. The directories are listed once at startup, and the first directory with a name wins, as in PATH. Each program is read and compiled on its first run. -wasm-cache-dir keeps the compiled code on disk, which drops the first kustomize run after a restart from about 4 s to 0.15 s. The manifest puts this cache on the existing PVC. kustomize.wasm moves to bin/ (still Git LFS), and the image copies bin/ to /usr/libexec/objgit/bin. The stripped binary shrinks from 79.5 MB to 55.0 MB. Assisted-by: Claude Opus 5.5 via Claude Code Signed-off-by: Xe Iaso <xe@tigrisdata.com>
…commands Signed-off-by: Xe Iaso <xe@tigrisdata.com> # Conflicts: # AGENTS.md
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
shshell getkustomize(an embedded WASI build, tracked with Git LFS), pluskube:apply(Server-Side Apply) andtekton:pipelinerun(a new run for each pushed commit, from agenerateNametemplate).-allow-kubernetesflag is off by default. It gives the two Kubernetes commands the pod's in-cluster ServiceAccount, andmanifest/tekton-rbac/is an example Role that allows only Tekton kinds in namespaceci.Details
The API client in
internal/kubeis small and hand-written instead of client-go, and the run's provenance (repo, ref, commit) comes from the daemon, not fromOBJGIT_*variables that a script can change. CI and the Dockerfile now pull LFS objects and stop the build if the embedded module is a pointer file. Seedocs/usage/kubernetes-hooks.mdfor the hook recipe, the RBAC, and the security warning.Test plan
go build ./...npm run format(goimports andprettier --checkon the changed files)kubectl auth can-ichecks,TestCluster, and two pushes through objgitd created the correct PipelineRuns