<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>k8s &amp;mdash; LinuxPizza</title>
    <link>https://blogs.linux.pizza/tag:k8s</link>
    <description>Personal notes and occasional posts - 100% human, 0% AI generated</description>
    <pubDate>Wed, 29 Apr 2026 12:04:46 +0000</pubDate>
    <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>