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 / kcgroups.md
Created April 12, 2024 08:58 — forked from mcastelino/kcgroups.md
Kubernetes and cgroups Resource Management/Static cpuManagerPolicy/Memory and Resource Isolation & Scheduling

Overview

The goal of this document to cover all aspects of Kubernetes management, including how resources are expressed, constrained and accounted for. This started a way to ensure that alternate container runtime implementation like Kata containers will behave from a resource accounting and consumption point of view in the same manner as runc.

Location of the latest version of this document: https://gist.github.com/mcastelino/b8ce9a70b00ee56036dadd70ded53e9f

If you do not understand cgroups please refer to a quick primer at the bottom of this document. This will help you understand how the resource enforcement actually works.

Kubernetes Resource Management

@phosae
phosae / kubevirt-centos-Dockerfile
Created October 12, 2023 08:45
Dockerfile for KubeVirt VM
FROM busybox:1.35.0
ADD centos.qcow2 /disk/ # centos.qcow2 or centos.img
RUN chmod 766 disk
@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"
)
@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 / How-To-Kubernetes.md
Last active August 14, 2024 06:51
How-To-Kubernetes

How-To-Kubernetes

Basics

@phosae
phosae / How-To-Golang.md
Last active March 22, 2023 03:53
how to golang
@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 / 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 / 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