runc init workflow

Runc is a CLI tool for spawning and running containers on Linux according to the OCI specification. It’s implementation is based on various kinds isolated namespaces of linux. When we run runc create or runc exec commands, what happens? The runc cli command will fork it self several times to initialize different namespaces, and finally enter the go runtime. the whole flow of different phases as follows:…

client-go leader election example with explanation

This article will show the codes of leader election, first, let’s look at the demonstration below. First, the Local terminal got the lease, we can confirm that be executing kubectl get lease command. then I terminated the program in the Local terminal, then, we can find the Local(2) terminal got the lease. Finally, I closed the tunnel connection between my computer and my kubernetes cluster, we can find current leader…

How to create a kubernetes client using client-go library

A kubernetes client is a http client that can connect to a kubernetes cluster, and do resources creation, deletion etc. Before create a client, we must know the server address and port, cluster’s ca cert, and the client tls key or a service account token file. Usually, these information can be automatically obtained from KUBECONFIG file or pod service account by client-go, so next, I will introduce some common ways…

kubernetes client-go Quantity explanation

What is quantity? quantity is a string representation of some countable resources, comprised by a number, either an int64 or a bigint value, and a unit suffix. for example 100Mi, 1000m, 100. The resources can be cpu, gpu, memory, pods, ephemeral-storage, etc, we can get the full resources list from the nodes.Status.Capacity. In this article, we mainly talk about how to use quantity in client-go library. First, let’s see how…