Skip to content

Instantly share code, notes, and snippets.

View swagfin's full-sized avatar
🖥️
Just a little research

George Njeri (Swagfin) swagfin

🖥️
Just a little research
View GitHub Profile
@swagfin
swagfin / upgrading-argocd-on-microk8s.md
Last active July 2, 2025 06:55
This guide helps you check for new Argo CD versions and upgrade safely when installed via Helm.

🔄 Checking for Argo CD Updates & Performing an Upgrade (Helm-based)

This guide helps you check for new Argo CD versions and upgrade safely when installed via Helm.

🧰 Prerequisites

  • Argo CD installed using helm via MicroK8s community addon
  • Access to microk8s helm3
  • Namespace: argocd

🔁 WithRetry Helper for C#

A minimal retry utility for async methods with and without return values.

📦 Code

using System;
using System.Threading;
using System.Threading.Tasks;
@swagfin
swagfin / horizontal-scaling-aspnet-core-razor-pages-auth-problem.md
Created April 5, 2025 19:34
Horizontally Scaling an ASP.NET Core Razor App (Authentication with Redis)

Horizontally Scaling an ASP.NET Core Razor App (Authentication with Redis)

When scaling your ASP.NET Core Razor app to multiple instances (pods, containers, etc.), authentication can become problematic. This is particularly true for cookie-based authentication, where each instance of your app needs to be able to encrypt and decrypt cookies using the same encryption keys.

Problem

By default, ASP.NET Core stores its data protection keys locally within the app (e.g., in /root/.aspnet/DataProtection-Keys). This approach works well in single-instance scenarios, but when you scale horizontally, each instance of your app has its own set of encryption keys. As a result, cookies encrypted by one instance cannot be decrypted by another, causing authentication failures.

Symptoms:

  • Users are redirected to the login page when they switch between different instances (pods).
@swagfin
swagfin / updating-ubuntu-hostname-after-cloning.md
Created March 25, 2025 15:38
Updating Ubuntu Hostname After Cloning a Disk

Updating Ubuntu Hostname After Cloning a Disk

Step 1: Change the Hostname

Update the hostname using the hostnamectl command:

sudo hostnamectl set-hostname NEW_HOSTNAME

Step 2: Update /etc/hostname

Edit the file manually:

@swagfin
swagfin / how-to-join-a-node-into-microk8s-cluster.md
Last active April 2, 2025 21:44
How to Join a Node into MicroK8s Cluster

How to Join a Node into a MicroK8s Cluster as a Worker

MicroK8s provides an easy way to create lightweight Kubernetes clusters. This guide explains how to join a new node as a worker in an existing MicroK8s cluster using the --worker flag.


1. On the Control Plane (Primary Node)

Run the following command to generate a join token:

@swagfin
swagfin / how-to-setup-nfs-server-on-ubuntu.md
Last active November 3, 2024 14:08
How to Set Up NFS Server on Ubuntu

How to Set Up NFS Server on Ubuntu

Install NFS Server

First, install the NFS kernel server:

sudo apt install nfs-kernel-server

Start the NFS service:

sudo systemctl start nfs-kernel-server.service

How to re-generate K8s SSL Certificates on MicroK8s

Issue

You might encounter the following error when you the IP addresses is changed on the host machine:

Unable to connect to the server: x509: certificate is valid for <internal IPs>, not <external IP>

Solution

@swagfin
swagfin / how-to-add-users-and-roles-in-argocd.md
Last active September 22, 2024 19:54
How to Add Users and Role Policies in Argo CD

Adding Users with Role Policy in Argo CD

Step 1: Login to Argo CD

You can log in to Argo CD or bash into the Argo CD pod running in Kubernetes:

argocd login <ARGOCD_SERVER> --username admin --password <ADMIN_PASSWORD>

Step 2: Create a User

@swagfin
swagfin / microk8s-fix-node-unhealthy-after-reboot.md
Last active September 22, 2024 19:58
Microk8s - Fixing Node Re-connection after Re-boot Issue

Fixing K8s Node UnHealthy after Re-boot Issue

Issue:

Nodes in the Kubernetes cluster may remain in an "Unhealthy" state on the control plane/master node after they are restarted. This problem occurs because the nf_conntrack module, which is essential for network connection tracking, is not automatically loaded on reboot.

Solution:

To ensure nodes reconnect properly after a restart, you need to make sure the nf_conntrack module is loaded at boot on all workers nodes thought this command;

@swagfin
swagfin / fixing-network-driver-issues-on-ubuntu-20.04.md
Last active March 23, 2024 09:33
Fixing Network Driver Issues on Ubuntu 20.04

Fixing Network Driver Issues on Ubuntu 20.04

If you encounter missing network drivers when installing Ubuntu on new machines, you might notice that network cards are listed as (UNCLAIMED) when you execute the command:

lshw -c network

This indicates that your device requires Hardware Enablement (HWE).

About Hardware Enablement (HWE)