Changing the color of a Wiz lightbulb from Rust.
I use Wiz lightbulbs for lights that I want to control remotely and has the ability to control from a local protocol. I don't want to depend on the internet and cloud working.
After setting up the device to accept local communication we can control the smart devices by sending a UDP packet. You can send a UDP packet via NC(netcat) or by making a program in a language such as Rust. 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.[...]
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 working with MicroVM's. When you are reading this the steps may work or not. I wanted to get these on internet to hopefully help someone else. While I am still learning about 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 want and need kernel isolation. MicroVM's are ideal for running multiple secure workloads concurrently on a single machine. There are multiple solutions 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/
Download Script
curl -LOJ https://github.com/firecracker-microvm/firecracker/releases/download/v1.14.0/firecracker-v1.14.0
mv firecrack[...]
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[...]
Creating a SystemD service to run a self hosted devops agent.
I have the need to run an Azure Devops Agent as a systemD. Typcially I would just run it inside a container. But due to requirements on this system and pipeline I am unable to simply run inside a container. The belows assumes you have an agent already setup. Lets get started.
Creating the service file
First, lets go over the structure of a systemd service file.
There are three important sections. They are [Unit], [Service], and [Install]. The extension is .service and we can make comments with the hash symbol(#).
Lets create a file
[Unit]
Description=Devops Service
After=multi-user.target
[Service]
ExecStart=/home/[username]/myagent/run.sh
WorkingDirectory=/home/[username]/myagent/
User=opc
Group=opc
Restart=always
Type=simple
[Install]
WantedBy=default.target
What does each section do?
The [Unit] section helps describe the service and when to start it. In this case we want to ensure the network is up before starting the service. You can include an [...]