Skip to content

Instantly share code, notes, and snippets.

apiVersion: v1
kind: ServiceAccount
metadata:
name: hubble-ui
namespace: kube-system
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: hubble-ui
@PixelRobots
PixelRobots / nodeVersion-check
Created September 15, 2023 07:21
Resource Graph- get nodeVersion of AKS clusters
resources
| where type == "microsoft.containerservice/managedclusters"
| mv-expand agentpool=properties.agentPoolProfiles
| extend nodeVersion = tostring(agentpool.nodeImageVersion)
| where nodeVersion startswith "AKSUbuntu"
| extend nodePoolName = tostring(agentpool.name)
| project clusterName = name, tenantId, subscriptionId, nodePoolName, nodeVersion
az k8s-extension create \
--resource-group rg-aks-pixelland-weu \
--cluster-name aks-pixelland-weu \
--name flux \
--extension-type microsoft.flux \
--cluster-type managedClusters \
--auto-upgrade-minor-version true \
--config toleration-keys="CriticalAddonsOnly=true:NoSchedule"
AZURE_SUBSCRIPTION_ID=$(az account show --query "id" --output tsv)
AZURE_NODE_RESOURCE_GROUP=$(az aks show --resource-group ${AZURE_RESOURCE_GROUP} --name ${NAME} --query "nodeResourceGroup" --output tsv)
AZURE_SERVICE_PRINCIPAL=$(az ad sp create-for-rbac --scopes /subscriptions/${AZURE_SUBSCRIPTION_ID}/resourceGroups/${AZURE_NODE_RESOURCE_GROUP} --role Contributor --output json --only-show-errors)
AZURE_TENANT_ID=$(echo ${AZURE_SERVICE_PRINCIPAL} | jq -r '.tenant')
AZURE_CLIENT_ID=$(echo ${AZURE_SERVICE_PRINCIPAL} | jq -r '.appId')
AZURE_CLIENT_SECRET=$(echo ${AZURE_SERVICE_PRINCIPAL} | jq -r '.password')
az aks get-credentials --resource-group rg-aks-byo-cni-dev --name aks-byo-cni-dev
helm install cilium cilium/cilium --version 1.11.3 \
@PixelRobots
PixelRobots / capturehelmkubectloutput.ps1
Created October 26, 2021 13:14
capture helm and kubectl output to a variable
$command = $(helm uninstall me 2>&1)
if ($command -match 'error' ) {
write-host "error = $command" -ForegroundColor Red
}
$command = $(kubectl apply -f me.yaml 2>&1)
@PixelRobots
PixelRobots / pixelrobots.json
Last active January 8, 2022 11:28
pixelrobots oh my posh theme
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"final_space": true,
"console_title": true,
"console_title_style": "template",
"console_title_template": "{{if .Root}}root :: {{end}}{{.Shell}} :: {{.Folder}}",
"blocks": [
{
"type": "prompt",
"alignment": "left",
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"type": "string",
"metadata": {
"description": "AKS cluster name"
}
},
$sp = New-AzADServicePrincipal -DisplayName RabbitMQScale
$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sp.Secret)
$UnsecureSecret = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)
$AppID = (Get-AzADServicePrincipal -DisplayName RabbitMQScale).ApplicationID
New-AzRoleAssignment -ApplicationId $AppID -RoleDefinitionName "Contributor"
Write-host "Client ID =" $AppID
Write-host "Client Secret =" $UnsecureSecret
Write-host " Tenant =" (Get-AzContext).Tenant.Id
{
"properties": {
"arguments": {
"properties": {
"x-dead-letter-exchange": {
"type": [
"string",
"object",
"number",
"integer",
// Table of Servers with disk space is under nnGB
let setGBValue = 20;
// enter a GB value to check
let startDate = ago(30m);
// enter how many minutes to look back on
Perf
| where InstanceName != "D:" and InstanceName contains ":"
| where TimeGenerated > startDate
| where ObjectName == "LogicalDisk" and CounterName == "Free Megabytes"
| extend FreeSpaceGB = CounterValue/1024