Skip to content

Instantly share code, notes, and snippets.

@oskapt
oskapt / rc.netdata
Last active December 13, 2023 12:49
Netdata init script for Synology DSM
#!/bin/bash
# Install this as `/etc/rc.netdata` and call it from `/etc/rc.local`
# to have it executed on boot.
NETDATA_DIR=/opt/netdata
DAEMON=$NETDATA_DIR/bin/srv/netdata
TIMEOUT=30 # seconds to wait for netdata to exit
[ -x $DAEMON ] || exit 0

Keybase proof

I hereby claim:

  • I am oskapt on github.
  • I am oskapt (https://keybase.io/oskapt) on keybase.
  • I have a public key ASAIGf3Y3vD9scPLvNC7Z-yOKyU_AvKCaMoHQwJjWmaEmwo

To claim this, I am signing this object:

@oskapt
oskapt / cali_interface_per_pod.sh
Created January 29, 2019 12:39 — forked from superseb/cali_interface_per_pod.sh
Cali interface per pod
#!/bin/bash
# Based on https://github.com/moby/moby/issues/17064#issuecomment-294020260, thanks!
function cali_interface_for_container() {
container_name=$(docker inspect --format='{{.Name}}' "${1}")
# Get the process ID for the container named ${1}:
local pid=$(docker inspect -f '{{.State.Pid}}' "${1}")
@oskapt
oskapt / ip-ranges.txt
Created May 12, 2019 21:54 — forked from PSJoshi/ip-ranges.txt
IP ranges for Google, Amazon etc
* CloudFare IP list: https://www.cloudflare.com/ips/
* Google's IP addresses:
nslookup -q=TXT _netblocks.google.com 8.8.8.8
nslookup -q=TXT _netblocks2.google.com 8.8.8.8
nslookup -q=TXT _netblocks3.google.com 8.8.8.8
Each of the above line will display a CIDR block or Google’s IP addresses.
* Amazon IP addresses: https://ip-ranges.amazonaws.com/ip-ranges.json
@oskapt
oskapt / 1_README.md
Created August 2, 2019 01:48 — forked from superseb/1_README.md
Generate Rancher 2 cluster/node agent definitions

Generate Rancher 2 cluster/node agents definitions

This is not official documentation/tooling, use with caution

This generate the Kubernetes definitions of the cattle-cluster-agent Deployment and cattle-node-agent DaemonSet, in case it's accidentally removed/server-url was changed/certficates were changed. It is supposed to run on every cluster Rancher manages. If you have custom clusters created in Rancher, see Kubeconfig for Custom clusters created in Rancher how to obtain the kubeconfig to directly talk to the Kubernetes API (as usually it doesn't work via Rancher anymore). For other clusters, use the tools provided by the provider to get the kubeconfig.

IMPORTANT: You get the cluster/node agents definitions from Rancher, and you apply them to the cluster that is created/managed so you need to switch kubeconfig to point to that cluster before applying them.

Running it

@oskapt
oskapt / restore_rancher2_agents.md
Created August 2, 2019 01:49 — forked from superseb/restore_rancher2_agents.md
Restore Rancher 2 cluster/node agents on clusters

Restore Rancher 2 cluster/node agents on clusters

This is an unsupported scenario, see rancher/rancher#14731 when there is an official solution.

When cattle-cluster-agent and/or cattle-node-agent are accidentally deleted, or when server-url/cacerts are changed.

Generate definitions

  • Generate API token in the UI (user -> API & Keys) and save the Bearer token
  • Find the clusterid in the Rancher UI (format is c-xxxxx), its in the address bar when the cluster is selected
@oskapt
oskapt / e08-handout.md
Created August 27, 2019 15:18
Scripts and commands for https://youtu.be/09bsaCkLfw4

Hello! This gist goes with this video, which covers shortcuts and strategies for working with the K8s command line. You can see all of my videos on YouTube at https://adrian.goins.tv.

Scripts

I use Fish as my shell, but I know that a lot of people are using Bash. Here are two ways to concatenate config files for kubectl into the KUBECONFIG environment variable. If you're using zsh or tcsh you'll know how to convert these to your shell's format.

You can call these from your shell init file, or if you want to temporarily disable a script, append .bak or .disabled to its extension and run the script manually.

You can even hotkey it on something like the Elgato Stream Deck.

@oskapt
oskapt / velero-aws-setup-combined.sh
Last active September 24, 2019 21:21
Velero AWS Setup Script
#!/bin/bash
# Set BUCKET and REGION before continuing. If you want to use a
# different IAM user name or if you use a different AWS profile
# for connecting, you can set those as well.
BUCKET=
REGION=
VELERO_USER=velero
AWS_PROFILE=default
@oskapt
oskapt / instance-policy.json
Created September 24, 2019 21:16
IAM Instance Policy JSON for Rancher
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ec2:AttachVolume",
"ec2:CreateSnapshot",
"ec2:CreateTags",
"ec2:CreateVolume",
@oskapt
oskapt / velero-install-aws.sh
Created September 24, 2019 21:19
Velero install command
velero install \
--provider aws \
--bucket $BUCKET \
--secret-file ./credentials-velero \
--backup-location-config region=$REGION \
--snapshot-location-config region=$REGION \
--use-restic