<p>I've been studying &quot;Kubernetes Up and Running&quot; by Hightower et al (first edition) Chapter 13 where they discussed creating a Reliable MySQL Singleton (Since I just discovered that there is a second edition, I guess I'll be buying it soon).</p>
<p>Using their MySQL reliable singleton example as a model, I've been looking for some sample YAML files to make a similar deployment with Microsoft SQL Server (Express) on Docker Desktop for Kubernetes.</p>
<p>Apparently I need YAML files to deploy</p>
<ol>
<li>Persistent Volume</li>
<li>Volume claim (should this be NFS?)</li>
<li>SQL Server (Express edition) replica set (in spite of the fact that this is just a singleton).</li>
</ol>
<p><a href="https://social.msdn.microsoft.com/Forums/vstudio/en-US/5d942d3f-8ecc-4aee-9bb2-cafc2a2be023/wanted-tutorial-for-running-aspnet-with-database-in-kubernetes-on-docker-desktop?forum=visualstudiogeneral" rel="nofollow noreferrer">I've tried this example</a> but I'm confused because it does not contain a persistent volume &amp; claim and it does not work. I get the error</p>
<blockquote>
<p>Error: unable to recognize &quot;sqlserver.yml&quot;: no matches for kind &quot;Deployment&quot; in version &quot;apps/v1beta1&quot;</p>
</blockquote>
<p>Can someone please point me to some sample YAML files that are not Azure specific that will work on Docker Desktop Kubernetes for Windows 10? After debugging my application, I'll want to deploy this to Azure (AKS).</p>
<p><strong>Wed Jul 15 2020 Update</strong></p>
<p>I left out the &quot;-n namespace&quot; for the helm install command (possibly because I'm using Helm and you are using helm v2?).</p>
<p>That install command still did not work. Then I did a</p>
<pre><code>helm repo add stable https://kubernetes-charts.storage.googleapis.com/
</code></pre>
<p>Now this command works:</p>
<pre><code>helm install todo-app-database stable/mssql-linux
</code></pre>
<p>Progress!</p>
<p>When I do a &quot;k get pods&quot; I see that my todo-app-mssql-linux database is in the pending state. So I did a</p>
<pre><code>kubectl get events
</code></pre>
<p>and I see</p>
<pre><code>Warning   FailedScheduling   pod/todo-app-database-mssql-linux-8668d9b88c-lsh5l   0/1 nodes are available: 1 Insufficient memory.
</code></pre>
<p>I've been google searching for &quot;Kubernetes insufficient memory&quot; and can find no match.</p>
<p>I suspect this is a problem specific to &quot;Docker Desktop Kubernetes&quot;.</p>
<p>When I look at the output for</p>
<pre><code>helm -n ns-todolistdemo template todo-app-database stable/mssql-linux
</code></pre>
<p>I see the deployment is asking for 2Gi. (Interesting: when I use the template command, the &quot;-n ns-todolistdemo&quot; does not cause an error like it does with the install command).</p>
<p>So I do</p>
<pre><code>kubectl describe deployment todo-app-database-mssql-linux &gt;todo-app-database-mssql-linux.yaml
</code></pre>
<p>I edit the yaml file to change 2Gi to 1Gi.</p>
<pre><code>kubectl apply -f todo-app-database-mssql-linux.yaml
</code></pre>
<p>I get this error:</p>
<pre><code>error: error parsing todo-app-database-mssql-linux.yaml: error converting YAML to JSON: yaml: line 9: mapping values are not allowed in this context
</code></pre>
<p>Hmm... that did not work. I try delete:</p>
<pre><code>kubectl delete deployment todo-app-database-mssql-linux
kubectl create -f todo-app-database-mssql-linux.yaml
</code></pre>
<p>I get this error:</p>
<pre><code>error: error validating &quot;todo-app-database-mssql-linux.yaml&quot;: error validating data: invalid object to validate; if you choose to ignore these errors, turn validation off with --validate=false
</code></pre>
<p>So I try apply:</p>
<pre><code>kubectl apply -f todo-app-database-mssql-linux.yaml
</code></pre>
<p>Same error!</p>
<p>Shucks.... Is there a way to adjust the memory allocation for Docker Desktop?</p>
<p>Thank you</p>
<p>Siegfried</p>

Siegfried
<h1>Short answer</h1>
<p><a href="https://github.com/helm/charts/blob/master/stable/mssql-linux/templates/pvc-master.yaml" rel="nofollow noreferrer">https://github.com/helm/charts/blob/master/stable/mssql-linux/templates/pvc-master.yaml</a></p>
<h1>Detailed Answer</h1>
<p>Docker For Desktop comes already with a default StorageClass :
<a href="https://i.stack.imgur.com/9mO55.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9mO55.png" alt="#" /></a></p>
<p>This storage class is responsible for auto-provisioning of PV whenever you create a PVC.</p>
<p>If you have a YAML definition of PVC (persistent volume claim), you just need to keep storageClass empty, so it will use the default.</p>
<pre><code>k get storageclass
NAME                 PROVISIONER                                       AGE
hostpath (default)   docker.io/hostpath                                11d
</code></pre>
<p>This is fair enough as Docker-For-Desktop Cluster is a one node cluster. So if your DB crashes and the cluster opens it again , it will not move to another node, because simply, you have a single node :)</p>
<p>Now should write the YAML of PVC from scratch ?</p>
<p>No , you don't need. Because Helm should be your best friend.</p>
<p>( I explained below Why you have to use Helm even without deep learning curve)</p>
<p>Fortunately, the community provides a chart called <a href="https://github.com/helm/charts/tree/master/stable/mssql-linux" rel="nofollow noreferrer">stable/mssql-linux</a>..
Let's run it together  :</p>
<pre class="lang-sh prettyprint-override"><code>helm -n &lt;your-namespace&gt; install todo-app-database stable/mssql-linux
# helm -n &lt;namespace&gt; install &lt;release-name&gt; &lt;chart-name-from-community&gt;

</code></pre>
<p>If you want to check the YAML (namely PVC) that Helm computed, you can run <code>template</code> instead of <code>install</code></p>
<pre class="lang-sh prettyprint-override"><code>helm -n &lt;your-namespace&gt; template todo-app-database stable/mssql-linux
</code></pre>
<h1>Why I give you the answer with Helm ?</h1>
<p>Writing YAML from scratch lets reinventing the wheel while others do it.</p>
<p>The most efficient way is to reuse what community prepare for you.</p>
<p>However, you may ask: How can i reuse what others doing ?</p>
<p>That's why <strong>Helm</strong> comes.</p>
<p>Helm comes to be your installer of any application on top of kubernetes <strong>regardless how much YAML does your app require.</strong></p>
<p>Install it now and hit the ground <code>choco install kubernetes-helm</code></p>
