Interview Prep/CI/CD/Jenkins Shared Libraries, Credentials and Security

You want one pipeline step, "deployToK8s", usable by all teams but restricted so it can only deploy to namespaces the team owns.

AdvancedScenarioJenkins Shared Libraries, Credentials and Security
Answer

Situation read → Safe self-service with guardrails.

What I'd do →

  1. Implement the step in the shared library; derive the allowed namespace from the folder or team name, not from caller input.
  2. Use per-team Kubernetes credentials (ServiceAccount token or OIDC) bound to a namespaced Role.
  3. Validate manifests with kubeconform and policy with OPA/Kyverno before apply.
  4. Enforce authorization on the cluster side as well, never only in Groovy.

Why → Library checks can be bypassed; RBAC at the target is the real boundary.

Interview tip → "Defence in depth: library guard plus cluster RBAC."

All CI/CD questions

More on Jenkins Shared Libraries, Credentials and Security