<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>k8s on Alekc's Blog</title><link>https://blog.alekc.org/categories/k8s/</link><description>Recent content in k8s on Alekc's Blog</description><generator>Hugo -- gohugo.io</generator><copyright>©{year}, All Rights Reserved</copyright><lastBuildDate>Sat, 03 Dec 2022 00:00:00 +0000</lastBuildDate><atom:link href="https://blog.alekc.org/categories/k8s/index.xml" rel="self" type="application/rss+xml"/><item><title>Useful debugging tools for kubernetes</title><link>https://blog.alekc.org/posts/useful-debugging-tools-for-kubernetes/</link><pubDate>Sat, 03 Dec 2022 00:00:00 +0000</pubDate><guid>https://blog.alekc.org/posts/useful-debugging-tools-for-kubernetes/</guid><description>Sometimes its useful to be able to run some ephemeral containers on kubernetes cluster in order to perform some debugging (i.e. dns resolution, pinging nodes, etc).
Sadly, most of the times, it can be tricky to remember all overrides so here is a small list
Run an ephemeral shell on a random node 1kubectl run -ti --restart=Never --rm debug --image=alekcander/network-diag -- sh Run a container with specific service account 1kubectl run -ti --restart=Never --rm debug --image=alekcander/network-diag --overrides=&amp;#39;{ &amp;#34;spec&amp;#34;: { &amp;#34;serviceAccount&amp;#34;: &amp;#34;terraform-runner&amp;#34; } }&amp;#39; -- sh Run on a specific node 1kubectl run -ti --restart=Never --rm debug --image=alekcander/network-diag --overrides=&amp;#39;{&amp;#34;spec&amp;#34;: { &amp;#34;nodeName&amp;#34;: &amp;#34;alekc-worker-01&amp;#34;}}&amp;#39; -- sh Run based on specific selector (ie.</description></item><item><title>Fixing etcdDatabaseHighFragmentationRatio prometheus alert</title><link>https://blog.alekc.org/posts/fixing-etcddatabasehighfragmentationratio-prometheus-alert/</link><pubDate>Sat, 03 Sep 2022 23:00:00 +0000</pubDate><guid>https://blog.alekc.org/posts/fixing-etcddatabasehighfragmentationratio-prometheus-alert/</guid><description>If you receive a following error in alertmanager
1etcd cluster &amp;#34;kube-etcd&amp;#34;: database size in use on instance xxx.xxx.xxx.xxx:2381 2is 49.55% of the actual allocated disk space, please run defragmentation 3(e.g. etcdctl defrag) to retrieve the unused fragmented disk space. it can be easily solved by running a following command:
1kubectl exec $(kubectl get pods --selector=component=etcd -A -o name \ 2| head -n 1) -n kube-system -- etcdctl defrag --cluster \ 3--cacert /etc/kubernetes/pki/etcd/ca.</description></item><item><title>Kubernetes networking</title><link>https://blog.alekc.org/posts/kubernetes-networking/</link><pubDate>Wed, 17 Aug 2022 08:00:00 +0000</pubDate><guid>https://blog.alekc.org/posts/kubernetes-networking/</guid><description>Kubernetes networking Pause container In Kubernetes, the pause container serves as the &amp;ldquo;parent container&amp;rdquo; for all of the containers in your pod, and it has two main responsibilities:
it serves as the basis of Linux namespace sharing in the pod with PID (process ID) namespace sharing enabled, it serves as PID 1 for each pod and reaps zombie processes. In Linux, each running process communicates within a network namespace that provides a logical networking stack with its own routes, firewall rules, and network devices.</description></item><item><title>Longhorn disaster recovery jobs</title><link>https://blog.alekc.org/posts/longhorn-disaster-recovery-jobs/</link><pubDate>Mon, 15 Aug 2022 02:00:00 +0000</pubDate><guid>https://blog.alekc.org/posts/longhorn-disaster-recovery-jobs/</guid><description>&lt;p>Longhorn is a brilliant piece of software (especially for those who cannot use block volumes on their Kubernetes cluster), but it can (and does) happen to have some volumes getting degraded and thus requiring to recover from a backup.&lt;/p></description></item><item><title>How to create cross cloud self managed kubernetes cluster</title><link>https://blog.alekc.org/posts/how-to-create-cross-cloud-self-managed-kubernetes-cluster/</link><pubDate>Sun, 14 Aug 2022 23:00:00 +0000</pubDate><guid>https://blog.alekc.org/posts/how-to-create-cross-cloud-self-managed-kubernetes-cluster/</guid><description>&lt;hr>
&lt;p>While it&amp;rsquo;s fairly &amp;ldquo;trivial&amp;rdquo; to install a stacked kubernetes cluster with kubeadm on any cloud provider or managed bare metal (where you have a certain degree of management over the networking which permits you to use bgp for example), it&amp;rsquo;s not so trivial when your nodes are situated in different network segments (clouds) and/or behind NAT.&lt;/p>
&lt;p>With this guide I will try to alleviate a pain related to this kind of setup.&lt;/p></description></item><item><title>Prometheus - kube-proxy endpoint connection refused</title><link>https://blog.alekc.org/posts/prometheus-kube-proxy-endpoint-connection-refused/</link><pubDate>Mon, 30 May 2022 23:00:00 +0000</pubDate><guid>https://blog.alekc.org/posts/prometheus-kube-proxy-endpoint-connection-refused/</guid><description>When using kube-prometheus-stack and kubernetes cluster provisioned by kubeadm you will likely have an issue of prometheus not being able to connect to the kube-proxy metrics
It can be easily fixed by editing it&amp;rsquo;s config map
kubectl edit cm/kube-proxy -n kube-system Change the metricsBindAddress property from 127.0.0.1:10249 (or empty value) to
metricsBindAddress: 0.0.0.0:10249 Delete and redeploy kube-proxy pods
kubectl delete pod -l k8s-app=kube-proxy -n kube-system</description></item><item><title>How to mass remove finalizers from argocd applications</title><link>https://blog.alekc.org/posts/how-to-mass-remove-finalizers-from-argocd-applications/</link><pubDate>Mon, 24 Jan 2022 11:00:00 +0000</pubDate><guid>https://blog.alekc.org/posts/how-to-mass-remove-finalizers-from-argocd-applications/</guid><description>If you are using finalizers in your argo-cd applications, you may find that it&amp;rsquo;s impossible to delete them if argo-cd installation is broken.
In order to fix it, you can either update them one by one with kubectl edit and remove the finalizer tag, or you can run following command which will patch all argocd entities in argocd namespace
kubectl get Application -A -o name | xargs kubectl patch -p '{&amp;quot;metadata&amp;quot;:{&amp;quot;finalizers&amp;quot;:null}}' --type=merge -n argocd</description></item><item><title>An error occurred (AccessDenied) when calling the AssumeRoleWithWebIdentity operation</title><link>https://blog.alekc.org/posts/2021/how-to-fix-access-denied-assumerolewithwebidentity/</link><pubDate>Wed, 29 Sep 2021 05:40:59 +0000</pubDate><guid>https://blog.alekc.org/posts/2021/how-to-fix-access-denied-assumerolewithwebidentity/</guid><description>&lt;p>When working with EKS under AWS, it&amp;rsquo;s possible that at some point you wanted to run a pod under a certain role, and you&amp;rsquo;ve encountered a following error:&lt;/p>
&lt;blockquote>
&lt;p>An error occurred (AccessDenied) when calling the AssumeRoleWithWebIdentity operation: Not authorized to perform sts:AssumeRoleWithWebIdentity&lt;/p>
&lt;/blockquote>
&lt;p>What&amp;rsquo;s frustrating, is that by default AWS doesn&amp;rsquo;t provide you a lot of feedback of why that error happened.&lt;/p>
&lt;p>So I&amp;rsquo;ve written down some debug steps for further reference:&lt;/p></description></item><item><title>Recovery of etcd failing node</title><link>https://blog.alekc.org/posts/2021/recovery-of-etcd-failing-node/</link><pubDate>Thu, 14 Jan 2021 16:40:59 +0000</pubDate><guid>https://blog.alekc.org/posts/2021/recovery-of-etcd-failing-node/</guid><description>&lt;p>One of my etcd nodes in my home k8s cluster has been failing with following message:&lt;/p>
&lt;div class="highlight">&lt;pre class="chroma">&lt;code class="language-fallback" data-lang="fallback">&lt;span class="ln">1&lt;/span>2021-01-14 11:16:09.233458 I | embed: listening for peers on 192.168.0.33:2380
&lt;span class="ln">2&lt;/span>raft2021/01/14 11:16:09 tocommit(29492601) is out of range [lastIndex(29492469)]. Was the raft log corrupted, truncated, or lost?
&lt;span class="ln">3&lt;/span>panic: tocommit(29492601) is out of range [lastIndex(29492469)]. Was the raft log corrupted, truncated, or lost?
&lt;/code>&lt;/pre>&lt;/div>&lt;p>These are steps I took to fix it:&lt;/p></description></item></channel></rss>