Some of golang's libraries for time and timed tasks

Avoid reinventing the wheel. If there are some good libraries, we just use them directly, there is no need to do some duplicate work, if these libraries can not meet the needs, may be submitted pull request or clone them, enhance them, optimize them, the current premise is that you have to know them. This article gives you some information about the time and similar linux cron function of the

How to Implement a Kubernetes CSI Driver

I’ve been maintaining a CSI Driver for about a year and a half now, and I’ve been asked by some of my friends about CSI-related issues and how to develop their own CSI Driver. This post is about how to quickly develop your own Kubernetes CSI Driver. CSIbuilder In fact, CSI Driver is nothing more than an interface that implements the logic of a third-party storage. A short sentence contains a lot of work and is tedious, and requires a clear understanding of how CSI works, but the good news is that the work is traceable.

Vue3 Script Setup

Two years ago, shortly after vue3 was released, an sfc proposal was created that allowed all top-level variables in scripts to be bound to templates by default to close one of the gaps in the developer experience with react. Similar to this: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 <script setup> // imported components are also directly usable in template import Foo from '.

How does Karmada implement a complete custom resource distribution capability across clusters?

Introduction to Karmada Before we start talking about Resource Interpreter Webhook, we need to have some understanding of Karmada’s infrastructure and how to distribute applications, but that part has been mentioned in previous blogs, so we won’t go over it again in this post. An example: Creating an nginx application Let’s start with the simplest example, creating and distributing an nginx application in Karmada; the first step is to prepare the nginx resource template, which is the native K8s Deployment and does not require any changes.

Kubernete Operator with multi-cluster support

In previous articles we have discussed how to design and implement an operator within a single kubernetes cluster, but as our application scales up or for various other reasons within the company (e.g. permissions, etc.) we have to adopt multiple kubernetes clusters to meet our needs. How does our operator fit into this multi-cluster scenario? Of course, there are many solutions for multi-cluster scenarios, such as ClusterNet, Karmada, and so on.

Go 1.20 New Features Preview

In a recent article “Thirteen Years of Go” published by Russ Cox on behalf of the Go core team, he mentioned that “In Go’s 14th year, the Go team will continue to strive to make Go the best environment for large-scale software engineering, with a special focus on supply chain security, improved compatibility, and structured logging. Of course there will be many other improvements, including profile-guided optimization. The current version under development is Go 1.

Running Mongodb in Docker

This article describes in detail how to run Mongodb in docker. I am using wsl ubuntu 20.04 as my operating system. Install docker (If you already have docker installed, you can skip this step…) For ubuntu, you can refer to this tutorial: Install Docker Engine on Ubuntu. Check the version of docker. 1 2 3 $ sudo docker --version [sudo] password for pengfei: Docker version 20.10.18, build b40c2f6 Download and run the mongo image Download the mongo image from docker hub

Reflecting channels in gong

1. The “limitations” of channel syntax The Go language implements a concurrency scheme based on the theory of CSP (Communicating Sequential Processes). The scheme consists of two important elements: the Goroutine, which is the basic building block and execution unit for concurrent design of Go applications, and the channel, which plays an important role in the concurrency model. channel can be used to implement both inter-Goroutine communication and inter-Goroutine synchronization.

Implementing an HTTP file server from scratch using Golang

HTTP Protocol Basics The HTTP protocol is an application layer protocol that was generally implemented based on the TCP protocol prior to HTTP/3. Because TCP protocol is a reliable streaming communication protocol, after a connection is established, both senders and receivers can send data of any length, and the TCP stack may also do slicing of the data. So TCP-based application layer protocols need to negotiate the message transmission format so that both senders and receivers can extract the complete message from the received data stream.

Concurrency Programming in Golang

This article introduces the concepts, usage and issues to keep in mind for concurrent programming in Go. As we said before, Go is a procedural oriented language. The default program starts with the main function, executes the code line by line, and can only use one core of the CPU. As an example. 1 2 3 4 files := []string{"a.txt", "b.txt", "c.txt"} for _, f := range files { Compress(f) } Assume that Compress will compress the files according to the path passed in.

How to monitor TCP in K8s Pod

In the Kubernetes system, each container resource monitoring information is collected by the kubelet’s built-in cadvisor component, but officially, based on performance-related considerations, it would consume a lot of CPU memory resources to capture the network-related metrics in each container, so the collection of network and other related metrics is turned off by default in cadvisor. https://github.com/google/cadvisor/blob/master/docs/runtime_options.md#metrics https://github.com/kubernetes/kubernetes/issues/60279 So in the kubelet cadvisor metrics endpoint that prometheus crawls by default, the metrics container_network_tcp_usage_total and container_network_udp_usage_total are all 0, but the actual business monitoring may require the collection of these metrics for monitoring alarms and troubleshooting problems.

What exactly does the linking process do?

Overview Generally speaking, turning a C source file into an executable requires compiling to generate a target file, and then linking multiple target files to create the final executable. Write source code -> Compile to generate target file -> Link to generate executable file Because the code in our projects is often scattered in different files, we need to synthesize multiple target files into one executable, and as for how to do that, that’s what linking is going to do.

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.