Skip to content

Instantly share code, notes, and snippets.

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

Raymond Kao raykao

🇨🇦
¯\_(ツ)_/¯
View GitHub Profile
@raykao
raykao / run_consul.sh
Created April 5, 2019 05:44
Work around for using Azure Managed Service Identities to discover Consul Server IP addresses. Waiting for [this](https://github.com/hashicorp/go-discover/pull/102) PR on go-discover to be approved
## The Env Vars
# AZURE_SUBSCRIPTION_ID
# CONSUL_VMSS_RG
# CONSUL_VMSS_NAME
## were prepended to this script at provisioning time with Terraform via custom_data/cloud-init
AZURE_MSI_ENDPOINT="http://169.254.169.254/metadata/identity"
AZURE_MSI_OAUTH=$(curl -H "Metadata:true" $AZURE_MSI_ENDPOINT"/oauth2/token?api-version=2018-02-01&resource=https%3A%2F%2Fmanagement.azure.com%2F")
AZURE_MSI_JWT=$(echo $AZURE_MSI_OAUTH | jq -r '.access_token')

Keybase proof

I hereby claim:

  • I am raykao on github.
  • I am raykao (https://keybase.io/raykao) on keybase.
  • I have a public key ASB1OgQWgG4JUJOHAv70PW8fEe3X6JWJkrpd1146kA4TpAo

To claim this, I am signing this object:

apiVersion: v1
kind: Service
metadata:
name: bobble
labels:
name: bobble
spec:
type: LoadBalancer
ports:
- name: http
@raykao
raykao / azuregfs.sh
Last active February 20, 2018 21:28
#!/bin/bash
# This script is only tested on CentOS 6.5
# You can customize variables such as MOUNTPOINT, RAIDCHUNKSIZE and so on to your needs.
# You can also customize it to work with other Linux flavours and versions.
# If you customize it, copy it to either Azure blob storage or Github so that Azure
# custom script Linux VM extension can access it, and specify its location in the
# parameters of powershell script or runbook or Azure Resource Manager CRP template.
NODENAME=$(hostname)
{
"$schema": "https://schema.management.azure.com/schemas/2016-09-01/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": {
"deploymentPrefix": {
"type": "string"
},
"indexCount": {
"type": "int"
},
{
"$schema": "http://schema.management.azure.com/schemas/2016-09-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"deploymentPrefix": {
"type": "string",
"metadata": {
"description": "Deployment Prefix name. Added to the beginning of each resource."
}
},
@raykao
raykao / first-node.sh
Created February 10, 2017 19:58
Downloads the galera.cnf config file to the MariaDB config.d path, then replaces values with the current machine's info.
#!/usr/bin/env bash
sudo -i
cd /etc/mysql/conf.d
wget https://gist.githubusercontent.com/raykao/027e42847392a0eafb6c7b51c3291191/raw/a328e20eb13e2e129101dea460e1bd592d7f1c3b/galera.cnf
sed -i "s/first_ip/$(ip -4 addr ls eth0 | awk '/inet / {print $2}' | cut -d"/" -f1)/g" galera.cnf
@raykao
raykao / galera.cnf
Created February 10, 2017 19:10
Basic MariaDB Galera Cluster configuration file.
# /etc/mysql/conf.d/galera.cnf
[mysqld]
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0
# Galera Provider Configuration
wsrep_on=ON
@raykao
raykao / install-mariadb.sh
Last active February 10, 2017 15:48
Scripted mariadb 10.1 install on Ubuntu without user interaction and auto password entry.
#!/usr/bin/env bash
export DEBIAN_FRONTEND="noninteractive"
export PASSWORD="H3ll0W0rld!"
sudo debconf-set-selections <<< "mariadb-server mysql-server/root_password password $PASSWORD"
sudo debconf-set-selections <<< "mariadb-server mysql-server/root_password_again password $PASSWORD"
sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
@raykao
raykao / example.nginx.config.file.com
Created April 29, 2016 16:23
An example nginx config file for ember deployment
server {
listen 80;
server_name yourdomain.com;
root /home/yourUserAccount/yourdomain.com/dist;
index index.html;
location / {
try_files $uri $uri/ /index.html;
}