Skip to content

Instantly share code, notes, and snippets.

View able8's full-sized avatar

Able Lv able8

View GitHub Profile
@able8
able8 / vault-scanner.go
Created April 27, 2024 15:05
Search / Download Retrieve all secrets from HashiCorp's Vault in Golang
package main
import (
"encoding/json"
"fmt"
"io"
"log"
"net/http"
"os"
"path"
@able8
able8 / vimium-options.json
Created March 18, 2024 06:08
My vimium configs
{
"keyMappings": "# Insert your preferred key mappings here.\nunmap d\nmap d scrollFullPageDown\nmap <down> scrollFullPageDown\nmap e scrollFullPageUp\nmap <up> scrollUp\n#map e scrollPageUp\nmap w nextTab\nmap a previousTab\n\nunmap l\nmap s goBack\nmap l goForward\n\nmap z restoreTab\nmap c goNext\nmap h goPrevious\n\nunmap f\nunmap F\n\n\nmap F LinkHints.activateModeToOpenInNewForegroundTab\nmap f LinkHints.activateModeToOpenInNewTab\nmap o Vomnibar.activateInNewTab\nmap q visitPreviousTab\n\n# map t createTab http://www.google.com/\n#map t createTab https://www.deepl.com/write\nmap t duplicateTab\n\nmap  ; Marks.activateGotoMode swap\nmap m Marks.activateCreateMode swap\n\nmap <c-,> moveTabLeft count=99\nmap <c-.> moveTabRight count=99\n\nmap <c-f> LinkHints.activateModeWithQueue\n\nunmap p\nmap p openCopiedUrlInNewTab\n\nmap <c-p> togglePinTab\nmap <c-d> LinkHints.activateModeToDownloadLink\n\nunmap b\nmap b Vomnibar.activateTabSelection",
"linkHintCharacters": "asdfwerzxcv",
"nextPatterns": "下一篇,
@able8
able8 / main.go
Created November 1, 2023 15:01
Get Node and Pod Resource Usages using K8s metricsClient
package main
// https://cloud.tencent.com/developer/ask/sof/115441746
import (
"bytes"
"context"
"flag"
"fmt"
"log"
// Watch Pod update events
podInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
UpdateFunc: func(old interface{}, new interface{}) {
oldPod, newPod := old.(*v1.Pod), new.(*v1.Pod)
oldPodRestartCount := getPodRestartCount(oldPod)
newPodRestartCount := getPodRestartCount(newPod)
// Compare the RestartCount
if newPodRestartCount > oldPodRestartCount {
key, err := cache.MetaNamespaceKeyFunc(new)
if err == nil {
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"apiextensions.k8s.io/v1","kind":"CustomResourceDefinition","metadata":{"annotations":{},"name":"serviceboards.airwallex.com"},"spec":{"group":"airwallex.com","names":{"kind":"ServiceBoard","plural":"serviceboards","shortNames":["svcb"],"singular":"serviceboard"},"scope":"Namespaced","versions":[{"additionalPrinterColumns":[{"jsonPath":".spec.serviceInfomation.pods.status.ready","name":"Ready","type":"string"},{"jsonPath":".spec.serviceInfomation.pods.imageTags","name":"ImageTags","type":"string"},{"jsonPath":".spec.serviceInfomation.ingress.hosts","name":"IngressHosts","type":"string"},{"jsonPath":".spec.serviceInfomation.updatedAt","name":"UpdatedAt","type":"date"}],"name":"v1alpha1","schema":{"openAPIV3Schema":{"properties":{"spec":{"properties":{"serviceInfomation":{"properties":{"clusterName":{"type":"string"},"ingress":{"properties":{"hos
@able8
able8 / check-key-expiration.sh
Created May 27, 2022 03:28
check SSL certificate and PGP key expiration date with shell
#!/bin/bash
# check TLS/SSL certificate expiration date
# openssl x509 -text -noout -in inputfile
# https://www.sslshopper.com/certificate-decoder.html
echo -e "\n## SSL Certificates List: \n\n| File Name | Valid From | Valid To | Comment |\n| --- | --- | --- | --- |" >> README.md
for file in $(find .); do
if test -f $file; then
if grep -q "\-BEGIN CERTIFICATE\-" $file; then
@able8
able8 / a-basic-controller-sample-code.go
Created April 29, 2022 13:12
A Basic Controller Sample Code
package main
import (
"flag"
"fmt"
"path/filepath"
"time"
"k8s.io/klog/v2"
_ "k8s.io/client-go/plugin/pkg/client/auth"
@able8
able8 / informer-example-coce.go
Created April 29, 2022 13:10
Informer Sample Code
package main
import (
"flag"
"log"
"path/filepath"
_ "k8s.io/client-go/plugin/pkg/client/auth"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
@able8
able8 / main.go
Last active December 24, 2021 09:06
Use client-go to create/generate/publish an Event object in Kuberentes
package main
import (
"flag"
"path/filepath"
_ "k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
#!/bin/bash
# ------------------------------------------------------------------------------
# 您好!本脚本纯shell编写,用于收集系统日志以及相关服务日志等,
#
# 目前兼容TKE的Ubuntu、Centos,脚本开源,您可以直接用vim打开脚本查阅里面的代码。
#
# 确认脚本无误后,放到容器节点运行。成功后,请把/tmp/tkelog/tkelog.tar.gz打包文件发我们进行问题排查,感谢您的支持!
# ------------------------------------------------------------------------------
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin/bash
version='2020.1'