Cyber Security Community Question

How does GitOps handle Policy-as-Code for compliance and governance in 2024?

Posted on 2024-11-10 • In Cyber Security • By Elizabeth Clark

Our security team wants to enforce rules like "no root containers" and "mandatory resource limits" across all our clusters. Since we use GitOps, they want these policies to be part of the Git workflow. Should we be using Kyverno or OPA Gatekeeper for this? And more importantly, how do we make the GitOps controller aware that a manifest in Git violates a policy before it tries to sync it and fails?

3 Answers 12,812 Views

All answers to this question 3 Answers

Nancy Harris Answered on 2024-11-13
Answered

For a GitOps-native experience, Kyverno is usually the winner because its policies are written in standard Kubernetes YAML, whereas OPA requires learning the Rego language. To catch violations "pre-sync," you should integrate a policy-checking tool into your CI pipeline (the "Shift-Left" approach). Tools like Linter or Kyverno CLI can scan your Git repository every time a PR is opened. If a developer tries to commit a manifest that runs as root, the CI build fails and the PR can't be merged. This way, your GitOps controller only ever sees "clean" and compliant code, preventing sync loops.

James Miller Answered on 2024-11-15
Answered

Are you more concerned about preventing the deployment of bad configs, or do you also need to audit the current state of the clusters for compliance?

Joseph Rodriguez Commented on 2024-11-17
Commented

We need both. We need the "Prevention" at the PR stage, but we also need a report for our auditors showing that no non-compliant pods are currently running. Does Kyverno provide a dashboard or a way to export these "Policy Reports" into a format that a non-technical compliance officer can understand?

Karen Walker Answered on 2024-11-19
Answered

We use OPA Gatekeeper because of its "Admission Controller" capabilities. It physically blocks any API request that violates our rules, even if it comes from the GitOps agent.

Elizabeth Clark Commented on 2024-11-20
Commented

Gatekeeper is powerful, but be careful. If Gatekeeper blocks the GitOps agent, you end up with a permanent "Out of Sync" status in your dashboard.

Write a Comment

Your email address will not be published. Required fields are marked (*)

Join the LearnersEra Community

Ask questions, share knowledge and learn from professionals across technology, project management and certification topics.

Change Country and Nearest City

Select your country and nearest city to see courses available in your region.