Skip to content

Instantly share code, notes, and snippets.

View rleap-m's full-sized avatar

Ryan Leap rleap-m

  • Mirantis
  • Raleigh, NC
View GitHub Profile
@rleap-m
rleap-m / mke4_admin_password_update.sh
Created November 15, 2024 14:22
MKE4 change admin password by changing password hash
# Courtesy Dmitrii in a Slack channel
NAME=admin
NEW_PASSWORD=mke4mke4mke4
export HASHED=$(htpasswd -nbBC 10 '' "$NEW_PASSWORD" | tr -d ':\n' | base64)
alias km="kubectl -n mke --kubeconfig ~/.mke/mke.kubeconf"
km get password $(km get password -o jsonpath="{.items[?(@.email=='$NAME')].metadata.name}") -oyaml | yq '.hash = strenv(HASHED)' | km -n mke apply -f -
function verboseLog {
Write-Verbose "$args"
}
function getContainerdVer {
if (Get-Command "ctr.exe" -ErrorAction SilentlyContinue)
{
$tmp = ctr -v|Out-String
if ($LASTEXITCODE -eq 0) {
@rleap-m
rleap-m / trend-memory-on-windows-report.ps1
Created November 13, 2024 16:16
Shows increase (or decrease) in memory usage for processes over time
[CmdletBinding()]
param (
[Parameter(Mandatory=$true)]
[ValidateScript({Test-Path -Path $_ -PathType Leaf})]
[string]
$ReportPath,
[Parameter(Mandatory=$false)]
[int]
$EntryCount = 10
@rleap-m
rleap-m / create_mke_cluster_admin_kubeconfig_files.sh
Last active November 13, 2024 20:34
Creates kubeconfig files for MKE (Mirantis Kubernetes Engine) admin users based on their clusterrolebinding to the 'cluster-admin' role
#!/bin/bash
show_help() {
echo "Usage: $0 [--expires-in-days <days> | -e <days>] [--output-dir <directory> | -o <directory>] [-h|--help]"
echo ""
echo "Purpose: This script creates kubeconfig files for MKE (Mirantis Kubernetes Engine) admin users"
echo " based on their clusterrolebinding to the 'cluster-admin' role."
echo ""
echo "Options:"
echo " -h, --help Show this help message"
@rleap-m
rleap-m / myinvocation_test.ps1
Last active October 24, 2024 21:15
Seeing how this $MyInvocation PowerShell thing works.
Write-Host "`$MyInvocationInvocationName value is [$($MyInvocation.InvocationName)]"
Write-Host "`$MyInvocation.Line value is [$($MyInvocation.Line)]"
Write-Host "`$MyInvocation.Line is null? [$($null -eq $MyInvocation.Line)]"
Write-Host "`$MyInvocation.Line is empty string? [$('' -eq $MyInvocation.Line)]"
Write-Host
if (-Not ($MyInvocation.InvocationName -eq '.' -or $MyInvocation.Line -eq '')) {
Write-Host "I'm gonna run the installer!"
}
else {
Write-Host "Not going to run the installer. :-("
@rleap-m
rleap-m / install.ps1
Last active October 29, 2024 13:57
MCR Installer for Windows with customized genUrlFromVersionAndChannel function (resolves to latest build) and workaround for ENGINE-1050 (WinRM)
#!/usr/bin/env pwsh
#
# This script is meant for quick & easy install on Windows via an elevated command prompt:
#
# PS>Invoke-WebRequest -Uri get.mirantis.com/install.ps1
# PS>Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process
# PS>.\install.ps1
#
# To obtain explicit versions of the script, append version number after replacing
# '.' and '-' characters in version with '_':
@rleap-m
rleap-m / Invoke-McrGenUrlRoutine.ps1
Last active October 24, 2024 19:09
Wrapper script for 'genUrlFromVersionAndChannel' function with support for v25 versioning and resolving to latest pre-release build
<#
.SYNOPSIS
Wrapper script for 'genUrlFromVersionAndChannel' function with support for v25 versioning and resolving to latest
pre-release build
.PARAMETER DownloadUrl
Specify the URL from which to obtain the package
.PARAMETER Channel
Specify the release channel like 'test' or 'stable', etc.
.PARAMETER DockerVersion
Specify the docker version you intend to install
@rleap-m
rleap-m / check_ports.sh
Last active October 9, 2024 16:41
Checks the status of specified ports on a system output as columnar data including protocol, local address, process name, and PID
#!/bin/bash
# Port Checker Script
# This Bash script checks the status of specified network ports on a system.
# It utilizes the `ss` command to determine if each port is being listened to
# and retrieves associated process information, including the protocol (Netid),
# local address, process name, and PID. The output is formatted in a columnar
# structure for easy reading. The script requires elevated privileges to access
# process information.
#
@rleap-m
rleap-m / mke3_ports_not_used_by_mke4.ps1
Created October 3, 2024 21:15
Cross references port requirements of MKE3 with ports denoted as unused by MKE4
$mke4WarnPortsMsg = 'WRN The following MKE3 ports are no longer used by MKE4 and (unless otherwise needed) may be made unavailable on all nodes: [2377,6444,7946,12376,12378,12381,12382,12383,12384,12385,12386,12387,12388,12389,12391,12392,179,12390,2376,443]'
$mke4PortsNotUsed = [regex]::matches($mke4WarnPortsMsg, '(?<=\[)[^\]]+(?=\])').Value -split ',' | ForEach-Object { [int] $_ } | Sort-Object
$mke3PortList = @"
[
{
"Role":["manager","worker"],
"Port": "179",
"Protocol": "TCP",
@rleap-m
rleap-m / Get-NodeLabel.ps1
Last active September 24, 2024 20:24
Gets the labels associated with each node
<#
.SYNOPSIS
Gets the labels associated with each node
.PARAMETER NodeName
Specify a single node (if not provided all nodes returned)
.PARAMETER Flatten
Flattens out the labels such that there is a node object returned per label
#>
[CmdletBinding()]
param (