Skip to content

Instantly share code, notes, and snippets.

View icy's full-sized avatar
🦖
Available

Ky-Anh Huynh icy

🦖
Available
View GitHub Profile
@icy
icy / fluxctl-list-images.sh
Created February 14, 2020 07:09
fluxctl-list-images.sh
$ gk8s :euw1 -- fluxctl list-images --k8s-fwd-ns=flux
WORKLOAD CONTAINER IMAGE CREATED
cert-manager:deployment/cert-manager cert-manager quay.io/jetstack/cert-manager-controller
| canary 10 Feb 20 14:50 UTC
'-> v0.13.0 21 Jan 20 18:29 UTC
@icy
icy / k8s-selector.rb
Created February 12, 2020 09:36
k8s-selector.rb
#!/usr/bin/env ruby
# Purpose : Select the objects you want from maninfests,
# as you may not want to deploy everything.
# Author : Ky-Anh Huynh
# Date : 2019-12
# Example :
#
# helm foo | k8s-select kind=Ingress | kubectl diff -f-
# helm foo | k8s-select metadata.name=someth | kubectl diff -f-
@icy
icy / gk8s-wait-for.sh
Created February 4, 2020 06:33
gk8s-wait-for.sh
gk8s_wait_for() {
retries="$1"; shift
regex="$1"; shift
kind="$*"
set +xe
echo ":: Wating for expression:"
echo ":: $kind"
echo ":://"
@icy
icy / telegram-group-stats.sh
Last active January 9, 2020 15:26
telegram-group-stats.sh
#!/usr/bin/env bash
# license : mit
# author : kyanh-huynh
# purpose : print stats from telegram group exported data
members() {
grep -Ee '(invited|joined|date details)' messages* \
|grep -v http \
|sed -E -e 's#^.+joined.+#foobar.html:joined#g' \
@icy
icy / fluxcd-rbac.yaml
Created January 8, 2020 14:47
fluxcd-rbac.yaml
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: flux
namespace: demo
labels:
name: flux
roleRef:
apiGroup: rbac.authorization.k8s.io
@icy
icy / kustomize-json-patch-complex.yaml
Created December 13, 2019 08:06
kustomize-json-patch-complex.yaml
resources:
- ../local-end2end
- test-end2end.yaml
namePrefix: RESOURCE_PREFIX_
commonLabels:
mineHashId: IMAGE_TAG
patches:
@icy
icy / my-dns-resolver.rb
Created December 13, 2019 07:21
my-dns-resolver.rb
#!/usr/bin/env ruby
require 'rubydns'
INTERFACES = [
[:udp, "0.0.0.0", 53],
[:tcp, "0.0.0.0", 53],
]
IN = Resolv::DNS::Resource::IN
@icy
icy / security-nginx-ingress-controller.yaml
Created December 10, 2019 16:35
security-nginx-ingress-controller.yaml
### A flaw setup of nginx ingress controller
Assuming you have two sites `publicA` and `privateB`, both are running on
the same `k8s` cluster and exposing accesses through nginx ingress controller.
The site `publicA` requires authentication and the site `privateB`
doesn't. Let's consider the following setup
public ELB/ALB --> public A with authentication
private ELB/ALB --> private B
@icy
icy / prometheus-exclude-docker-and-non-ext-fs.yaml
Last active February 11, 2020 03:09
prometheus-exclude-docker-and-non-ext-fs.yaml
# Purpose: Clean up non-sense filesystem entries from node exporter's metrics
#
# * Remove all /var/lib/docker, /var/run, /run mount points
# * Remove all non-ext filesystem
#
# Author : Ky-Anh Huynh
# License: as free as beer, or a MIT
# Efficiency : 108724 metrics --> 1593 metrics
# TODO: support xfs filesystem