Skip to content

Instantly share code, notes, and snippets.

View lrakai's full-sized avatar

Logan Rakai lrakai

View GitHub Profile
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDBL2soKeIWpxf+
ywATxUqdAnOB4OnNhNla1hWkuawQtgO8cfstsGMInOuXMPPCQ+WxSLjAo2goQDYK
wmYoYmgbpUyx87jRlnqMAIlz+jIJLjnpRLwV8Rkw8hfo6WJEe7c+5wwlLj5cNHnB
XTQtMDaf1Mt9hL9XhLjGgzfEWDcBx3zPVB1s/euX94CV3qpU032a63JNFY7F6L2i
AGOMFt8yQ2MszKF7B5mFTdZbzXQT9HASDWcX49OKG6RN5HNHDK6y44ROMz1NQPtX
neSTe3s31mfiGIAnUVbqysYvH17O1uRGzS1uM0873hlS2r4KJ79tXgNeSR6f7PCf
2bsJFOyPAgMBAAECggEBAJtkdSF9byshhR+iUpGUpQveqOLT870pG10Bz68M2ucm
QaMXXB/IPiDzeF3JNooQ63XLNTFfP60A2XeWH25kmbGDKUoK7aNJE5IB7I6ptg3E
bTjB3TkZElZYpfrnn+/OQ/wJBa/ynp60ZyuuuQWQPqAaHwT7/p17WNX1Pqpk+vom
@lrakai
lrakai / azure-deploy.json
Created December 12, 2019 03:48
Original Template From 2017
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"virtualMachineName": {
"type": "string",
"defaultValue": "ca-lab-vm"
},
"virtualMachineSize": {
"type": "string",
@lrakai
lrakai / azure-deploy.json
Created December 11, 2019 22:26
Template causing PowerShell to block on startup until custom script extension completes
{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"virtualMachineName": {
"type": "string",
"defaultValue": "ca-lab-vm"
},
"virtualMachineSize": {
"type": "string",
@lrakai
lrakai / Copy-ManagedDisk.ps1
Last active December 5, 2019 17:06
AzureNestedHyperVPriv
#Provide the subscription Id where managed disk is created
# subscriptionId=yourSubscriptionId # omit for use in Azure Cloud Shell
# az account set --subscription $subscriptionId
#Provide the name of your resource group where managed disk is created
resourceGroupName=QACA
#Provide the managed disk name
diskName=ca-lab-vm_OsDisk_1_b5b39d9313ec4ce3aa8ace3889dcce9b
@lrakai
lrakai / lambda-aws-ssm-run-command-on-ec2-instance.py
Last active January 9, 2024 16:29
Run commands on EC2 instances using Lambda and Systems Manager (SendCommand)
import boto3
import botocore
import time
def handler(event=None, context=None):
client = boto3.client('ssm')
instance_id = 'i-07362a00952fca213' # hard-code for example
response = client.send_command(
@lrakai
lrakai / delete_all_awslogs.sh
Created January 18, 2019 22:26 — forked from pahud/delete_all_awslogs.sh.md
delete all aws log groups
aws logs describe-log-groups --query 'logGroups[*].logGroupName' --output table | awk '{print $2}' | grep -v ^$ | while read x; do aws logs delete-log-group --log-group-name $x; done
@lrakai
lrakai / Remove-StorageSyncServiceResources.ps1
Last active January 2, 2019 23:55
Remove Azure Storage Sync Service Resources
# Must run on a Windows Server with Azure File Sync Agent and Azure PowerShell module installed
function Login-Azure {
param (
[string]$username,
[string]$password # Use [secureString] outside of secure environments
)
# Convert password to secure string (required for creating login credential)
$securePassword = ConvertTo-SecureString -String $password -AsPlainText -Force
@lrakai
lrakai / Get-AzureToken
Last active December 6, 2018 18:13
Get Azure Token in PowerShell
# Azure Authtentication Token
# From https://blogs.technet.microsoft.com/stefan_stranger/2016/10/21/using-the-azure-arm-rest-apin-get-access-token/
#requires -Version 3
#SPN ClientId and Secret
$ClientID = "clientid" #ApplicationID
$ClientSecret = "ClientSecret" #key from Application
$tenantid = "TenantID"
@lrakai
lrakai / script.sh
Last active September 2, 2018 07:30
Testing Kubernetes Descheduler to rebalance ala https://stackoverflow.com/q/52106831/5894196
# Note I used 2 t2.micro EC2 instances with 1gb memory each as worker nodes
# 1gb in the OP maps to 440Mi (~50%) in the example
kubectl run pod1 --image=nginx --requests=memory=440Mi
kubectl run pod3 --image=nginx --requests=memory=440Mi
kubectl run pod4 --image=nginx --requests=memory=100Mi
kubectl run pod2 --image=nginx --requests=memory=100Mi
# The scheduler will alternate each deployment's pod to each of the two nodes like in the OP
@lrakai
lrakai / cloudformation-new-vpc.template
Last active August 8, 2018 08:04
AWS k8s cluster CloudFormation template with VPC (flattened to remove nested stacks)
# Copyright 2017 by the contributors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,