Skip to content

Instantly share code, notes, and snippets.

@mvasilenko
mvasilenko / haproxy-www.tf
Last active January 28, 2021 22:53 — forked from thisismitch/haproxy-www.tf
How To Use Terraform with DigitalOcean
resource "digitalocean_droplet" "haproxy-www" {
image = "ubuntu-14-04-x64"
name = "haproxy-www"
region = "nyc2"
size = "512mb"
private_networking = true
ssh_keys = [
"${var.ssh_fingerprint}"
]
connection {
@mvasilenko
mvasilenko / instance.tf
Created February 25, 2018 18:49 — forked from davebiffuk/instance.tf
Terraform template for security group
variable "count" {
default = 1
}
variable "flavor" {
default = "m1.small"
}
resource "openstack_networking_floatingip_v2" "fip" {
count = "${var.count}"
resource "opentelekomcloud_dns_zone_v2" "dnszone" {
name = "${var.dnszone}"
email = "info@${var.dnszone}"
ttl = 6000
}
resource "opentelekomcloud_dns_recordset_v2" "test_a" {
zone_id = "${opentelekomcloud_dns_zone_v2.dnszone.id}"
name = "${var.dnszone}"
ttl = 300
@mvasilenko
mvasilenko / gist:b8c47616fa74de63dcc030508c53e7c1
Last active December 30, 2022 08:51
goaccess nginx apm log format template
time-format %T
date-format %d/%b/%Y
log_format "%d:%t +%^" client=%h method=%m request="%r" request_length=%^ status=%s bytes_sent=%b body_bytes_sent=%^ referer=%R user_agent="%^" upstream_addr=%^ upstream_status=%^ request_time=%T upstream_response_time=%^ upstream_connect_time=%^ upstream_header_time=%^
@mvasilenko
mvasilenko / gist:316ce0399ce8a95bc3e6ab0d1b71e882
Created May 17, 2018 09:48
delete k8s pods stuck in Terminating state
#!/bin/bash
# get namespaces list
NAMESPACES=$(kubectl get namespaces --output=jsonpath={.items..metadata.name})
# delete stuck pods in each namespace
for NS in $NAMESPACES;do
kubectl get pods -n $NS | awk "\$3==\"Terminating\" {print \"kubectl delete -n $NS pod \" \$1 \" --grace-period=0 --force\"}" | xargs -0 bash -c
done
$ kubectl run nginx --image=nginx --dry-run -o yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
creationTimestamp: null
labels:
run: nginx
name: nginx
spec:
@mvasilenko
mvasilenko / AKS Setup Script
Created September 29, 2018 06:51 — forked from seanw122/AKS Setup Script
This script will setup a new Azure Resource Group and Azure Kubernetes Service cluster environment also with an Azure Container Registry resource.
## This creates a working single node Azure Kubernetes Cluster
## and with an Azure Container Registry. Note, the ACR is in
## the same resource group as the AKS for demo purposes. For
## dev you should have ACR in separate resource group.
echo "Beginning AKS Setup for Demo"
date
AKS_RESOURCE_GROUP=aks-rg1
AKS_CLUSTER_NAME=aks-c1
@mvasilenko
mvasilenko / mongodb_list_indexes_all_db.js
Last active March 6, 2019 07:27
mongodb list all indexes for all databases
// List all indexes in all databases
db.getMongo().getDBNames().forEach(function(dbName) {
if (dbName != "admin" && dbName != "local" && dbName != "config") {
db.getSiblingDB(dbName).getCollectionNames().forEach(function(coll) {
db.getSiblingDB(dbName)[coll].getIndexes().forEach(function(index) {
if ("id" !== index.name) {
print("db.getSiblingDB('" + dbName + "')." + coll + ".ensureIndex(" + tojson(index.key) + ")");
}
});
@mvasilenko
mvasilenko / mongodb_copy_all_indexes_for_collection.js
Created March 6, 2019 07:30
MongoDB copy all indexes for collection
db.getCollectionInfos().forEach(function(coll) {
if (coll.type === "collection" ) {
db[coll.name].getIndexes().forEach(function(index) {
if ("id" !== index.name) {
//print( JSON.stringify( index ))
var indexKey = index.key // save the key, and transform index into the "options"
delete index.v
delete index.key
index.background = true // optional: force background to be true
print("db." + coll.name + ".createIndex(" + JSON.stringify(indexKey) + ", " + JSON.stringify(index) + ")");
get_network_mode() {
docker inspect --format='{{.HostConfig.NetworkMode}}' "$1"
}
created_by_kubelet() {
[[ $(docker inspect --format='{{.Name}}' "$1") =~ ^/k8s_ ]]
}