Disable opening links in new windows

Many web pages force the link to open in a new window (or a new tab, collectively referred to as a new window below). Some people find this approach convenient, as it preserves the original page. But I don’t like this approach. Because I use Firefox, if I open a web page in a new window or tab, I can’t use the touchpad to swipe back to the previous page. Today, I’ll share with you the method to force the link to open in the current window or web page.

Golang gRPC Error Handling

The most common way to handle errors in gRPC is to return the error directly, e.g. return nil, err, but in practice, we also have business status codes to return, and the common way is to define an error code in the returned structure, but this is very cumbersome to write, for example, you may need to write it like this. 1 2 3 4 5 6 7 user, err := dao.

Grafana Releases Phlare, an Open Source Database for Large-Scale Continuous Performance profiling

Grafana Phlare is an open source software project for aggregating continuous profiling data.Grafana Phlare can be fully integrated with Grafana, allowing you to correlate it with other observable signals. What is continuous profiling? The concept is valuable: Profiling can help you understand the resource usage of your programs, which in turn can help you optimize their performance and cost. However, the shift to distributed cloud-native architectures complicates this, creating the need for continuous analytics, where information about resource usage is automatically collected periodically across the computing infrastructure, then compressed and stored as time-series data, which allows you to visualize changes over time and zoom in on profile files that match the time period of interest - For example, the amount of CPU time spent during its highest utilization.

Several ways to implement multi-tenancy capabilities in Kubernetes

When using Kubernetes, users often need to share the use of Kubernetes clusters (multi-tenancy) to simplify operations and reduce costs while meeting the needs of multiple teams and customers. While Kubernetes itself does not directly provide multi-tenancy capabilities, it provides a set of features that can be used to support the implementation of multi-tenancy. Based on these features, a number of projects have emerged in the Kubernetes community to implement multi-tenancy.

How to write kernel modules using rust

In recent years, the Rust language has gained a lot of developer attention for its memory safety, high reliability, and zero abstraction capabilities, which happen to be needed in kernel programming, so let’s try out how to write Linux kernel modules in rust. Rust and kernel modules Although Rust support has been merged into the mainline in Linux Kernel version 6.1, so in theory, developers can use Rust to write kernel modules for Linux 6.

Configuring GitHub Action cache for Rust projects

To speed up CI execution, caching is a very effective tool. Ensuring the highest utilization of the cache is the most important concern when using caching. For example, after caching the entire target directory, when do you update the cache? The best way to do this is when there is a dependency change, which is Cargo.lock for Rust and package.lock for Node. Let’s see how to use the cache component to achieve the above effect, with three main parameters.

Kubernetes application troubleshooting

Set reasonable Req and Limit If you don’t set Req and Limit, when the CPU and MEM of the application skyrocket, it will endanger other Pods on the same node, and even cause the cluster nodes to be crushed one by one. There are four values of Req and Limit, if only some of them are set, Kubelet will expel Pods when the node resource usage reaches Kubelet’s preset value, the order of expulsion is Guaranteed > Burstable > Best-Effort Where:

HTTP Protocol Introduction

HTTP is known as Hypertext Transfer Protocol, and there is a wide variety of information available on the Internet about the HTTP protocol, but most of them are listing the specific provisions of the HTTP protocol, and few of them are talking about the reasons why the HTTP protocol is designed this way. Today I will try to analyze the main features of the HTTP protocol from the perspective of problem solving, hoping to help you quickly understand the HTTP protocol.

slog: Golang's official structured logging package

Since its inception, Go has had the log package built into its standard library as a standard component of Go source output logging, and this package is widely used in the Go standard library itself and in Go community projects. However, for the Go standard library log package, the Go community has always demanded improvements, and the mainstream voice focuses on the following points. log packages are designed to be easily human readable and do not support structured logs that are easy to parse by machine such as outputting logs in json format like zap.

Writing maintainable unit test code in Golang

This article is about the maintainability of unit test code. I don’t know if you’ve ever written a spaghetti-style unit test, which is structured like this. Frankly, I’ve written quite a few. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 func TestFoo(t *testing.T) { // test get resp, err := GET(blabalbal) assert.Nil(err) ... // test post resp, err = POST(blabalbal) assert.Nil(err) ... // test update resp, err = PUT(blabalbal) assert.

Exploring container networking principles through Linux network virtualization technology

The essence of a container is a special process, special in that it creates a NameSpace isolated runtime environment and uses Cgroups to control resource overhead for it. With these two underlying technologies, we can successfully implement application containerization, but how to make multiple containers in the network environment without interfering with each other can still communicate with each other, so that containers can access the external network, so that

Docker Releases First Technical Preview of Integrated WebAssembly

Docker announced the first technical preview of its integration with WebAssembly (Docker+Wasm) and said the company has joined the Bytecode Alliance as a voting member. The Bytecode Alliance, founded by Mozilla, Fastly, Intel and Red Hat, is an organization that promotes WebAssembly standardization and aims to improve the WebAssembly ecosystem beyond the browser by collaboratively implementing standards and proposing new ones. It is currently actively promoting WASI (WebAssembly System Interface) to enable WebAssembly to securely access system resources such as files, networks, and memory.

Things we need to know about eBPF

What is eBPF eBPF, known as Extended Berkeley Packet Filter, is derived from BPF (Berkeley Packet Filter), which is a functional module for network message filtering. However, eBPF has evolved into a general-purpose execution engine, essentially a virtual machine-like function module in the kernel. eBPF allows developers to write custom code that runs in the kernel and is dynamically loaded into the kernel, attached to a kernel event that handles the execution of the eBPF program, without the need to recompile a new kernel module, and can dynamically load and unload eBPF programs as needed.

Useful new features or functionality in Python 3.11

Preface This article explains the important new features of Python 3.11, but there are still many small changes, so I won’t mention them one by one, so if you’re interested, you should read the official changelog to understand them. Speed improvements This is the most exciting news ever. The official website says : CPython 3.11 is on average 25% faster than CPython 3.10 when measured with the pyperformance benchmark suite, and compiled with GCC on Ubuntu Linux.

Visualizing kubernetes Tcp Traffic with k8spacket and Grafana

Do you know what your K8s cluster is doing when you’re not using it? Who established TCP communication with him? Who is he calling? Using k8spacket and Grafana, we can visualize the TCP traffic in the cluster so we can understand how workloads are communicating with each other. Check how many connections were established, how many bytes were exchanged, and how long those connections were active. Introduction k8spacket is a tool written in Golang that uses the gopacket third-party library to sniff TCP packets (incoming and outgoing) on workloads, and it creates TCP listeners on the running container network interface.

New features in Python 3.11 related to the type system.

PEP 646 - Variadic Generics Before introducing this PEP, we need to make up some knowledge, so let’s go deeper and deeper to understand the Generics first. A generic type is a feature that does not specify a specific type in advance when defining a function or class, but specifies the type at the time of use. For dynamic languages like Python, since everything is an object reference, you can determine the type directly at the time of use.

How to fix a Kubernetes cluster after changing IPs

Document a fix for a cluster failure caused by an IP change. There are two clusters, one is a single node (allinone) and the other is a four node (3 master 1 node) cluster. 1. Update Etcd certificate Backup Etcd certificate at each Etcd node. 1 cp -R /etc/ssl/etcd/ssl /etc/ssl/etcd/ssl-bak View the domain in the Etcd certificate 1 2 3 openssl x509 -in /etc/ssl/etcd/ssl/node-node1.pem -noout -text|grep DNS DNS:etcd, DNS:etcd.kube-system, DNS:etcd.kube-system.svc, DNS:etcd.

Differences between kubectl create and kubectl apply

kubectl is a command line tool (CLI) for Kubernetes, mainly used to help you manage Kubernetes clusters, deploy applications, view and manage resources and records in various clusters. When we want to create resources, we often use kubectl create or kubectl apply to create resources. Is it really the literal meaning (create/apply)? In this article, we will explore this question. Imperative vs. Declarative When we built the Kubernetes resource, we basically split it into two strategies, and understanding the difference between the two is critical to the future implementation of GitOps or IaC, and should be thoroughly understood.

The Simplest Git Server

A programmer’s code repository always needs to be hosted on a server to be safe and easy to use. Today we’re going to talk about Git servers. 1. Code Hosting Services In general, it’s not recommended to build your own Git server, but rather to use an off-the-shelf service, known as a code hosting service. They are free. GitHub Gitlab Bitbucket Codeberg sourcehut These are external services, so I won’t go into much detail.

Managing multiple Go versions via brew on Mac

Overview Because there are many projects to maintain, and because these projects have different histories, some may have been written by myself, some have been taken over from others, one of the problems we are facing is that Go versions may not be consistent, but you don’t dare to take the risk of upgrading to a consistent version, after all, the test coverage is not enough to give me confidence to do so.