Skip to content

Instantly share code, notes, and snippets.

View raykao's full-sized avatar
🇨🇦
¯\_(ツ)_/¯

Raymond Kao raykao

🇨🇦
¯\_(ツ)_/¯
View GitHub Profile
resource "azurerm_user_assigned_identity" "cluster" {
location = azurerm_resource_group.example.location
name = "aks-cluster-identity-${var.cluster_uid}"
resource_group_name = azurerm_resource_group.example.name
}
resource "azurerm_user_assigned_identity" "kubelet" {
location = azurerm_resource_group.example.location
name = "aks-kubelet-identity-${var.cluster_uid}"
resource_group_name = azurerm_resource_group.example.name
@raykao
raykao / get-kube-config.sh
Created September 16, 2021 01:34
used for demo environment
#!/bin/bash
# Wait for cloud-init to finish
while [ ! -f /tmp/cloud-init-done ]; do echo 'Waiting for cloud-init to complete.';sleep 5; done
ssh -o "StrictHostKeyChecking no" $USER@$CONTROL_HOST 'sudo cp /etc/rancher/k3s/k3s.yaml ~/;sudo chown $USER:$USER k3s.yaml'
mkdir .kube
scp -o "StrictHostKeyChecking no" $USER@$CONTROL_HOST:~/k3s.yaml ./.kube/config
chmod 640 ~/.kube/config
sed -i 's/127.0.0.1/'$CONTROL_HOST'/g' ./.kube/config
@raykao
raykao / Dockerfile
Created January 21, 2021 18:35
Azure Function Custom Runtime Container for Ruby app
# To enable ssh & remote debugging on app service change the base image to the one below
FROM mcr.microsoft.com/azure-functions/dotnet:3.0-appservice
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
# skip installing gem documentation
RUN set -eux; \
mkdir -p /usr/local/etc; \
{ \
# Lookup TZ
timedatectl list-timezones
# Set TZ
sudo timedatectl set-timezone America/Toronto
@raykao
raykao / fw-whitelist-fqdns.txt
Created May 10, 2020 02:46
Azure Ubuntu Update FQDNs - Required FQDNs for Ubuntu Linux Updates. These FQDNs are necessary for the operation of a given Ubuntu VM.
target_fqdns = [
"azure.archive.ubuntu.com",
"security.ubuntu.com",
]
@raykao
raykao / powerline-fonts.ps1
Created December 7, 2019 05:04
Powerline fonts
git clone https://github.com/powerline/fonts.git --depth=1
cd fonts
.\install.ps1
cd ..
rd /S /Q fonts
trigger:
- master
variables:
- group: akv-credentials
pool:
vmImage: 'ubuntu-latest'
steps:
module "subnet" {
source = "./subnet_module.tf"
}
resource "azurerm_virtual_machine" "some_name" {
...
depends_on = module.subnet
subnet_id = module.subnet.id
}
@raykao
raykao / batcherize.js
Created August 20, 2019 02:06
Turn an array into an array of arrays...to batch process some data.
function batcherize(batchSize, unbatchedData) {
const batchedData = [];
const batchNumber = Math.ceil(unbatchedData.length/batchSize)
for (let batchIndex = 0; batchIndex < batchNumber; batchIndex++) {
const currentBatchPosition = (batchIndex * batchSize);
const currentBatchOffset = currentBatchPosition + (batchSize);
const currentBatchData = unbatchedData.slice(currentBatchPosition, currentBatchOffset);
batchedData.push(currentBatchData);