Skip to content

Instantly share code, notes, and snippets.

View full-sized avatar

Antonio Ojea aojea

View GitHub Profile
@aojea
aojea / readme.md
Created September 11, 2023 18:10
Obtain coredump from an application
View readme.md
kubectl get pods -A -o wide | grep dns
kube-system   kube-dns-5bfd847c64-bkkhf                           4/4     Running   0             80m   10.108.0.5    gke-vanilla-default-pool-ddebe65c-pkzw   <none>           <none>
kubectl debug -n kube-system -it kube-dns-5bfd847c64-bkkhf --image=busybox:1.28 --target=dnsmasq
Targeting container "dnsmasq". If you don't see processes from this container it may be because the container runtime doesn't support this feature.
Defaulting debug container name to debugger-qz6cb.
If you don't see a command prompt, try pressing enter.
@aojea
aojea / service_selector.yaml
Created August 27, 2023 19:05
Service selector
View service_selector.yaml
apiVersion: v1
kind: Pod
metadata:
name: job1
labels:
job-name: "job1"
job-index: "0"
spec:
hostNetwork: true
containers:
@aojea
aojea / netperf.yaml
Last active August 27, 2023 14:47
netperf network performance test kubernetes
View netperf.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: netperf-server
labels:
app: netperf-server
spec:
replicas: 1
selector:
matchLabels:
@aojea
aojea / README.md
Last active June 23, 2023 09:16
Test even loadbalancing
View README.md

Create the deploymentn with 100 backends and one Service

kubectl apply -f backends.yaml

Run a pod to test the Service using the httptest program, that allows to specify different parameters of the http connections

./httptest -h
Usage: httpget [options] [url]
@aojea
aojea / README.md
Last active June 10, 2023 12:20
BPF cheatsheet
View README.md
@aojea
aojea / README.md
Last active May 11, 2023 15:08
service loadbalancer deleteion
View README.md

Service LoadBalancer deletion

Services of Type: LoadBalancer are handled by external controllers.

These controllers need to handle the infrastructure necessary to provisiong the external Loadbalancer, and use finalizers to avoid deleting the Service before all the necessary steps are done.

Kubernetes provide a reference implementation of a controller for Loadbalancers in https://github.com/kubernetes/kubernetes/blob/master/staging/src/k8s.io/cloud-provider/controllers/service/controller.go

Example

View README.md

checkout cilium repo and run it in kind

git clone https://github.com/cilium/cilium.git
cd cilium
REPO_ROOT=$PWD
KUBEPROXY_MODE="none" make kind
make kind-image
make kind-install-cilium
@aojea
aojea / README.md
Created May 5, 2023 08:26
Ingress-nginx load sharing
View README.md

Install ingress-nginx

kubectl create clusterrolebinding cluster-admin-binding   --clusterrole cluster-admin   --user $(gcloud config get-value account)
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.7.0/deploy/static/provider/cloud/deploy.yaml

Scale the ingress-controller to have two replicas:

@aojea
aojea / README.md
Last active April 16, 2023 09:21
Noop ipmasq-agent
View README.md
$ wget https://gist.githubusercontent.com/aojea/50ec0d10807d1907ecc6ece526f991da/raw/15371f0f2cf48f2e6a75db7f71a7e674e8dfc624/ipmasq.yaml -O ipmasq-noop.yaml
$ kubectl apply -f ipmasq-noop.yaml
configmap/ip-masq-agent configured
daemonset.apps/ip-masq-agent unchanged
@aojea
aojea / README.md
Last active April 12, 2023 22:23
gce ipv6 only cluster
View README.md

GCE IPv6 only cluster

These scripts create an IPv6 only cluster on GCE using GUA for both Pods and Services. The scripts use kubeadm and there are not fully automated, this is some personal and exploratory work, so some manual steps are required.

Using GUAs everywhere allows to connect directly to Pod and Services:

  • with the benefit that everything is routed and there is no need for lodabalancers or nodePorts
  • with the con that everything is public and you need to create firewall rules accordenly