Skip to content

Instantly share code, notes, and snippets.

View lamw's full-sized avatar

William Lam lamw

View GitHub Profile
@lamw
lamw / kubedoom.yaml
Created September 7, 2023 16:03
k8s manifest for kubedoom running on Project Keswick
apiVersion: v1
kind: Namespace
metadata:
name: kubedoom
labels:
app: kubedoom
---
apiVersion: v1
kind: ServiceAccount
metadata:
@lamw
lamw / manual_vsphere_content_library_sync.ps1
Created June 14, 2023 00:01
Manually sync all items in a vSphere Content Library using the vCenter Server REST API and PowerCLI
Connect-CISServer -Server vcsa.primp-industries.local -User administrator@vsphere.local -Password VMware1!
# Name of your Content Library
$content_library_name = "TKG-Content-Library"
$contentLibraryService = Get-CisService com.vmware.content.library
$contentLibraryItemService = Get-CisService com.vmware.content.library.item
$subscribedLibraryItemService = Get-CisService com.vmware.content.library.subscribed_item
# Find Content Library matching name
@lamw
lamw / vsan-object-viewer.yaml
Last active May 17, 2023 21:19
Deploy vSAN Object Viewer Fling into K8s Cluster OR as vSphere Pod
apiVersion: apps/v1
kind: Deployment
metadata:
name: vsan-object-viewer-fling
spec:
replicas: 1
selector:
matchLabels:
app: vsan-object-viewer-fling
template:
@lamw
lamw / gist:0f04ac8cd9df35d42c9b8bd700ef9ece
Created October 21, 2022 11:23
Query & Re-Enable vSphere Cluster Quick Start from VCDB
# vSphere QuickStart can not be re-enabled after workflow has been Abandoned https://vdc-download.vmware.com/vmwb-repository/dcr-public/c476b64b-c93c-4b21-9d76-be14da0148f9/04ca12ad-59b9-4e1c-8232-fd3d4276e52c/SDK/vsphere-ws/docs/ReferenceGuide/vim.ClusterComputeResource.html#AbandonHciWorkflow
# QuickStart state is stored in 'hci_workflow_state' property which is not configurable outside of messing w/VCDB
# The following is NOT recommended but for information/learning purposes
# 1. Retrieve the ID value from your vSphere Cluster MoRef (e.g. domain-c84065)
# 2. Connect to VCDB
# Query vSphere Cluster for QuickStart state 'hci_workflow_state'
select * from vpx_hci_config_info where cluster_id = '84065';
@lamw
lamw / bluetooth-monitor.sh
Created August 22, 2022 20:00
Script to check the Apple keyboard/mouse battery percent
#!/usr/bin/env bash
PATH=/usr/local/bin:/usr/local/sbin:~/bin:/usr/bin:/bin:/usr/sbin:/sbin
# actual battery level
MOUSE_BATT=$(ioreg -c AppleDeviceManagementHIDEventService -r -l | grep -i mouse -A 20 | grep BatteryPercent | cut -d= -f2 | cut -d' ' -f2)
KEYBOARD_BATT=$(ioreg -c AppleDeviceManagementHIDEventService -r -l | grep -i keyboard -A 20 | grep BatteryPercent | cut -d= -f2 | cut -d' ' -f2)
COMPARE=${1:-20}
if (( MOUSE_BATT < COMPARE )); then
@lamw
lamw / gist:bda4820e33532319423e6669c73af905
Created March 4, 2022 14:02
PowerCLI Ubuntu Dockerfile
FROM mirror.gcr.io/library/ubuntu:bionic
ENV TERM linux
WORKDIR /root
ARG POWERCLI_VERSION="12.4.0.18633274"
RUN echo "/usr/bin/pwsh" >> /etc/shells && \
echo "/bin/pwsh" >> /etc/shells && \
apt update && \
@lamw
lamw / gist:f3a3b7134c03b2d945d741a250c3f05f
Created March 1, 2022 15:55
PowerCLI snippet to map PVC to vSphere Datastore
$volumes = Get-CnsVolume
$results = @()
foreach ($volume in $volumes) {
$entityDetails = $volume.ExtensionData.Metadata.EntityMetadata | where {$_.EntityType -eq "PERSISTENT_VOLUME_CLAIM"}
if($entityDetails) {
$tmp = [pscustomobject] @{
VolumeName = $volume.name;
PVCName = $entityDetails.EntityName;
Namespace = $entityDetails.Namespace;
Datastore = $volume.datastore.name;
@lamw
lamw / gist:f66f1ca6c059b2852f03adb0d627abf2
Created October 26, 2021 13:50
vSphere w/Tanzu ClusterRole Edit
root@42294959c845d4be8507807dd2d100d0 [ ~ ]# k get clusterrole edit -o yaml
aggregationRule:
clusterRoleSelectors:
- matchLabels:
rbac.authorization.k8s.io/aggregate-to-edit: "true"
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
annotations:
@lamw
lamw / gist:086320a7545c47b802a4db3127d91b27
Created October 26, 2021 13:49
vSphere w/Tanzu ClusterRole View
root@42294959c845d4be8507807dd2d100d0 [ ~ ]# k get clusterrole view -o yaml
aggregationRule:
clusterRoleSelectors:
- matchLabels:
rbac.authorization.k8s.io/aggregate-to-view: "true"
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
annotations:
@lamw
lamw / configstore_esxi70u2.json
Created July 19, 2021 16:19
Schema for ConfigStore in ESXi 7.0 Update 2
{
"clusterstore": {
"cluster_agent": [
"agent_settings"
]
},
"esx": {
"assignhw": [
"overrides"
],