Changing the color of a Wiz lightbulb from Rust.

After setting up the device to accept local communication we can control the smart devices by sending a UDP packet. You can do it via NC or by making a program. There is a nice Python library for this as well.

I'm going to list quick examples here for NC, Bash and Rust.

NC:

 echo -n '{"id":1,"method":"setPilot","params":{"r":85,"g":85,"b":85,"dimming":100}}' | nc -4u -w1 192.168.5.106 38899

Bash:

 echo -n '{"id":1,"method":"setPilot","params":{"r":200,"g":12,"b":85,"dimming":100}}' > /dev/udp/192.168.5.106/38899

Rust:

fn main() {
  // Create the UDP socket
  let socket = UdpSocket::bind("0.0.0.0:0").unwrap(); // Bind to an available local port
  let target = "192.168.5.106:38899";
  let mut rng = rand::thread_rng();

  let r: u8 = rng.gen_range(0..=255);
  let g: u8 = rng.gen_range(0..=255);
  let b: u8 = rng.gen_range(0..=255);

  let message2 = format!(r#"{{"id":1,"method":"setPilot","params":{{"r":{},"g":{},"b":{},"dimming":100}}}}"#,r,g,b);
  socket.se[...]

Admission Webhook Kubernetes

Kubernetes admission webhooks are a powerful mechanism for customizing and controlling the behavior of your Kubernetes cluster at runtime. By intercepting requests to the Kubernetes API server, admission webhooks allow you to validate, mutate, or even reject operations like pod creation, service modifications, and more. Whether you're enforcing security policies, applying default configurations, or ensuring compliance with custom standards, admission webhooks give you the flexibility to tailor your Kubernetes environment to your organization’s needs. In this article, we’ll explore how to set up and leverage Kubernetes admission webhooks to enhance your cluster management.

Generate Certificates

Generating certificates is the most important step in creating your own custom admission controller. This allows the Kubernetes control plane to trust your web server. If the certificate is not trusted by Kubernetes the webhook calls will fail. I like to use Cloudflare's cfssl tool to gener[...]

Micro VM - Firecracker

NOTE: The below blog are notes from a while ago on when I started messing with MicroVM's. These may work now, may not be understandable. I wanted to get these on internet to hopefully help someone else. I am still working on MicroVM's. My method has changed slightly and I do not use Firecracker now.

microVM's are awesome!

They are good for situations where you need to run untrusted code and you need kernel isolation. They are ideal for running multiple secure workloads concurrently on a single machine. There are multiple platforms but this document will focus on Firecracker. Built by AWS for their serverless services.

Installing Firecracker

You can either compile from source or download the latest release from the link below. https://github.com/firecracker-microvm/firecracker/releases/ Make it executable and copy to /usr/bin.

Download

curl -LOJ https://github.com/firecracker-microvm/firecracker/releases/download/v1.14.0/firecracker-v1.14.0
mv firecrac[...]

Getting the expiration date of a TLS certificate inside of Kubernetes.

I had a use case to pull the expiration date from a TLS certificate from inside of Kubernetes.

The below command will output the expiration date of the certificate. Replace NAMESPACE and CERTNAME with the correct values.



kubectl -n NAMESPACE get secret CERTNAME -o "jsonpath={.data['tls\.crt]}" | base64 -D | openssl x509 -enddate -noout





Happy Hacking![...]

Setting up a Kubernetes cluster at home

Working with Kubernetes

How can I use Kubernetes at home?

There are several ways that you can practice kubernetes. Spin up cloud resources, K3S, or my favorite K3d.

K3d is a wrapper around K3s, which run in docker container(s). This allows you to quickly deploy and destory clusters. It also allows you to have multi-node clusters, within a single host, to allow you to see how failover and other high availability services work.

Okay, How can I get started?

First you will need Docker installed. I will not be going over that in this document. Please refer to my other container documents. [links coming soon].

Next will be to install the k3d toolset. This can be accomlplished by the following command.

curl -s https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh | bash

Important: As always, please review the script before piping to bash. This could lead to bad things.

Now the hard part. Creating the cluster. Lets create a cluster called[...]