Skip to content

Instantly share code, notes, and snippets.

@max-rocket-internet
max-rocket-internet / prom-k8s-request-limits.md
Last active April 15, 2024 08:06
How to display Kubernetes request and limit in Grafana / Prometheus properly

CPU: percentage of limit

A lot of people land when trying to find out how to calculate CPU usage metric correctly in prometheus, myself included! So I'll post what I eventually ended up using as I think it's still a little difficult trying to tie together all the snippets of info here and elsewhere.

This is specific to k8s and containers that have CPU limits set.

To show CPU usage as a percentage of the limit given to the container, this is the Prometheus query we used to create nice graphs in Grafana:

sum(rate(container_cpu_usage_seconds_total{name!~".*prometheus.*", image!="", container_name!="POD"}[5m])) by (pod_name, container_name) /
@jbratu
jbratu / setupiisforsslperfectforwardsecrecy_v17.ps1
Last active April 7, 2024 19:39
Great powershell script for tightening HTTPS security on IIS and disabling insecure protocols and ciphers. Very useful on core installations.
# Copyright 2019, Alexander Hass
# https://www.hass.de/content/setup-microsoft-windows-or-iis-ssl-perfect-forward-secrecy-and-tls-12
#
# After running this script the computer only supports:
# - TLS 1.2
#
# Version 3.0.1, see CHANGELOG.txt for changes.
Write-Host 'Configuring IIS with SSL/TLS Deployment Best Practices...'
Write-Host '--------------------------------------------------------------------------------'
@noseka1
noseka1 / How to approve OpenShift operator upgrade using CLI.md
Last active April 4, 2024 09:15
How to approve OpenShift operator upgrade using CLI

Install the operator using the Manual approval strategy, see the attached screenshot.

An install plan has been created but not executed as it has not been approved:

oc get installplan -n openshift-logging
NAME            CSV                                    APPROVAL   APPROVED
install-dq68d   clusterlogging.4.5.0-202007012112.p0   Manual     false
@lnattrass
lnattrass / get_tds_cert.py
Last active February 29, 2024 18:38
A terrible way to connect to MS SQL Server and dump the certificate as a PEM
import sys
import pprint
import struct
import socket
import ssl
from time import sleep
# Standard "HELLO" message for TDS
prelogin_msg = bytearray([ 0x12, 0x01, 0x00, 0x2f, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x06, 0x01, 0x00, 0x20,
0x00, 0x01, 0x02, 0x00, 0x21, 0x00, 0x01, 0x03, 0x00, 0x22, 0x00, 0x04, 0x04, 0x00, 0x26, 0x00,
@svarukala
svarukala / Get-AzureADAppsInfo.ps1
Last active May 10, 2023 19:38
Outputs list of all Azure AD Apps along with their expiration date, display name, owner email, credentials (passwordcredentials or keycredentials), start date, key id and usage. Useful to know the apps that are expiring and take action (renew). Since Azure AD PowerShell is being deprecated in favor of Microsoft Graph PowerShell SDK, I created a …
# Requires Azure AD PowerShell Module
#Prompts user to login using Azure Credentials
Connect-AzureAD
$results = @()
Get-AzureADApplication -All $true | %{
$app = $_
$owner = Get-AzureADApplicationOwner -ObjectId $_.ObjectID -Top 1
@TiloGit
TiloGit / shaw-compress.sh
Created December 3, 2022 00:19
compress and rename shaw PDFs
##for PDF invoices with filename like ShawInvoice_01412345678_01Apr2022.pdf
for file in Shaw*.pdf
do
echo "$(date +"%F_%s") Start $file"
filedate=$(basename "$file" .pdf | tail -c 10)
outFdate=$(date -d $filedate +"%F")
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -dCompatibilityLevel=1.5 -dPDFSETTINGS=/ebook -sOutputFile=${outFdate}_${file} $file
echo "$(date +"%F_%s") Done $file"
done
@Stephanevg
Stephanevg / createRandomFiles.ps1
Last active October 3, 2022 17:30
This function will create random files. It allows you to select the total size all the files together must have, and the number of individual files to create in total. (for example, A total of 5GB in 100 different files). The main advantage of this function is that it will create files with human understandeble names (and if your lucky, funny na…
Function Create-RandomFiles{
<#
.SYNOPSIS
Generates a number of dumb files for a specific size.
.DESCRIPTION
Generates a defined number of files until reaching a maximum size.
.PARAMETER Totalsize
Specify the total size you would all the files combined should use on the harddrive.
@tomasaschan
tomasaschan / aks-restart-nodes.sh
Last active August 30, 2022 17:45
Rolling restart of all nodes in an AKS cluster
#!/bin/bash
set -e
resourceGroupDefault='<set your default here, to avoid having to specify in the common case>'
resourceGroup=${RESOURCE_GROUP:-$resourceGroupDefault}
clusterNameDefault='<set your default here>'
clusterName=${CLUSTER_NAME:-$clusterNameDefault}
regionDefault='<set your default here>'
region=${REGION:-$regionDefault}
@mislav
mislav / gh-rename-master
Last active April 24, 2022 10:02
Rename the default branch of a repository using GitHub CLI https://github.com/cli/cli/releases/tag/v0.10.0
#!/bin/bash
# Usage: gh-rename-master <newbranch> [<remote>]
#
# Renames the "master" branch of the current repository both locally and on GitHub.
#
# dependencies: GitHub CLI v0.10
set -e
newbranch="${1?}"
remote="${2:-origin}"