Skip to main content

Posts


Install

Install microk8s and nginx ingress.

sudo snap install microk8s --classic
sudo microk8s status --wait
sudo microk8s enable ingress

Note that the nginx ingressClassName provided by microk8s is public.

Configure

Increase proxy buffer size, enable header underscores, enable use-forwarded-headers.

microk8s kubectl -n ingress edit configmaps nginx-load-balancer-microk8s-conf

add the following

data:
  use-forwarded-headers: "true"
  enable-underscores-in-headers: "true"
  proxy-buffer-size: "16k"

Rollout the changes

microk8s kubectl -n ingress rollout restart daemonset nginx-ingress-microk8s-controller

Create oci images/containers

Use podman or docker.

examplescript.sh

#!/bin/bash
while true
do
	echo "Press [CTRL+C] to stop.."
	sleep 1
done

Make the script executable.

chmod +x ./examplescript.sh

Dockerfile. The filename must be “Dockerfile” or when calling docker build -f must be used to pass in the filename.

FROM ubuntu:22.04
ADD examplescript.sh /
RUN apt update && apt install bash -y
CMD [ "./examplescript.sh" ]

build the image

sudo docker build -t exampleapp .

Verify the image was built.

sudo docker build -t exampleapp .
sudo docker images
sudo docker run localhost/exampleapp

create pods and deployments

create a pod yaml

Create the yaml for a pod running a nginx container.

kubectl run nginx --image=nginx --dry-run=client -o yaml > example-pod.yaml

create a deployment yaml

Create the yaml for a deployment with a pod running an nginx container.

kubectl create deployment --image=nginx nginx --dry-run=client -o yaml > example-deployment.yaml

create a nodeport service yaml

Use a nodeport service to expose an applications via port. Note: –tcp=:

kubectl create service nodeport ns-service --tcp=80:80 --dry-run=client -o yaml > example-nodeport-service.yaml


Resize logical volume

# Check disks
lsblk /dev/sda
lsblk /dev/sdb
lsblk /dev/nvme0n1

# Increase the Physical Volume (pv) to max size
pvresize /dev/sda3

# Expand the Logical Volume (LV) to max size to match
lvresize -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv

# Expand the filesystem itself
resize2fs /dev/mapper/ubuntu--vg-ubuntu--lv

Add a second disk to a lvm

# display physical volumes (pv)
pvs
pvdisplay

# display lvm volume groups (vg)
vgs
vgdisplay

# display lvm logical volume (lv)
lvs
lvdisplay

# find out info on all disks
fdisk -l | grep '^Disk /dev/'
lvmdiskscan

# create the physical volume (pv) and verify
# this is if the new disk is named /dev/sdb
pvcreate /dev/sdb
lvmdiskscan -l

# Add new pv named /dev/sdb to an existing lv

# add /dev/sdb to volume group
vgextend ubuntu-vg /dev/sdb

# extend mapped drive to full size
lvm lvextend -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv

# resize to 
resize2fs -p /dev/mapper/ubuntu--vg-ubuntu--lv

# verify
df -H

Fdisk basics

# list partisions
fdisk -l

# open /dev/sdb for editing
# once fdisk is running 'm' is for help
fdisk /dev/sdb

References


As a reminder to myself. SBOM (software bill of materials) tooling at this time is CycloneDX.

At the time of writing all below instructoins assume a linux install with bash.

Install CycloneDX

echo "dotnet cyclonedx install"
dotnet tool install --global CycloneDX 
ln -s /root/.dotnet/tools/dotnet-CycloneDX /usr/bin/CycloneDX 

echo "javascript cyclonedx install
npm install --global @cyclonedx/cyclonedx-npm 

Run CycloneDX

Run the dotnet tool against a c# project with github credentials to avoid rate limiting.

PROJECT_PATH="PROJECT PLACEHOLDER.csproj"
REPORT_TITLE="TITLE PLACEHOLDER"
REPORT_OUTPUT_FOLDER=`pwd`
REPORT_FILENAME="the-sbom-report.xml"
REPORT_VERSION="1.2.3"
GITHUB_USERNAME="GH USERNAME PLACEHOLDER"
GITHUB_TOKEN="GH TOKEN PLACEHOLDER"

CycloneDX $PROJECT_PATH --set-name "$REPORT_TITLE" --set-version "$REPORT_VERSION" --set-type "Application" --github-username "$GITHUB_USERNAME" --github-token "$GITHUB_TOKEN" -o "$REPORT_OUTPUT_FOLDER" -f "$REPORT_FILENAME"