Maven / GitOps Interview Questions
What is declarative infrastructure and why does GitOps require it?
Declarative infrastructure means specifying the desired end state of a system rather than the sequence of commands needed to reach it. A Kubernetes Deployment manifest is declarative — it says "I want 3 replicas of this container image running with these environment variables." The Kubernetes control plane figures out the steps (schedule pods, pull images, attach volumes) to achieve that state. By contrast, a shell script that runs kubectl scale, kubectl set image, and kubectl rollout in sequence is imperative — the outcome depends on the starting state.
GitOps requires declarative infrastructure for a specific technical reason: the reconciliation loop works by comparing two representations of system state — the declared state in Git and the live state reported by the Kubernetes API. Both sides of the comparison must be in the same format for the diff to be meaningful.
- Imperative commands like
kubectl rundescribe a one-time action, not a persistent state. You cannot store "kubectl scale to 5" in Git and compare it to the current replica count; you can storespec.replicas: 5and compare it. - Idempotency follows naturally from declarative configs — applying the same manifest twice produces the same result, which means the operator can safely reconcile as often as it likes.
- Drift detection only works if the desired state can be parsed, normalised, and diffed against the live API server response. Declarative YAML makes this straightforward.
Common declarative formats used with GitOps: Kubernetes YAML manifests, Helm values.yaml files (rendered to manifests by the operator), Kustomize overlay patches, and Crossplane Composite Resource Claims.
Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!
Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.
Invest now!!! Get Free equity stock (US, UK only)!
Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.
The Robinhood app makes it easy to trade stocks, crypto and more.
Webull! Receive free stock by signing up using the link: Webull signup.
More Related questions...
