<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>kubernetes &amp;mdash; LinuxPizza</title>
    <link>https://blogs.linux.pizza/tag:kubernetes</link>
    <description>Personal notes and occasional posts - 100% human, 0% AI generated</description>
    <pubDate>Wed, 29 Apr 2026 12:02:56 +0000</pubDate>
    <item>
      <title>Random stuff cheat-sheet</title>
      <link>https://blogs.linux.pizza/random-stuff-cheat-sheet</link>
      <description>&lt;![CDATA[LVM stuff&#xA;&#xA;WARNING: PV /dev/sda2 in VG vg0 is using an old PV header, modify the VG to update.&#xA;Update the metadata with the vgck command - where the &#34;vg0&#34; is your own pool.&#xA;vgck --updatemetadata vg0&#xA;curl stuff&#xA;Curl a specific IP with a another host-header&#xA;curl -H &#34;Host: subdomain.example.com&#34; http://172.243.6.400/&#xA;git stuff&#xA;tell git.exe to use the built-in CA-store in Windows&#xA;git config --global http.sslBackend schannel&#xA;random stuff&#xA;See which process is using a file&#xA;fuser file&#xA;Import RootCert into Java-keystore example&#xA;sudo /usr/lib/java/jdk8u292-b10-jre/bin/keytool -import -alias some-rootcert -keystore /usr/lib/java/jdk8u292-b10-jre/lib/security/cacerts -file /usr/share/ca-certificates/extra/someRoot.crt`&#xA;&#xA;Apache2 configs example&#xA;Enable AD-authentication for web-resources&#xA;Location /&#xA;   AuthName &#34;AD authentication&#34;&#xA;   AuthBasicProvider ldap&#xA;   AuthType Basic&#xA;   AuthLDAPGroupAttribute member&#xA;   AuthLDAPGroupAttributeIsDN On&#xA;   AuthLDAPURL ldap://IP:389/OU=Users,OU=pizza,DC=linux,DC=pizza? &#xA;   sAMAccountName?sub?(objectClass=)&#xA;   AuthLDAPBindDN cn=tomcat7,ou=ServiceAccounts,ou=Users,OU=pizza,dc=linux,dc=pizza&#xA;  AuthLDAPBindPassword &#34;exec:/bin/cat /etc/apache2/ldap-password.conf&#34;&#xA;  Require ldap-group &#xA;  CN=somegroup,OU=Groups,OU=pizza,DC=linux,DC=pizza&#xA;  ProxyPass &#34;http://localhost:5601/&#34;&#xA;  ProxyPassReverse &#34;http://localhost:5601/&#34;&#xA;&#xA;/Location&#xA;&#xA;Insert Matomo tracking script in Apache using modsubstitute&#xA;AddOutputFilterByType SUBSTITUTE text/html&#xA;Substitute &#34;s-/head-script type=\&#34;text/javascript\&#34;var paq = paq || [];paq.push([&#39;trackPageView&#39;]);paq.push([&#39;enableLinkTracking&#39;]);(function() {var u=\&#34;https://matomo.example.com/\&#34;;paq.push([&#39;setTrackerUrl&#39;, u+&#39;matomo.php&#39;]);paq.push([&#39;setSiteId&#39;, &#39;1&#39;]);var d=document, g=d.createElement(&#39;script&#39;), s=d.getElementsByTagName(&#39;script&#39;)[0];g.type=&#39;text/javascript&#39;; g.async=true; g.defer=true; g.src=u+&#39;matomo.js&#39;; s.parentNode.insertBefore(g,s);})();/script/head-n&#34;&#xA;Load balance backend-servers&#xA;Proxy balancer://k3singress&#xA;&#x9;BalancerMember http://x.x.x.1:80&#xA;&#x9;BalancerMember http://x.x.x.2:80&#xA;&#x9;BalancerMember http://x.x.x.3:80&#xA;&#x9;BalancerMember http://x.x.x.4:80&#xA;&#x9;ProxySet lbmethod=bytraffic&#xA;&#x9;ProxySet connectiontimeout=5 timeout=30&#xA;&#x9;SetEnv force-proxy-request-1.0 1&#xA;&#x9;SetEnv proxy-nokeepalive 1&#xA;/Proxy&#xA;       ProxyPass &#34;/&#34; &#34;balancer://k3singress/&#34;&#xA;       ProxyPassReverse &#34;/&#34; &#34;balancer://k3singress/&#34;&#xA;       ProxyVia Full&#xA;       ProxyRequests On&#xA;       ProxyPreserveHost On&#xA;Basic Apache-config for PHP-FPM&#xA;VirtualHost :80&#xA;  ServerName www.example.com&#xA;  DocumentRoot /srv/www.example.com/htdocs&#xA;  Directory /srv/www.example.com/htdocs&#xA;    AllowOverride All&#xA;    Require all granted&#xA;    DirectoryIndex index.html index.htm index.php&#xA;    FilesMatch &#34;\.php$&#34;&#xA;      SetHandler proxy:unix:/run/php/www.example.com.sock|fcgi://localhost&#xA;    /FilesMatch&#xA;  /Directory&#xA;  SetEnvIf x-forwarded-proto https HTTPS=on&#xA;/VirtualHost&#xA;Basic PHP-fpm pool&#xA;[www.example.com]&#xA;user = USER&#xA;group = GROUP&#xA;&#xA;listen = /var/run/php/$pool.sock&#xA;&#xA;listen.owner = www-data&#xA;listen.group = www-data&#xA;&#xA;pm = ondemand&#xA;pm.processidletimeout = 10&#xA;pm.maxchildren = 1&#xA;&#xA;chdir = /&#xA;&#xA;phpadminvalue[sendmailpath] = /usr/sbin/sendmail -t -i -f no-reply@ftp.selea.se&#xA;phpadminvalue[mail.log] = /srv/ftp.selea.se/log/mail.log&#xA;phpadminvalue[openbasedir] = /srv/ftp.selea.se:/tmp&#xA;phpadminvalue[memorylimit] = 64M&#xA;phpadminvalue[uploadmaxfilesize] = 64M&#xA;phpadminvalue[postmaxsize] = 64M&#xA;phpadminvalue[maxexecutiontime] = 180&#xA;phpadminvalue[maxinputvars] = 1000&#xA;&#xA;phpadminvalue[disablefunctions] = passthru,exec,shellexec,system,procopen,popen,curlexec,curlmultiexec,parseinifile,showsource,mail&#xA;Netplan - use device MAC instead of /etc/machine-id for DHCP&#xA;network:&#xA;  ethernets:&#xA;    eth0:&#xA;      dhcp4: true&#xA;      dhcp-identifier: mac&#xA;  version: 2&#xA;HPs apt repo for various utilities for proliant machines &#xA;deb http://downloads.linux.hpe.com/SDR/repo/mcp buster/current non-free&#xA;psql stuff&#xA;CREATE DATABASE yourdbname;&#xA;CREATE USER youruser WITH ENCRYPTED PASSWORD &#39;yourpass&#39;;&#xA;GRANT ALL PRIVILEGES ON DATABASE yourdbname TO youruser;&#xA;&#xA;Get entity for AD/SMB based user so you can put it in getent passwd USERNAME&#xA;Nicely shutdown NetApp cluster&#xA;system node autosupport invoke -node  -type all -message &#34;MAINT=48h Power Maintenance&#34;&#xA;system node halt -node  -skip-lif-migration-before-shutdown true -ignore-quorum-warnings true -inhibit-takeover true&#xA;Allow a process to listen on ports 0-1000 in systemd.service file&#xA;[Service]&#xA;AmbientCapabilities=CAPNETBINDSERVICE&#xA;&#xA;#linux #kubernetes #netplan #php-fpm #apache #LVM&#xA;&#xA;]]&gt;</description>
      <content:encoded><![CDATA[<h4 id="lvm-stuff" id="lvm-stuff">LVM stuff</h4>

<pre><code>WARNING: PV /dev/sda2 in VG vg0 is using an old PV header, modify the VG to update.
</code></pre>

<p>Update the metadata with the vgck command – where the “vg0” is your own pool.</p>

<pre><code>vgck --updatemetadata vg0
</code></pre>

<h4 id="curl-stuff" id="curl-stuff">curl stuff</h4>

<p>Curl a specific IP with a another host-header</p>

<pre><code>curl -H &#34;Host: subdomain.example.com&#34; http://172.243.6.400/
</code></pre>

<h4 id="git-stuff" id="git-stuff">git stuff</h4>

<p>tell git.exe to use the built-in CA-store in Windows</p>

<pre><code>git config --global http.sslBackend schannel
</code></pre>

<h4 id="random-stuff" id="random-stuff">random stuff</h4>

<p>See which process is using a file</p>

<pre><code>fuser file
</code></pre>

<h4 id="import-rootcert-into-java-keystore-example" id="import-rootcert-into-java-keystore-example">Import RootCert into Java-keystore example</h4>

<pre><code>sudo /usr/lib/java/jdk8u292-b10-jre/bin/keytool -import -alias some-rootcert -keystore /usr/lib/java/jdk8u292-b10-jre/lib/security/cacerts -file /usr/share/ca-certificates/extra/someRoot.crt`
</code></pre>

<h2 id="apache2-configs-example" id="apache2-configs-example">Apache2 configs example</h2>

<h4 id="enable-ad-authentication-for-web-resources" id="enable-ad-authentication-for-web-resources">Enable AD-authentication for web-resources</h4>

<pre><code>&lt;Location /&gt;
   AuthName &#34;AD authentication&#34;
   AuthBasicProvider ldap
   AuthType Basic
   AuthLDAPGroupAttribute member
   AuthLDAPGroupAttributeIsDN On
   AuthLDAPURL ldap://IP:389/OU=Users,OU=pizza,DC=linux,DC=pizza? 
   sAMAccountName?sub?(objectClass=*)
   AuthLDAPBindDN cn=tomcat7,ou=ServiceAccounts,ou=Users,OU=pizza,dc=linux,dc=pizza
  AuthLDAPBindPassword &#34;exec:/bin/cat /etc/apache2/ldap-password.conf&#34;
  Require ldap-group 
  CN=some_group,OU=Groups,OU=pizza,DC=linux,DC=pizza
  ProxyPass &#34;http://localhost:5601/&#34;
  ProxyPassReverse &#34;http://localhost:5601/&#34;

&lt;/Location&gt;

</code></pre>

<h4 id="insert-matomo-tracking-script-in-apache-using-mod-substitute" id="insert-matomo-tracking-script-in-apache-using-mod-substitute">Insert Matomo tracking script in Apache using mod_substitute</h4>

<pre><code>AddOutputFilterByType SUBSTITUTE text/html
Substitute &#34;s-&lt;/head&gt;-&lt;script type=\&#34;text/javascript\&#34;&gt;var _paq = _paq || [];_paq.push([&#39;trackPageView&#39;]);_paq.push([&#39;enableLinkTracking&#39;]);(function() {var u=\&#34;https://matomo.example.com/\&#34;;_paq.push([&#39;setTrackerUrl&#39;, u+&#39;matomo.php&#39;]);_paq.push([&#39;setSiteId&#39;, &#39;1&#39;]);var d=document, g=d.createElement(&#39;script&#39;), s=d.getElementsByTagName(&#39;script&#39;)[0];g.type=&#39;text/javascript&#39;; g.async=true; g.defer=true; g.src=u+&#39;matomo.js&#39;; s.parentNode.insertBefore(g,s);})();&lt;/script&gt;&lt;/head&gt;-n&#34;
</code></pre>

<h4 id="load-balance-backend-servers" id="load-balance-backend-servers">Load balance backend-servers</h4>

<pre><code>&lt;Proxy balancer://k3singress&gt;
	BalancerMember http://x.x.x.1:80
	BalancerMember http://x.x.x.2:80
	BalancerMember http://x.x.x.3:80
	BalancerMember http://x.x.x.4:80
	ProxySet lbmethod=bytraffic
	ProxySet connectiontimeout=5 timeout=30
	SetEnv force-proxy-request-1.0 1
	SetEnv proxy-nokeepalive 1
&lt;/Proxy&gt;
       ProxyPass &#34;/&#34; &#34;balancer://k3singress/&#34;
       ProxyPassReverse &#34;/&#34; &#34;balancer://k3singress/&#34;
       ProxyVia Full
       ProxyRequests On
       ProxyPreserveHost On
</code></pre>

<h4 id="basic-apache-config-for-php-fpm" id="basic-apache-config-for-php-fpm">Basic Apache-config for PHP-FPM</h4>

<pre><code>&lt;VirtualHost *:80&gt;
  ServerName www.example.com
  DocumentRoot /srv/www.example.com/htdocs
  &lt;Directory /srv/www.example.com/htdocs&gt;
    AllowOverride All
    Require all granted
    DirectoryIndex index.html index.htm index.php
    &lt;FilesMatch &#34;\.php$&#34;&gt;
      SetHandler proxy:unix:/run/php/www.example.com.sock|fcgi://localhost
    &lt;/FilesMatch&gt;
  &lt;/Directory&gt;
  SetEnvIf x-forwarded-proto https HTTPS=on
&lt;/VirtualHost&gt;
</code></pre>

<h4 id="basic-php-fpm-pool" id="basic-php-fpm-pool">Basic PHP-fpm pool</h4>

<pre><code>[www.example.com]
user = USER
group = GROUP

listen = /var/run/php/$pool.sock

listen.owner = www-data
listen.group = www-data

pm = ondemand
pm.process_idle_timeout = 10
pm.max_children = 1

chdir = /

php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f no-reply@ftp.selea.se
php_admin_value[mail.log] = /srv/ftp.selea.se/log/mail.log
php_admin_value[open_basedir] = /srv/ftp.selea.se:/tmp
php_admin_value[memory_limit] = 64M
php_admin_value[upload_max_filesize] = 64M
php_admin_value[post_max_size] = 64M
php_admin_value[max_execution_time] = 180
php_admin_value[max_input_vars] = 1000

php_admin_value[disable_functions] = passthru,exec,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec,parse_ini_file,show_source,mail
</code></pre>

<h3 id="netplan-use-device-mac-instead-of-etc-machine-id-for-dhcp" id="netplan-use-device-mac-instead-of-etc-machine-id-for-dhcp">Netplan – use device MAC instead of /etc/machine-id for DHCP</h3>

<pre><code>network:
  ethernets:
    eth0:
      dhcp4: true
      dhcp-identifier: mac
  version: 2
</code></pre>

<h4 id="hps-apt-repo-for-various-utilities-for-proliant-machines" id="hps-apt-repo-for-various-utilities-for-proliant-machines">HPs apt repo for various utilities for proliant machines</h4>

<pre><code>deb http://downloads.linux.hpe.com/SDR/repo/mcp buster/current non-free
</code></pre>

<h4 id="psql-stuff" id="psql-stuff">psql stuff</h4>

<pre><code>CREATE DATABASE yourdbname;
CREATE USER youruser WITH ENCRYPTED PASSWORD &#39;yourpass&#39;;
GRANT ALL PRIVILEGES ON DATABASE yourdbname TO youruser;
</code></pre>

<p>Get entity for AD/SMB based user so you can put it in <code>/etc/passwd</code>:</p>

<pre><code>getent passwd USERNAME
</code></pre>

<p>Nicely shutdown NetApp cluster</p>

<pre><code>system node autosupport invoke -node * -type all -message &#34;MAINT=48h Power Maintenance&#34;
system node halt -node * -skip-lif-migration-before-shutdown true -ignore-quorum-warnings true -inhibit-takeover true
</code></pre>

<p>Allow a process to listen on ports 0-1000 in systemd.service file</p>

<pre><code>[Service]
AmbientCapabilities=CAP_NET_BIND_SERVICE
</code></pre>

<p><a href="https://blogs.linux.pizza/tag:linux" class="hashtag"><span>#</span><span class="p-category">linux</span></a> <a href="https://blogs.linux.pizza/tag:kubernetes" class="hashtag"><span>#</span><span class="p-category">kubernetes</span></a> <a href="https://blogs.linux.pizza/tag:netplan" class="hashtag"><span>#</span><span class="p-category">netplan</span></a> <a href="https://blogs.linux.pizza/tag:php" class="hashtag"><span>#</span><span class="p-category">php</span></a>-fpm <a href="https://blogs.linux.pizza/tag:apache" class="hashtag"><span>#</span><span class="p-category">apache</span></a> <a href="https://blogs.linux.pizza/tag:LVM" class="hashtag"><span>#</span><span class="p-category">LVM</span></a></p>
]]></content:encoded>
      <guid>https://blogs.linux.pizza/random-stuff-cheat-sheet</guid>
      <pubDate>Fri, 30 Jun 2023 07:53:42 +0000</pubDate>
    </item>
    <item>
      <title>Kubectl cheat-sheet</title>
      <link>https://blogs.linux.pizza/kubectl-cheat-sheet</link>
      <description>&lt;![CDATA[## Just some random #kubectl commands for myself. I have tested these on 1.20  1.25&#xA;&#xA;Get all ingress logs (if your ingress is nginx)&#xA;kubectl logs -n ingress-nginx -l app.kubernetes.io/name=ingress-nginx&#xA;Get all logs from Deployment&#xA;kubectl logs deployment/deployment -n namespace --watch&#xA;Why is the pod stuck in &#34;ContainerCreating&#34;?&#xA;kubectl get events --sort-by=.metadata.creationTimestamp --watch&#xA;Restart your deployment, nice and clean&#xA;kubectl rollout restart deployment/deployment -n namespace&#xA;Check which namespaces are using the most disk space&#xA;kubectl get namespace --no-headers | xargs -I {} sh -c &#39;echo {}; kubectl get pods -n {} --no-headers | xargs -I {} sh -c &#34;kubectl logs {} -n {} | wc -c&#34;&#39; | awk &#39;{print $1&#34; &#34;($2/1024/1024)&#34; MB&#34;}&#39; | sort -k2 -n -r | head&#xA;Check if any pods are using a lot of disk space&#xA;kubectl get pods --all-namespaces -o json | jq &#39;.items[].spec.containers[].resources.requests.storage&#39; | grep -v null&#xA;Check the Kubernetes event logs for any disk-related errors&#xA;&#xA;kubectl get events --field-selector involvedObject.kind=Node,reason=OutOfDisk&#xA;&#xA;I&#39;ll add more when I find more usefull stuff&#xA;&#xA;#linux #k8s #kubernetes #kubectl #ingress #nginx #deployment #logs]]&gt;</description>
      <content:encoded><![CDATA[<h2 id="just-some-random-kubectl-commands-for-myself-i-have-tested-these-on-1-20-1-25" id="just-some-random-kubectl-commands-for-myself-i-have-tested-these-on-1-20-1-25">Just some random <a href="https://blogs.linux.pizza/tag:kubectl" class="hashtag"><span>#</span><span class="p-category">kubectl</span></a> commands for myself. I have tested these on 1.20 &lt;&gt; 1.25</h2>

<h4 id="get-all-ingress-logs-if-your-ingress-is-nginx" id="get-all-ingress-logs-if-your-ingress-is-nginx">Get all ingress logs (if your ingress is nginx)</h4>

<pre><code>kubectl logs -n ingress-nginx -l app.kubernetes.io/name=ingress-nginx
</code></pre>

<h4 id="get-all-logs-from-deployment" id="get-all-logs-from-deployment">Get all logs from Deployment</h4>

<pre><code>kubectl logs deployment/&lt;deployment&gt; -n &lt;namespace&gt; --watch
</code></pre>

<h4 id="why-is-the-pod-stuck-in-containercreating" id="why-is-the-pod-stuck-in-containercreating">Why is the pod stuck in “ContainerCreating”?</h4>

<pre><code>kubectl get events --sort-by=.metadata.creationTimestamp --watch
</code></pre>

<h4 id="restart-your-deployment-nice-and-clean" id="restart-your-deployment-nice-and-clean">Restart your deployment, nice and clean</h4>

<pre><code>kubectl rollout restart deployment/&lt;deployment&gt; -n &lt;namespace&gt;
</code></pre>

<h4 id="check-which-namespaces-are-using-the-most-disk-space" id="check-which-namespaces-are-using-the-most-disk-space">Check which namespaces are using the most disk space</h4>

<pre><code>kubectl get namespace --no-headers | xargs -I {} sh -c &#39;echo {}; kubectl get pods -n {} --no-headers | xargs -I {} sh -c &#34;kubectl logs {} -n {} | wc -c&#34;&#39; | awk &#39;{print $1&#34; &#34;($2/1024/1024)&#34; MB&#34;}&#39; | sort -k2 -n -r | head
</code></pre>

<h4 id="check-if-any-pods-are-using-a-lot-of-disk-space" id="check-if-any-pods-are-using-a-lot-of-disk-space">Check if any pods are using a lot of disk space</h4>

<pre><code>kubectl get pods --all-namespaces -o json | jq &#39;.items[].spec.containers[].resources.requests.storage&#39; | grep -v null
</code></pre>

<h4 id="check-the-kubernetes-event-logs-for-any-disk-related-errors" id="check-the-kubernetes-event-logs-for-any-disk-related-errors">Check the Kubernetes event logs for any disk-related errors</h4>

<pre><code>kubectl get events --field-selector involvedObject.kind=Node,reason=OutOfDisk
</code></pre>

<p>I&#39;ll add more when I find more usefull stuff</p>

<p><a href="https://blogs.linux.pizza/tag:linux" class="hashtag"><span>#</span><span class="p-category">linux</span></a> <a href="https://blogs.linux.pizza/tag:k8s" class="hashtag"><span>#</span><span class="p-category">k8s</span></a> <a href="https://blogs.linux.pizza/tag:kubernetes" class="hashtag"><span>#</span><span class="p-category">kubernetes</span></a> <a href="https://blogs.linux.pizza/tag:kubectl" class="hashtag"><span>#</span><span class="p-category">kubectl</span></a> <a href="https://blogs.linux.pizza/tag:ingress" class="hashtag"><span>#</span><span class="p-category">ingress</span></a> <a href="https://blogs.linux.pizza/tag:nginx" class="hashtag"><span>#</span><span class="p-category">nginx</span></a> <a href="https://blogs.linux.pizza/tag:deployment" class="hashtag"><span>#</span><span class="p-category">deployment</span></a> <a href="https://blogs.linux.pizza/tag:logs" class="hashtag"><span>#</span><span class="p-category">logs</span></a></p>
]]></content:encoded>
      <guid>https://blogs.linux.pizza/kubectl-cheat-sheet</guid>
      <pubDate>Tue, 28 Feb 2023 08:04:47 +0000</pubDate>
    </item>
    <item>
      <title>Creating a PV and PVC on NFS for K8s</title>
      <link>https://blogs.linux.pizza/creating-a-pv-and-pvc-on-nfs-for-k8s</link>
      <description>&lt;![CDATA[Took myself ages to figure this out, so I am noting this down for my future self.&#xA;Just a note - this is not the indented workflow, but rather a &#34;getting started with kubernetes&#34; step.&#xA;&#xA;First, we need to add NFS as a storage class:&#xA;&#xA;apiVersion: storage.k8s.io/v1&#xA;kind: StorageClass&#xA;metadata:&#xA;  name: managed-nfs-storage&#xA;provisioner: k8s-sigs.io/nfs-subdir-external-provisioner # or choose another name, must match deployment&#39;s env PROVISIONERNAME&#39;&#xA;parameters:&#xA;  archiveOnDelete: &#34;false&#34;&#xA;Then, we can add the actual storage:&#xA;kind: PersistentVolume&#xA;apiVersion: v1&#xA;metadata:&#xA;  name: nfs-persistentvolume&#xA;spec:&#xA;  capacity:&#xA;    storage: 1Gi&#xA;  accessModes:&#xA;    ReadWriteMany&#xA;  storageClassName: &#34;nfs&#34; # Empty string must be explicitly set otherwise default StorageClass will be set / or custom storageClassName name&#xA;  nfs:&#xA;    path: &#34;/path/to/share&#34;&#xA;    server: &#34;xxx.xxx.xxx.xxx&#34;&#xA;    readOnly: false&#xA;  claimRef:&#xA;    name: nfs-persistentvolumeclaim&#xA;    namespace: default&#xA;---&#xA;apiVersion: v1&#xA;kind: PersistentVolumeClaim&#xA;metadata:&#xA;  name: nfs-persistentvolumeclaim&#xA;  namespace: default&#xA;spec:&#xA;  accessModes:&#xA;    ReadWriteMany&#xA;  resources:&#xA;    requests:&#xA;      storage: 1Gi&#xA;  storageClassName: &#34;nfs&#34; # Empty string must be explicitly set otherwise default StorageClass will be set / or custom storageClassName name&#xA;  volumeName: nfs-persistentvolume&#xA;&#xA;Hope this helps&#xA;&#xA;Bonus - run a Minecraft Bedrock inside K8S using your newly created PVC as storage&#xA;&#xA;apiVersion: apps/v1&#xA;kind: Deployment&#xA;metadata:&#xA;  name: mc-bedrock&#xA;  labels:&#xA;    app: mc-bedrock&#xA;spec:&#xA;  replicas: 1&#xA;  template:&#xA;    metadata:&#xA;      name: mc-bedrock&#xA;      labels:&#xA;        app: mc-bedrock&#xA;    spec:&#xA;      containers:&#xA;        name: mc-bedrock&#xA;          image: itzg/minecraft-bedrock-server&#xA;          imagePullPolicy: Always&#xA;          resources:&#xA;            requests:&#xA;              cpu: 500m&#xA;              memory: 4Gi&#xA;          env:&#xA;            name: EULA&#xA;              value: &#34;TRUE&#34;&#xA;            name: GAMEMODE&#xA;              value: survival&#xA;            name: DIFFICULTY&#xA;              value: normal&#xA;            name: WHITELIST&#xA;              value: &#34;false&#34;&#xA;            name: ONLINEMODE&#xA;              value: &#34;true&#34;&#xA;            name: ALLOWCHEATS&#xA;              value: &#34;true&#34;&#xA;          volumeMounts:&#xA;            mountPath: /data&#xA;              name: data&#xA;      volumes:&#xA;        name: data&#xA;          persistentVolumeClaim:&#xA;            claimName: nfs-persistentvolumeclaim&#xA;  selector:&#xA;    matchLabels:&#xA;      app: mc-bedrock&#xA;---&#xA;apiVersion: v1&#xA;kind: Service&#xA;metadata:&#xA;  name: mc-bedrock&#xA;  labels:&#xA;    app: mc-bedrock&#xA;spec:&#xA;  selector:&#xA;    app: mc-bedrock&#xA;  ports:&#xA;    port: 19132&#xA;      protocol: UDP&#xA;  type: LoadBalancer&#xA;Get the IP assigned for the service&#xA;kubectl get service mc-bedrock -o jsonpath=&#39;{.status.loadBalancer.ingress[0].ip}&#39;&#xA;Restart the pods in the deployment&#xA;kubectl logs -f deployment/mc-bedrock&#xA;&#xA;#linux #k8s #kubernetes #pvc #pv #minecraft]]&gt;</description>
      <content:encoded><![CDATA[<p>Took myself ages to figure this out, so I am noting this down for my future self.
Just a note – this is not the indented workflow, but rather a “getting started with kubernetes” step.</p>

<h4 id="first-we-need-to-add-nfs-as-a-storage-class" id="first-we-need-to-add-nfs-as-a-storage-class">First, we need to add NFS as a storage class:</h4>

<pre><code>apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: managed-nfs-storage
provisioner: k8s-sigs.io/nfs-subdir-external-provisioner # or choose another name, must match deployment&#39;s env PROVISIONER_NAME&#39;
parameters:
  archiveOnDelete: &#34;false&#34;
</code></pre>

<h4 id="then-we-can-add-the-actual-storage" id="then-we-can-add-the-actual-storage">Then, we can add the actual storage:</h4>

<pre><code>kind: PersistentVolume
apiVersion: v1
metadata:
  name: nfs-persistentvolume
spec:
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteMany
  storageClassName: &#34;nfs&#34; # Empty string must be explicitly set otherwise default StorageClass will be set / or custom storageClassName name
  nfs:
    path: &#34;/path/to/share&#34;
    server: &#34;xxx.xxx.xxx.xxx&#34;
    readOnly: false
  claimRef:
    name: nfs-persistentvolumeclaim
    namespace: default
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nfs-persistentvolumeclaim
  namespace: default
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 1Gi
  storageClassName: &#34;nfs&#34; # Empty string must be explicitly set otherwise default StorageClass will be set / or custom storageClassName name
  volumeName: nfs-persistentvolume

</code></pre>

<p>Hope this helps</p>

<h2 id="bonus-run-a-minecraft-bedrock-inside-k8s-using-your-newly-created-pvc-as-storage" id="bonus-run-a-minecraft-bedrock-inside-k8s-using-your-newly-created-pvc-as-storage">Bonus – run a Minecraft Bedrock inside K8S using your newly created PVC as storage</h2>

<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: mc-bedrock
  labels:
    app: mc-bedrock
spec:
  replicas: 1
  template:
    metadata:
      name: mc-bedrock
      labels:
        app: mc-bedrock
    spec:
      containers:
        - name: mc-bedrock
          image: itzg/minecraft-bedrock-server
          imagePullPolicy: Always
          resources:
            requests:
              cpu: 500m
              memory: 4Gi
          env:
            - name: EULA
              value: &#34;TRUE&#34;
            - name: GAMEMODE
              value: survival
            - name: DIFFICULTY
              value: normal
            - name: WHITE_LIST
              value: &#34;false&#34;
            - name: ONLINE_MODE
              value: &#34;true&#34;
            - name: ALLOW_CHEATS
              value: &#34;true&#34;
          volumeMounts:
            - mountPath: /data
              name: data
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: nfs-persistentvolumeclaim
  selector:
    matchLabels:
      app: mc-bedrock
---
apiVersion: v1
kind: Service
metadata:
  name: mc-bedrock
  labels:
    app: mc-bedrock
spec:
  selector:
    app: mc-bedrock
  ports:
    - port: 19132
      protocol: UDP
  type: LoadBalancer
</code></pre>

<h4 id="get-the-ip-assigned-for-the-service" id="get-the-ip-assigned-for-the-service">Get the IP assigned for the service</h4>

<pre><code>kubectl get service mc-bedrock -o jsonpath=&#39;{.status.loadBalancer.ingress[0].ip}&#39;
</code></pre>

<h4 id="restart-the-pods-in-the-deployment" id="restart-the-pods-in-the-deployment">Restart the pods in the deployment</h4>

<pre><code>kubectl logs -f deployment/mc-bedrock
</code></pre>

<p><a href="https://blogs.linux.pizza/tag:linux" class="hashtag"><span>#</span><span class="p-category">linux</span></a> <a href="https://blogs.linux.pizza/tag:k8s" class="hashtag"><span>#</span><span class="p-category">k8s</span></a> <a href="https://blogs.linux.pizza/tag:kubernetes" class="hashtag"><span>#</span><span class="p-category">kubernetes</span></a> <a href="https://blogs.linux.pizza/tag:pvc" class="hashtag"><span>#</span><span class="p-category">pvc</span></a> <a href="https://blogs.linux.pizza/tag:pv" class="hashtag"><span>#</span><span class="p-category">pv</span></a> <a href="https://blogs.linux.pizza/tag:minecraft" class="hashtag"><span>#</span><span class="p-category">minecraft</span></a></p>
]]></content:encoded>
      <guid>https://blogs.linux.pizza/creating-a-pv-and-pvc-on-nfs-for-k8s</guid>
      <pubDate>Tue, 06 Jul 2021 14:18:39 +0000</pubDate>
    </item>
  </channel>
</rss>