Skip to content

Instantly share code, notes, and snippets.

@Mikulas
Mikulas / config.yaml
Created August 18, 2017 14:19
frp kubernetes config
apiVersion: v1
kind: Namespace
metadata:
name: frp
---
apiVersion: v1
kind: LimitRange
metadata:
SRC := $(shell find $(CURDIR)/src -name '*.php')
composer.lock: $(SRC)
composer dump-autoload --classmap-authoritative --optimize
test: composer.lock
vendor/bin/tester tests/
.PHONY: test
SELECT srcaddr, srcport, sum(bytes)
FROM vpc
WHERE crosszone=1
AND external=0
AND dstaddr='172.31.29.150'
GROUP BY srcaddr, srcport
ORDER BY 3 desc;
SELECT dstaddr, sum(bytes)
FROM vpc
WHERE crosszone=1
AND external=0
GROUP BY dstaddr
ORDER BY 2 desc;
SELECT dstaddr, sum(bytes)
FROM vpc
WHERE srcaddr << '172.31.0.0/16'
AND external=1
GROUP BY dstaddr
ORDER BY 2 desc;
SELECT srcport, sum(bytes)
FROM vpc
WHERE srcaddr << '172.31.0.0/16' -- packets sent from our VPC CIDR
AND external=1 -- going outside the VPC
GROUP BY srcport -- aggregated by your application ports
ORDER BY 2 desc;
#!/usr/bin/env bash
set -uo pipefail
IFS=$'\n\t'
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$(dirname "$DIR")"
for RETRY in $(seq 1 120); do
OUT="$(php bin/console migrations:continue --production)"
STATUS="$?"
UPDATE "vpc" SET "crosszone" = CASE
-- Get those values from a list of AWS VPC Subnets:
WHEN dstaddr::inet << '172.31.16.0/20' AND srcaddr::inet << '172.31.16.0/20'
THEN 0
WHEN dstaddr::inet << '172.31.0.0/20' AND srcaddr::inet << '172.31.0.0/20'
THEN 0
ELSE 1
END, "external" = CASE
-- This is a combined CIDR of all the subnets. If you can't simplify
-- into a single condition, add more cases.
COPY vpc FROM '/SOME/PATH/000000'
WITH (
FORMAT CSV,
DELIMITER ' ',
NULL '-' -- some Flog Log entries will have unset fields with '-', this normalizes the value to NULL
);
CREATE TABLE "public"."vpc" (
"time" timestamp NOT NULL,
"version" integer NOT NULL,
"account" text NOT NULL,
"interface" text NOT NULL,
"srcaddr" inet,
"dstaddr" inet,
"srcport" integer,
"dstport" integer,
"protocol" int,