Skip to content

Instantly share code, notes, and snippets.

@simonswine
simonswine / install-openjdk8-musl.sh
Created August 11, 2019 10:54
Install alpine openjdk8 onto OpenWRT (armv7)
#!/bin/sh
set -o errexit
set -o nounset
set -o pipefail
set -x
REVISION=8.212.04-r0
URL=http://dl-cdn.alpinelinux.org/alpine/v3.10/community/armv7/
PACKAGES="openjdk8 openjdk8-jre openjdk8-jre-lib openjdk8-jre-base"
@simonswine
simonswine / tfstate.jsonnet
Created April 18, 2019 14:09
Modify every instance of specific object in a terrafrom state
local x = import 'input.tfstate';
local modifyDNSManagedZone(o) = o {
primary+: {
attributes+: {
visibility: 'public',
},
},
};
@simonswine
simonswine / christian-kind-pod.yaml
Last active April 1, 2019 10:35
Run kubernetes in Kind
apiVersion: batch/v1
kind: Job
metadata:
name: christian-kind
spec:
template:
spec:
initContainers:
- name: install-docker-bin
command:
@simonswine
simonswine / gcloud_oauth2_cerds.sh
Created March 5, 2019 18:26
Using oauth2 google tokens with gcloud (those can be acquired through: `gcloud auth print-access-token`)
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
account_id=temp
mkdir -p ~/.config/gcloud/configurations/
cat > ~/.config/gcloud/configurations/config_default <<EOF
@simonswine
simonswine / generate-c-api.sh
Created January 9, 2019 22:00
Generate Kubernetes C api
#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
set -o verbose
REPO_ROOT=$(dirname "${BASH_SOURCE}")/..
# generate C api
@simonswine
simonswine / restic-exporter.sh
Created September 10, 2018 08:40
Write restic metrics for repo filesystem for node_exporters file collector
#!/bin/sh
set +e
set +x
NAMESPACE=restic
BACKUP_FOLDER=/opt/backup/restic
for dir in $(find "${BACKUP_FOLDER}" -type d -maxdepth 1 -mindepth 1); do
@simonswine
simonswine / sonar.sh
Created August 25, 2018 13:01
sonarqube golang
go test -json $(go list ./... | grep -v /vendor/) -coverprofile report_coverage.cov > report_gotest.json
~/sonar-scanner \
-Dsonar.sources=./ \
-Dsonar.sources.inclusions=**/**.go \
-Dsonar.exclusions="vendor/**" \
-Dsonar.tests=./ \
-Dsonar.test.inclusions=**/**_test.go \
-Dsonar.go.tests.reportPaths="report_gotest.json" \
-Dsonar.go.coverage.reportPaths="report_coverage.cov"
@simonswine
simonswine / docker-compose.yaml
Last active July 5, 2018 15:44
Run a standalone API server
version: '2'
services:
etcd:
image: quay.io/coreos/etcd:v3.1.12
ports:
- 2379
volumes:
- etcd_data:/etcd_data
command:
- /usr/local/bin/etcd
package main
import "fmt"
import "github.com/spf13/cobra"
import "os"
var works bool
func init() {
rootCmd.PersistentFlags().BoolVar(&works, "works", false, "testing flag behaviour")
@simonswine
simonswine / kubectl_root_host.sh
Created May 29, 2018 16:23
nsenter into the host
kubectl run hack1 --restart=Never -t -i -n kube-system --image overridden --overrides '{"spec":{"hostPID": true, "containers":[{"name":"busybox","image":"alpine:3.7","command":["nsenter","--mount=/proc/1/ns/mnt","--","/bin/bash"],"stdin": true,"tty":true,"securityContext":{"privileged":true}}]}}' --rm --attach