Skip to content

Identity Plugin - #288

Open
atpugtihsrah wants to merge 1 commit into
containerd:mainfrom
atpugtihsrah:identity-plugin-5qjelc65nb
Open

Identity Plugin#288
atpugtihsrah wants to merge 1 commit into
containerd:mainfrom
atpugtihsrah:identity-plugin-5qjelc65nb

Conversation

@atpugtihsrah

@atpugtihsrah atpugtihsrah commented Apr 24, 2026

Copy link
Copy Markdown

Identity Plugin WIP

RFC PR: #245

Relates to #240

PR Assisted by IBM Bob.

@MikeZappa87

Copy link
Copy Markdown
Member

@atpugtihsrah this is interesting. I did some work in the istio/isovalent ecosystem for SPIRE. Lmk if you need any help

@atpugtihsrah
atpugtihsrah force-pushed the identity-plugin-5qjelc65nb branch from 11f5595 to ff81182 Compare May 21, 2026 14:48
@atpugtihsrah
atpugtihsrah force-pushed the identity-plugin-5qjelc65nb branch 2 times, most recently from 0748a95 to e355b5e Compare July 12, 2026 06:44
Comment thread plugins/identity-injector/identity-injector_test.go Outdated
@mikebrow

Copy link
Copy Markdown
Member
Ginkgo detected a version mismatch between the Ginkgo CLI and the version of Ginkgo imported by your packages:
  Ginkgo CLI Version:
    2.28.1
  Mismatched package versions found:
    2.19.1 used by identity-injector

  Ginkgo will continue to attempt to run but you may see errors (including flag
  parsing errors) and should either update your go.mod or your version of the
  Ginkgo CLI to match.

  To install the matching version of the CLI run
    go install github.com/onsi/ginkgo/v2/ginkgo
  from a path that contains a go.mod file.  Alternatively you can use
    go run github.com/onsi/ginkgo/v2/ginkgo
  from a path that contains a go.mod file to invoke the matching version of the
  Ginkgo CLI.

  If you are attempting to test multiple packages that each have a different
  version of the Ginkgo library with a single Ginkgo CLI that is currently
  unsupported.

Comment thread plugins/identity-injector/go.mod
@atpugtihsrah
atpugtihsrah force-pushed the identity-plugin-5qjelc65nb branch 10 times, most recently from 7b49520 to ec86027 Compare July 16, 2026 09:26
@atpugtihsrah
atpugtihsrah marked this pull request as ready for review July 16, 2026 09:29
@mikebrow

mikebrow commented Jul 20, 2026

Copy link
Copy Markdown
Member

good meeting this morning @atpugtihsrah! Note to other reviewers contributor is going to clean up the vendor issues and boost the plugin getting started guide.

Comment thread plugins/identity-injector/setup.md Outdated
Comment thread plugins/identity-injector/setup.md Outdated
@atpugtihsrah
atpugtihsrah force-pushed the identity-plugin-5qjelc65nb branch 2 times, most recently from cadcd8d to c3a1707 Compare July 31, 2026 08:31
@mikebrow

Copy link
Copy Markdown
Member

heads up needs rebase :-) we've been busy getting ready for a release

@atpugtihsrah
atpugtihsrah force-pushed the identity-plugin-5qjelc65nb branch 2 times, most recently from b46ddf1 to 3358c45 Compare August 25, 2026 15:13
@mikebrow

mikebrow commented Sep 1, 2026

Copy link
Copy Markdown
Member

Ran the test instructions to success using kind...

We can add this later:
mikebrow@76915f1

@mikebrow mikebrow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM very nice...

would like to get this in and iterate

@mikebrow
mikebrow requested a balanced review from Copilot September 1, 2026 21:22
Comment thread plugins/identity-injector/identity-injector.go

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Pull request overview

Adds a WIP “Identity Plugin” (identity-injector) to fetch X.509 SVIDs via SPIRE’s Delegated Identity API and inject them into workload containers, along with kustomize manifests and a local-cluster setup guide.

Changes:

  • Introduces the identity-injector plugin implementation (gRPC streaming watchers, file writes, annotation parsing) and a unit test for annotation parsing.
  • Adds kustomize base/overlay resources to deploy the plugin as a DaemonSet.
  • Adds a detailed setup guide for SPIRE/SPIFFE + local build/test flow, and wires the plugin tests into the main Makefile.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
plugins/identity-injector/identity-injector.go Implements the identity-injector plugin, certificate/bundle streaming watchers, and annotation parsing.
plugins/identity-injector/identity-injector_test.go Adds unit tests for parsing identity annotations.
plugins/identity-injector/go.mod Defines the plugin module and dependencies (SPIFFE/SPIRE SDK, gRPC, yaml, etc.).
plugins/identity-injector/go.sum Locks dependency checksums for the plugin module.
contrib/kustomize/identity-injector/kustomization.yaml Adds a kustomize entry point for the identity-injector deployment.
contrib/kustomize/identity-injector/base/kustomization.yaml Defines base resources, image override, and common labels for deployment.
contrib/kustomize/identity-injector/base/daemonset.yaml Adds the DaemonSet manifest to run the plugin and mount required host paths/sockets.
plugins/identity-injector/setup.md Documents end-to-end local setup for SPIRE + plugin + test workload.
Makefile Adds a test target for the new identity-injector plugin.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread contrib/kustomize/identity-injector/base/daemonset.yaml
Comment thread contrib/kustomize/identity-injector/base/daemonset.yaml
Comment thread contrib/kustomize/identity-injector/base/daemonset.yaml
Comment thread plugins/identity-injector/identity-injector.go
Comment thread plugins/identity-injector/identity-injector.go Outdated

}

// TODO create test cases for processDelegatedIdentityUpdate()
Comment on lines +30 to +32
sudo mkdir /tmp/spire-data

sudo chmod 777 /tmp/spire-data
Comment on lines +354 to +356
sudo mkdir /var/run/spiffe/
sudo mkdir /var/run/spiffe/secrets/
sudo chmod 777 /var/run/spiffe/secrets/
Comment thread plugins/identity-injector/identity-injector.go Outdated
Comment thread plugins/identity-injector/setup.md Outdated
@atpugtihsrah
atpugtihsrah force-pushed the identity-plugin-5qjelc65nb branch 2 times, most recently from ca3b6ac to 189f5a6 Compare September 3, 2026 12:05

@mikebrow mikebrow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

maybe a little more work around the map initialization part to ensure it's never used when not properly initialized

Comment thread plugins/identity-injector/identity-injector.go Outdated
Comment thread plugins/identity-injector/identity-injector.go
Comment thread plugins/identity-injector/identity-injector.go
@atpugtihsrah
atpugtihsrah force-pushed the identity-plugin-5qjelc65nb branch 4 times, most recently from acc660c to d488f96 Compare September 4, 2026 07:24
Signed-off-by: Harshit Gupta <hg2t4e@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Request-lifetime cancellation, unsafe filename handling, startup races, and missing recovery paths currently prevent reliable and secure identity delivery.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details

Suppressed comments (1)

plugins/identity-injector/identity-injector.go:372

  • The bundle stream has the same permanent-failure path: any transient Recv error returns, cancels the shared context, and stops SVID rotation too. Re-establish this subscription with bounded backoff while the container watcher remains active.
			resp, err := stream.Recv()
			if err != nil {
				log.Errorf("%s: bundle stream error: %v", containerName(pod, ctr), err)
				return
  • Files reviewed: 8/9 changed files
  • Comments generated: 9
  • Review effort level: Balanced

Comment on lines +20 to +21
- "--verbose"
- "true"
Comment on lines +231 to +235
if err := p.startCertificateWatcher(ctx, pod, container, int32(container.Pid), hostDir, config); err != nil {
return fmt.Errorf("failed to start certificate watcher: %w", err)
}

return nil
p.watchersMu.RUnlock()

// Create cancellable context for this watcher
watcherCtx, cancel := context.WithCancel(ctx)
Comment on lines +569 to +579
if config.CertFileName == "" {
config.CertFileName = defaultCertFileName
}
if config.KeyFileName == "" {
config.KeyFileName = defaultKeyFileName
}
if config.BundleFileName == "" {
config.BundleFileName = defaultBundleFileName
}

return &config, nil
Comment thread Makefile
#

test-gopkgs: go-generate test-main test-ulimits test-rdt test-hook-injector test-writable-cgroups
test-gopkgs: go-generate test-main test-ulimits test-rdt test-hook-injector test-writable-cgroups test-identity-injector
Comment on lines +318 to +321
resp, err := stream.Recv()
if err != nil {
log.Errorf("%s: bundle stream error: %v", containerName(pod, ctr), err)
return
Comment on lines +399 to +401
// TODO implement using hint to select relevant svid in case response has multiple svids
// Get the default SVID
svidWithKey := x509Svids[0]
Comment on lines +674 to +675
p := &plugin{
watchers: make(map[string]*containerWatcher),

## Step 2.2: Deploy the NRI Identity Plugin

**Why:** The kustomize overlay in `contrib/kustomize/identity-injector/` contains all of the Kubernetes resources needed to run the NRI Identity Plugin as a DaemonSet in the `kube-system` namespace: the DaemonSet definition (which mounts the SPIRE admin socket and the SVID secrets directory), the NRI registration ConfigMap (so that the Containerd NRI runtime knows to invoke the plugin), and the necessary RBAC resources. Applying it as a single `kubectl apply -k` command ensures all resources are created in the correct order and with the correct labels.
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.

4 participants