Skip to content

Instantly share code, notes, and snippets.

View queil's full-sized avatar

queil queil

View GitHub Profile
@queil
queil / Reclaim WSL2 memory
Created November 30, 2020 14:50
Reclaim WSL2 memory
# source https://devblogs.microsoft.com/commandline/memory-reclaim-in-the-windows-subsystem-for-linux-2/
# as root
echo 1 > /proc/sys/vm/drop_caches
echo 1 > /proc/sys/vm/compact_memory
@queil
queil / gist:72618b8e5116d0c87d4d25e209dca6e5
Created November 26, 2020 10:58
Kubernetes: find pod's memory cgroup on the node
# get pod uid
k get po pod-name -o jsonpath='{.metadata.uid}'
# then assuming your pod is burstable then the cgroup will be that:
/sys/fs/cgroup/memory/kubepods.slice/kubepods-burstable.slice{your pod uid with underscores rather than hyphens}
@queil
queil / openssl.sh
Last active October 27, 2020 12:07
Self-signed cert with Client Auth / Server Auth extensions
openssl req -x509 -newkey rsa:2048 -keyout my.domain.key -out my.domain.pem -days 3650 -subj '/CN=*.my.domain' -nodes -addext 'extendedKeyUsage=1.3.6.1.5.5.7.3.2,1.3.6.1.5.5.7.3.1'
openssl x509 -inform pem -in my.pem -outform der -out my.cer
@queil
queil / killAllJobs.groovy
Last active October 26, 2020 15:03
Jenkins: kill all jobs
Jenkins.instance.getAllItems(AbstractItem.class)
.findAll {job -> job.fullName.matches("your-job-regex")}
.each { job -> job.getLastBuild().doKill() }
@queil
queil / example.txt
Last active October 14, 2020 16:18
Octopus Deploy supports conditionals in Release Template
#{Octopus.Version.Channel.LastMajor}.#{Octopus.Version.Channel.LastMinor}.#{Octopus.Version.Channel.LastPatch}#{if Octopus.Version.Channel.LastSuffix != "-" }#{Octopus.Version.Channel.LastSuffix}#{/if}.#{Octopus.Version.Channel.NextBuild}
@queil
queil / script.sh
Created October 13, 2020 13:41
Delete Kubernetes namespace that gets stuck in finalizing
# first must run kubectl proxy in a separate terminal
kubectl proxy
# then run this (replace delete-me)
kubectl get ns delete-me -o json | \
jq '.spec.finalizers=[]' | \
curl -X PUT http://localhost:8001/api/v1/namespaces/delete-me/finalize -H "Content-Type: application/json" --data @-
@queil
queil / runAllJobs.groovy
Created July 14, 2020 13:35
Jenkins: run all the jobs matching a regex
// This can be executed in the master node script console
Jenkins.instance.getAllItems(AbstractItem.class)
.findAll {job -> job.fullName.matches("^(a|b).*/master")}
.each { job ->
def actions = [new CauseAction(new Cause.UserIdCause()), new ParametersAction(new BooleanParameterValue("X", true))] as Action[]
job.scheduleBuild2(0, actions)
};
@queil
queil / posh-k8s.ps1
Last active November 3, 2021 13:05
posh k8s
function k8s() {
$Cache = @{Names=@{}}
function makectx {
@{
Namespace = "default"
Ctx = $(kubectl config current-context)
Current = @{Name = $null; TypeAlias=$null}
}
(dotnet list package --outdated | Select-String ".*(> )([a-zA-Z\.]+).*").Matches | % {dotnet add package $_.Groups[2].Value}