Skip to content

Instantly share code, notes, and snippets.

@avoidik
avoidik / tsv2csv.sh
Last active May 15, 2021 12:06
Convert amazon-reviews-pds from TSV to CSV
pip install -U awscli pandas
aws s3 cp s3://amazon-reviews-pds/tsv/amazon_reviews_us_Automotive_v1_00.tsv.gz .
cat << 'EOF' | python
import pandas as pd
fields = ['star_rating', 'review_body', 'review_id']
dfs = pd.read_csv('amazon_reviews_us_Automotive_v1_00.tsv.gz', sep='\t', usecols=fields, compression='gzip', chunksize=100)
for df in dfs:
df.to_csv('amazon_reviews_us_Automotive_v1_00.csv', index=None, header=True, mode='a')
@avoidik
avoidik / cloud-init.yaml
Last active March 3, 2023 15:41
Run EC2 using AWS CLI with user-data
#cloud-config
package_update: false
package_upgrade: false
ssh_authorized_keys:
- 'ssh-rsa AAAA...'
- 'ssh-rsa AAAA...'
write_files:
@avoidik
avoidik / README.md
Last active May 13, 2021 10:47
How to integrate dnsmasq into systemd dns resolver

Default resolv.conf path

$ ls -ld /etc/resolv.conf
lrwxrwxrwx 1 root root 39 Dec 23 07:45 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf

Find all open DNS ports

@avoidik
avoidik / kcgroups.md
Created April 24, 2021 21:10 — forked from mcastelino/kcgroups.md
Kubernetes and cgroups Resource Management/Static cpuManagerPolicy/Memory and Resource Isolation & Scheduling

Overview

The goal of this document to cover all aspects of Kubernetes management, including how resources are expressed, constrained and accounted for. This started a way to ensure that alternate container runtime implementation like Kata containers will behave from a resource accounting and consumption point of view in the same manner as runc.

Location of the latest version of this document: https://gist.github.com/mcastelino/b8ce9a70b00ee56036dadd70ded53e9f

If you do not understand cgroups please refer to a quick primer at the bottom of this document. This will help you understand how the resource enforcement actually works.

Kubernetes Resource Management

@avoidik
avoidik / README.md
Created April 24, 2021 18:16
How to Limit CPU and Memory Usage With Cgroups on Debian/Ubuntu

How to Limit CPU and Memory Usage With Cgroups on Debian/Ubuntu

Cgroups is a flexible Linux kernel feature to limit, police and account resources usage. A cgroup is a set of tasks for a subsystems, that is typically a resource controller.

A file system of type cgroup is mounted and all operations are run over it.

Installation

The installation can be done using any of libcgroup, cgmanager or systemd.

@avoidik
avoidik / flannel.default.patch
Last active May 9, 2021 16:06
flannel patch (k3s on vagrant)
diff -rupN a/kube-flannel.yml b/kube-flannel.yml
--- a/kube-flannel.yml 2021-05-08 18:24:19.501046914 +0000
+++ b/kube-flannel.yml 2021-05-08 18:25:19.807186705 +0000
@@ -47,7 +47,7 @@ spec:
rule: 'RunAsAny'
---
kind: ClusterRole
-apiVersion: rbac.authorization.k8s.io/v1beta1
+apiVersion: rbac.authorization.k8s.io/v1
metadata:
@avoidik
avoidik / README.md
Created April 23, 2021 19:29
metrics-server enable TLS verification

Problem statement

Get https://ip-x-x-x-x:10250/stats/summary/: x509: certificate signed by unknown authority, unable to fully scrape metrics from source kubelet_summary

Solution

Proudly stolen from - https://stackoverflow.com/a/53218524

@avoidik
avoidik / s3gen.py
Created April 22, 2021 17:19
Generate AWS S3 presigned url and curl command to upload
#!/usr/bin/env python3
import os
import sys
import json
from argparse import ArgumentParser
from urllib.parse import urlencode, quote_plus
import boto3
@avoidik
avoidik / wsl-network.ps1
Created April 16, 2021 14:38
Allow to connect to WSL2 over the network
if ((Get-InstalledModule "Carbon" -ErrorAction SilentlyContinue) -eq $null) {
Install-Module -Name 'Carbon' -AllowClobber
}
Import-Module 'Carbon'
If ($Args[0] -eq "list" -Or $Args[0] -eq "-list") {
netsh interface portproxy show v4tov4
exit
}
@avoidik
avoidik / ingress.patch
Last active April 19, 2021 22:04
nginx-ingress patch
diff -rupN a/deploy.yaml b/deploy.yaml
--- a/deploy.yaml 2021-04-19 22:01:38.327342529 +0000
+++ b/deploy.yaml 2021-04-19 22:02:57.602960196 +0000
@@ -37,6 +37,9 @@ metadata:
name: ingress-nginx-controller
namespace: ingress-nginx
data:
+ use-forwarded-headers: "true"
+ compute-full-forwarded-for: "true"
+ use-proxy-protocol: "true"