Skip to content

Instantly share code, notes, and snippets.

View phosae's full-sized avatar
:octocat:
coffee ☕ , beer 🍺 and imagination 🧿

zengxu phosae

:octocat:
coffee ☕ , beer 🍺 and imagination 🧿
View GitHub Profile
@phosae
phosae / OkHttpUtils.java
Last active February 17, 2023 03:50
treenity
package dev.zeng.util;
import okhttp3.*;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.TimeUnit;
public class OkHttpUtils {
private static volatile OkHttpClient okHttpClient = null;
@phosae
phosae / ctr_set_maxprocs.go
Last active December 30, 2022 09:36
using uber automaxprocs to set GOMAXPROCS correctly in container context
package main
import (
"fmt"
"runtime"
"go.uber.org/automaxprocs/maxprocs"
)
func main() {
@phosae
phosae / kube-cAdvisor.md
Last active January 9, 2023 13:02
kube metrics

CPU

rate(container_cpu_usage_seconds[10m])/(container_spec_cpu_quota / container_spec_cpu_period)

by Pod and Container

sum(rate(container_cpu_usage_seconds_total{name!~".*prometheus.*", image!="", container!="POD"}[5m])) by (pod, container) 
/
sum(container_spec_cpu_quota{name!~".*prometheus.*",image!="",container!="POD"}/container_spec_cpu_period{name!~".*prometheus.*", image!="", container!="POD"}) by (pod, container) * 100
@phosae
phosae / args.md
Created February 7, 2023 08:49
Docker Buildx Args

https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope

The following ARG variables are set automatically:

  • TARGETPLATFORM - platform of the build result. Eg linux/amd64, linux/arm/v7, windows/amd64.
  • TARGETOS - OS component of TARGETPLATFORM, Eg linux, windows, wasi
  • TARGETARCH - architecture component of TARGETPLATFORM, Eg amd64, arm64, wasm32
  • TARGETVARIANT - variant component of TARGETPLATFORM
  • BUILDPLATFORM - platform of the node performing the build.
  • BUILDOS - OS component of BUILDPLATFORM
@phosae
phosae / imagetools.md
Last active June 28, 2024 10:30
Dockerless image

ko for Golang

# simple main
KO_DOCKER_REPO=zengxu ko build --platform linux/amd64,linux/arm64 -B -t `<tag>`
# cmd style
KOCACHE=/tmp/ko KO_DOCKER_REPO=zengxu ko build --platform linux/amd64 qiniu.com/dora-cloud/next/app/application-controller

change base image --> KO_DEFAULTBASEIMAGE

kyverno examples of ko

@phosae
phosae / How-To-Golang.md
Last active March 22, 2023 03:53
how to golang
@phosae
phosae / How-To-Kubernetes.md
Last active August 14, 2024 06:51
How-To-Kubernetes

How-To-Kubernetes

Basics

@phosae
phosae / what-is-cloud-native.md
Last active February 16, 2023 06:50
What is Cloud Native

The Cloud Native Computing Foundation provides the official definition:

Cloud native technologies empower organizations to build and run scalable applications in modern, dynamic environments such as public, private, and hybrid clouds. Containers, service meshes, microservices, immutable infrastructure, and declarative APIs exemplify this approach.

These techniques enable loosely coupled systems that are resilient, manageable, and observable. Combined with robust automation, they allow engineers to make high-impact changes frequently and predictably with minimal toil.

MicroSoft's Architecting Cloud Native .NET Applications for Azure covers more details.

Gitlab says:

Cloud native is an approach that uses technologies such as containers, Kubernetes, immutable infrastructure, and microservices to develop scalable appl

@phosae
phosae / fork_and_daemon.go
Created March 22, 2023 08:08 — forked from wrfly/fork_and_daemon.go
golang fork and exec and handle signals
package main
import (
"flag"
"fmt"
"log"
"os"
"os/signal"
"syscall"
)