Normally, we use the touch command to create an empty file.
However, when we are troubleshooting or want to test in some specific scenario, we may need a large file of a specific size, such as 500 MB or 2 GB.
At this point, we can’t just create an empty file and start writing random data to it.
Is there any way to create a new file of a specific size?
How Prometheus' Time series database stores and manages data
This article is mainly to organize how Prometheus’ time series database stores and manages the data, I hope this article can bring you some inspiration.
Overview Let’s take a look at the entire architecture of Prometheus.
For Prometheus Server, the entire data processing process is divided into three parts: Exporter metrics collection, Scraper data capture, TSDB data storage and query; Exporter in fact, different services have different collection implementations, similar to Mysqld-exporter, node exporter, etc.
Configuring Hosts Static Resolution for CoreDNS
CoreDNS is Rancher’s default DNS component and you want it to return hosts static file results instead of querying upstream DNS servers.
This solves the problem of upstream DNS servers not being able to resolve the queried domain name at all.
Configuring hosts ConfigMap Under the kube-system namespace, create a new ConfigMap coredns-hosts.
1 2 3 4 5 6 7 8 9 apiVersion: v1 kind: ConfigMap metadata: name: coredns-hosts namespace: kube-system data: coredns-hosts: |- 127.
MacOS Ventura system ssh no longer supports ssh-rsa reasons and solutions
After upgrading to MacOS Ventura, if you try to log in to the server with ssh, you will probably find that you can’t log in anymore.
1 2 3 $ ssh 192.1681.86 Unable to negotiate with 192.168.1.86 port 22: no matching host key type found. Their offer: ssh-rsa Troubleshooting From the error message, it is easy to deduce that the local ssh does not accept the public key type provided by the server sshd.
Quickly delete all useless Docker resources (containers, container images, networks)
Every once in a while, my local Docker container image takes up a lot of space on my hard drive, so I clean it up regularly, but this cleanup is not done often enough to remember the commands. In this article, I’m going to organize a few common commands, so I can easily look up commands in the future.
List all dangling images dangling images are container images that are left behind during each docker build.
Accessing a virtual disk using a loop device
The loop device is a virtual device under Linux. It is widely used for processing files such as virtual disks and ISO images. Recently, I have been working on an ARM virtual system, and I need to use the loop device to create a system image. It took a lot of research to get a relatively comprehensive understanding of it. In order to make the article clear, this article will also introduce the basics of Linux disk management.
Zero-copy in golang
Zero-copy techniques are also used extensively in the Go standard library to improve performance. Since many zero-copy related techniques are provided through system calls, these system calls are also encapsulated in the Go standard library, and the related encapsulated code can be found in internal/poll.
Let’s take Linux as an example, after all, most of our applications are running on Linux.
sendfile The sendfile system call is encapsulated in the internal/poll/sendfile_linux.
Zero-copy technology
The term “zero copy” has different meanings in some contexts. In this article, zero copy is what we often say, through this technology to free the CPU not to perform the function of data copy in memory, or to avoid unnecessary copies, so that zero copy is not no data copy (copy), but in a broad sense to reduce and avoid unnecessary data copy, can be used to save CPU use and internal bandwidth, such as high-speed transfer of files through the network, the implementation of network proxy, etc.
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.