Skip to content

Instantly share code, notes, and snippets.

View thomastaylor312's full-sized avatar

Taylor Thomas thomastaylor312

View GitHub Profile
@thomastaylor312
thomastaylor312 / approve-all-tags.js
Created August 15, 2018 06:11
Approves all Facebook tag requests
for (let o in document.querySelectorAll('[ajaxify^="/ajax/pending_tags/approve.php"]')) {
o.click()
}
@thomastaylor312
thomastaylor312 / service.yml
Created November 4, 2016 22:15
A service for exposing inter-node Cassandra ports in Kubernetes
---
apiVersion: v1
kind: Service
metadata:
labels:
app: cassandra
# Allows service to connect to containers that aren't in a ready state
# This is needed so the cluster can actually spin up
annotations:
service.alpha.kubernetes.io/tolerate-unready-endpoints: "true"
@thomastaylor312
thomastaylor312 / check-pods.py
Created November 4, 2016 21:43
Function for checking status of containers in pods
def check_pods(get_pods_json):
problemPods = list()
for pod in get_pods_json['items']:
isBad = False
if pod['status']['phase'] != 'Running' and pod['status']['phase'] != 'Completed':
isBad = True
else:
for container_status in pod['status']['containerStatuses']:
if not container_status['ready']:
isBad = True
@thomastaylor312
thomastaylor312 / example-alert.yml
Created November 4, 2016 21:11
An example elastalert config
# Alert when the rate of events exceeds a threshold
# (Required)
# Rule name, must be unique
name: jenkins-severe-exceptions
# (Required)
# Type of alert.
# the frequency rule type alerts when num_events events occur with timeframe time
type: frequency
@thomastaylor312
thomastaylor312 / cassandra.tick
Created November 4, 2016 18:58
An example Kapacitor alert
stream
// The following stream alerts based on changes in cpu/usage
// Every minute the rate of change for the cpu/usage is calculated
// Alerts are sent out when that rate is unusually high
|from()
.measurement('cpu/usage')
.where(lambda: "type" == 'node' AND "nodename" =~/.*cassandra.*/)
.groupBy('nodename')
|derivative('value')
.unit(60s)
@thomastaylor312
thomastaylor312 / jenkins.yml
Last active November 4, 2016 18:42
Example Ansible role file for populating Kubernetes YAML files
- include_vars: "group_vars/secrets/secrets_{{ k8s_environment }}_{{ jenkins_type }}.yml"
- name: "Jenkins specs directory"
file:
dest: "./build/{{ k8s_environment }}/"
state: directory
- name: "Jenkins environment directory"
file:
dest: "./build/{{ k8s_environment }}/jenkins"
state: directory
- name: "Set path where specs go"
@thomastaylor312
thomastaylor312 / populate.sh
Created November 4, 2016 18:19
A population script for creating Kubernetes spec files
#!/bin/bash
if [ $# -lt 2 ]; then
echo 'Expects 2 arguments: ./populate.sh APPLICATION K8S_ENVIRONMENT'
exit 1
fi
extra_vars="--extra-vars @group_vars/secrets.yml"
application=$1
k8s_environment=$2
@thomastaylor312
thomastaylor312 / example-deploy.yml
Created November 3, 2016 23:10
An example Deployment
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: test
spec:
replicas: 1
template:
spec:
containers:
@thomastaylor312
thomastaylor312 / example-config.yml
Last active November 3, 2016 23:10
An example ConfigMap
---
apiVersion: v1
kind: ConfigMap
metadata:
name: alert-rules
data:
foo-file: |
foo: bar
whiz: bang
special.conf: |
@thomastaylor312
thomastaylor312 / kubernetes-library.go
Last active November 8, 2016 16:27
Using the Kubernetes library
package main
import (
"log"
"k8s.io/kubernetes/pkg/api"
client "k8s.io/kubernetes/pkg/client/unversioned"
"k8s.io/kubernetes/pkg/fields"
"k8s.io/kubernetes/pkg/labels"
)