Skip to content

Instantly share code, notes, and snippets.

View example.sh
function get_cluster_name() {
if ! kubectl config current-context ; then
echo "ERROR: Could not read kubeconfig context" 2>&1
exit 1
fi
}
CLUSTER_NAME=$(get_cluster_name)
View filebeat.yaml
filebeat.autodiscover:
providers:
# documented at https://www.elastic.co/guide/en/beats/filebeat/master/configuration-autodiscover.html
- type: kubernetes
host: ${NODE_NAME}
hints.enabled: true
hints.default_config:
type: container
paths:
- /var/log/containers/*${data.kubernetes.container.id}.log
@kesor
kesor / kops-cluster-update-errors.txt
Created Sep 1, 2020
kops cluster update duplicate IAM roles
View kops-cluster-update-errors.txt
I0901 15:06:00.194412 65709 factory.go:68] state store s3://mybucket.domain.com/mycluster
I0901 15:06:00.194584 65709 s3context.go:337] GOOS="darwin", assuming not running on EC2
I0901 15:06:00.194592 65709 s3context.go:170] defaulting region to "us-east-1"
I0901 15:06:00.987020 65709 s3context.go:210] found bucket in region "us-east-1"
I0901 15:06:00.987048 65709 s3fs.go:284] Reading file "s3://mybucket.domain.com/mycluster/mycluster.domain.com/config"
I0901 15:06:01.770731 65709 s3fs.go:321] Listing objects in S3 bucket "mybucket.domain.com" with prefix "mycluster/mycluster.domain.com/instancegroup/"
I0901 15:06:01.978948 65709 s3fs.go:349] Listed files in s3://mybucket.domain.com/mycluster/mycluster.domain.com/instancegroup: [s3://mybucket.domain.com/mycluster/mycluster.domain.com/instancegroup/master-us-east-1a s3://mybucket.domain.com/mycluster/mycluster.domain.com/instancegroup/nodes s3://mybucket.domain.com/mycluster/mycluster.domain.com/instancegroup/second]
I0901 15:06:01.978996 65709
@kesor
kesor / ffmpeg-grab-cam-display.sh
Created Aug 20, 2020
Record display, webcam and pulseaudio using ffmpeg
View ffmpeg-grab-cam-display.sh
#!/bin/sh
# 1. create v4l2loopback device /dev/video42 using
# $ sudo modprobe v4l2loopback video_nr=42 max_buffers=2 exclusive_caps=1
ts=$(date +%Y-%m-%dT%H:%M:%SZ-%s)
PREFIX=/mnt/data/Videos
CAMERA_INPUT=/dev/video0
@kesor
kesor / component-app.js
Last active Jul 15, 2020
Vue.js 3.x with ES6 modules in the browser using import-map
View component-app.js
import { defineAsyncComponent } from 'vue'
const Content = defineAsyncComponent(() => import('./component-content.js'))
export default {
name: 'App',
components: { Content },
template: /*html*/`
<Content />
`
@kesor
kesor / docker-compose.yaml
Last active Jul 13, 2020
Docker Compose for ElasticSearch + Kibana 7.8
View docker-compose.yaml
# Create an EBS volume and attach to the EC2 instance
# Format as XFS and mount at /mnt/elastic-data
# /dev/nvme2n1 on /mnt/elastic-data type xfs (rw,relatime,attr2,inode64,noquota)
# For ElasticSearch to work - got to change this sysctl:
#
# sudo sysctl vm.max_map_count=262144
#
# $ cat docker-compose.yml
@kesor
kesor / docker-compose.yaml
Created Jul 13, 2020
Docker Compose for ElasticSearch + Kibana 7.8
View docker-compose.yaml
# Create an EBS volume and attach to the EC2 instance
# Format as XFS and mount at /mnt/elastic-data
# /dev/nvme2n1 on /mnt/elastic-data type xfs (rw,relatime,attr2,inode64,noquota)
# $ cat docker-compose.yml
version: "3.7"
services:
elasticsearch:
@kesor
kesor / docker-compose.yaml
Created Jul 13, 2020
Docker Compose for ElasticSearch + Kibana 7.8
View docker-compose.yaml
# Create an EBS volume and attach to the EC2 instance
# Format as XFS and mount at /mnt/elastic-data
# /dev/nvme2n1 on /mnt/elastic-data type xfs (rw,relatime,attr2,inode64,noquota)
# $ cat docker-compose.yml
version: "3.7"
services:
elasticsearch:
@kesor
kesor / utils.sh
Created Jul 1, 2020
example utils.sh
View utils.sh
#!/bin/bash
# Common utility functions for bash scripts,
# - fatal -- use like `some_cmd || fatal "Some cmd failed"`
# - debug -- use like `debug "This is a debug message"`
# - timer -- use like `tm some_cmd` as a wrapper
# - retry -- use like `retry some_cmd` as a wrapper, retries with exp. backoff
#
# Source this bash like so: `. util.sh`
#
@kesor
kesor / Dockerfile
Last active Jun 18, 2020
example node.js production Dockerfile
View Dockerfile
FROM node:14.4
RUN DEBIAN_FRONTEND=noninteractive apt-get update -y \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends -o APT::Install-Suggests=0 -o APT::Install-Recommends=0 \
ca-certificates \
&& rm -rf /var/lib/apt/lists/* \
&& mkdir -p /app \
&& chown node:node /app
ENV NODE_ENV production
You can’t perform that action at this time.