<p>While setting up a automated deployments with Kubernetes (and Helm), I came across the following question several times:</p>

<blockquote>
  <p>How important is the safeness of a services password (mysql, for example) inside a single namespace?</p>
</blockquote>

<p><strong>My thoughts:</strong> It's not important at all. Why? All related pods include the password anyway and the services are not available outside of the specific namespace. Though someone would gain access to a pod in that specific namespace, <code>printenv</code> would give him all he needs.</p>

<p><em>My specific case (Helm):</em> If I set up my mysql server as a requirement (requirements.yaml), I don't have to use any secrets or make effort to share the mysql password and can provide the password in values.yaml.</p>

mrvnklm
<p>While Kubernetes secrets aren't <em>that</em> secret, they are more secret than Helm values.  Fundamentally I'd suggest this question is more about how much you trust humans with the database password than any particular process.  Three approaches come to mind:</p>

<ol>
<li><p><strong>You pass the database password via Helm values.</strong>  Helm isn't especially access-controlled, so anyone who can <code>helm install</code> or <code>helm rollback</code> can also <code>helm get values</code> and find out the password.  If you don't care whether these humans have the password (all deployments are run via an automated system; all deployments are run by the devops team who has all the passwords anyways; you're a 10-person startup) then this works.</p></li>
<li><p><strong>The database password is in an RBAC-protected Secret.</strong>  You can use Kubernetes <a href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/" rel="nofollow noreferrer">role-based access control</a> so that ordinary users can't directly read the contents of Secrets.  Some administrator creates the Secret, and the Pod mounts it or injects it as an environment variable.  Now you don't need the password yourself to be able to deploy, and you can't trivially extract it (but it's not that much work to dump it out, if you can launch an arbitrary container).</p></li>
<li><p><strong>The application gets the database password from some external source at startup time.</strong>  Hashicorp's <a href="https://vaultproject.io" rel="nofollow noreferrer">Vault</a> is the solution I've worked with here: the Pod runs with a Kubernetes service account, which it uses to get a token from Vault, and then it uses that to get the database password.  The <a href="https://www.vaultproject.io/docs/secrets/databases/index.html" rel="nofollow noreferrer">advanced version of this</a> hands out single-use credentials that can be traced back to a specific Pod and service account.  This is the most complex path, but also the most secure.</p></li>
</ol>
