Skip to content

Instantly share code, notes, and snippets.

View aojea's full-sized avatar

Antonio Ojea aojea

View GitHub Profile
@aojea
aojea / prometheus_restore.md
Last active February 1, 2022 10:46
restore prometheus dump
  1. create a snapshot of the db
curl -XPOST http://${PROMETHEUS_IP}:8080/api/v1/admin/tsdb/snapshot
  1. get the prometheus database
tar cvf prometheus.tar /prometheus/snapshots 
  1. create a fake prometheus config so it does not complain
@aojea
aojea / api-performance-overview.json
Created December 10, 2021 10:35
Performance dashboards
{
"__inputs": [ ],
"__requires": [ ],
"annotations": {
"list": [ ]
},
"description": "",
"editable": "true",
"gnetId": null,
"graphTooltip": 0,
etcd&
_output/dockerized/bin/linux/amd64/kube-apiserver --etcd-servers localhost:2379 --service-account-issuer=api --service-account-api-audiences=api --service-account-signing-key-file=/var/run/kubernetes/apiserver.key --service-account-key-file=/var/run/kubernetes/apiserver.key 2>&1 | less
@aojea
aojea / iptables_trace_test.go
Created November 6, 2021 21:15
trace iptables
/*
Copyright 2021 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
apiVersion: v1
kind: Service
metadata:
name: mydomainfortest
namespace: default
spec:
externalName: www.google.com
type: ExternalName
selector:
app: myapp
@aojea
aojea / patch.diff
Created October 8, 2021 10:18
avoid port collision
commit adf8c8ad610f925ee424002326a68e0cca97df66 (HEAD -> test_integration_1.22)
Author: Antonio Ojea <[email protected]>
Date: Fri Oct 8 01:04:38 2021 +0200
don't get available port from the ephemeral range
diff --git a/test/integration/framework/etcd.go b/test/integration/framework/etcd.go
index aa1d36a86ab..7d2020be4e8 100644
--- a/test/integration/framework/etcd.go
+++ b/test/integration/framework/etcd.go
@aojea
aojea / podman_networkless.md
Last active January 22, 2024 07:43
Podman networkless containers

Podman networless containers

There are some special cases that you only want to create a container without network interfaces, so you can handle the network directly.

Podman networking uses CNI to configure the networking of the containers, so we can leverage that to create containers without network interfaces, however, we always need the special loopback interface to be UP, so the networking working inside of the namespace.

How to create a networkless container

@aojea
aojea / apis_with_ip.md
Created August 22, 2021 20:24
kuberetes api fields with IP or CIDR

cat swagger.json | jq '.definitions' | gron | grep -E "(IP|CIDR)"

json["io.k8s.api.admissionregistration.v1.WebhookClientConfig"].properties.url.description = "`url` gives the location of the webhook, in standard URL form (`scheme://host:port/path`). Exactly one of `url` or `service` must be specified.\n\nThe `host` should not refer to a service running in the cluster; use the `service` field instead. The host might be resolved via external DNS in some apiservers (e.g., `kube-apiserver` cannot resolve in-cluster DNS as that would be a layering violation). `host` may also be an IP address.\n\nPlease note that using `localhost` or `127.0.0.1` as a `host` is risky unless you take great care to run this webhook on all hosts which run an apiserver which might need to make calls to this webhook. Such installs are likely to be non-portable, i.e., not easy to turn up in a new cluster.\n\nThe scheme must be \"https\"; the URL must begin with \"https://\".\n\nA path is optional, and if present may be any string per
@aojea
aojea / httptrace.go
Created August 2, 2021 23:15
transport wrapper to trace http requests
import (
"fmt"
"log"
"net/http"
"net/http/httptrace"
)
// transport is an http.RoundTripper that keeps track of the in-flight
// request and implements hooks to report HTTP tracing events.
type transport struct {
@aojea
aojea / netkat.md
Last active July 16, 2021 01:12
kubernetes loadbalancers and netkat
  1. Create a multinode cluster kind create cluster --config config.yaml
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker