How do you secure secrets in a GitOps repository?

Tests whether you treat Git as source of truth while excluding plaintext credentials. A strong answer covers encrypting at rest with SOPS or Sealed Secrets, external stores like Vault, and operator workflows.
What's really being asked
This question evaluates whether you understand the core GitOps principle that Git serves as the source of truth for declarative infrastructure and application configuration, while recognizing that storing confidential data in Git represents a security vulnerability even when repositories are private and implement access controls. The interviewer wants to see that you can distinguish between configuration state and sensitive credentials, and that you know practical patterns for keeping secrets out of plaintext version control without breaking automated GitOps reconciliation.
The full answer
A good answer hits three things in order. First, encrypting secrets at rest inside the repository using tools like Mozilla SOPS or Bitnami Sealed Secrets, which allows manifests to be stored in Git while ensuring that only the target cluster or specific keys can decrypt the actual values. Second, referencing external secret management systems such as HashiCorp Vault, AWS Secrets Manager, Azure Key Vault, or Google Cloud KMS from the declarative manifests, then relying on an operator like External Secrets Operator or the GitOps controller itself to inject those values into the cluster at runtime without ever writing plaintext to Git. Third, leveraging native capabilities of the GitOps operator to generate or reconcile secrets outside of version control, for example by using templating, post-rendering hooks, or operator-managed secret generation. You should also mention that rotation, auditing, and least-privilege access policies must accompany whichever technical approach you choose.
The mistakes people make
The most common wrong answer is claiming that a private repository with role-based access control is sufficient protection for plaintext secrets. Another red flag is suggesting manual secret application steps outside of the GitOps pipeline, which breaks the declarative source-of-truth model. Candidates also stumble by confusing config maps with secrets, or by proposing base64 encoding alone, which is not encryption and is trivially reversible.
What usually comes next
An interviewer might push on key rotation strategy and how you automate it without editing Git state. They may ask how you handle secret drift if someone modifies a secret directly in the cluster, or how you audit access when secrets are injected from an external vault. You might also be asked to compare the tradeoffs between encrypted Git storage and external secret stores in terms of blast radius, availability, and disaster recovery.
A concrete example
Suppose you are running Argo CD or Flux on Amazon EKS. You could store a SealedSecret custom resource in Git that encrypts a database password for a specific namespace. Argo CD reconciles the SealedSecret object, the cluster-side controller decrypts it into a standard Kubernetes Secret, and your application consumes it. Alternatively, you could commit a SecretStore manifest pointing to AWS Secrets Manager; the External Secrets Operator fetches the password at runtime and creates the Kubernetes Secret automatically. In both cases, the Git repository never contains the plaintext password, satisfying the requirement that confidential data should not be allowed in Git even when access controls exist.
Interview question
Which strategy best protects sensitive credentials while maintaining Git as the declarative source of truth in a GitOps workflow?
- a.Encrypt the credentials at rest using Sealed Secrets or SOPS so only the target cluster can decrypt themCorrect
- b.Store the credentials as plain text in a private repository with strict role-based access controls
- c.Apply the credentials manually with kubectl outside the GitOps pipeline and reference them in Git manifests
- d.Encode the credentials with Base64 in standard Kubernetes Secret manifests before committing them
Why? this is the answer
Encrypting secrets at rest with Sealed Secrets or SOPS keeps sensitive values out of plaintext while preserving Git as the automated source of truth. The most tempting distractor is storing plaintext in a private repository, but access controls alone do not prevent exposure to anyone with read access and offer no protection against accidental leaks.
Just read this? Test yourself on what you have been reading.
Read the original → redhat.com
- #gitops
- #secrets-management
- #kubernetes
- #cicd
- #security
You just looked this up. Could you explain it out loud?
That is the part interviews actually test. Tezvyn takes questions like this one and gives you what the interviewer is really checking, the answer that lands, and the mistake that ends the conversation, in the four minutes before your next meeting.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on gitops — each one lists the topics its interview covers.
See open roles