Interaction between client-go and Kubernetes operator. Image from [sample-controller](https://github.com/kubernetes/sample-controller/blob/master/docs/images/client-go-controller-interaction.jpeg)

How to Write a Kubernetes Operator Using client-go

What is client-go? client-go is the official Golang client for Kubernetes, responsible for interacting with the Kubernetes API server using REST API. In fact, client-go can do almost anything, not just for writing operators. Even the internal implementation of kubectl is based on client-go. As for more specialized frameworks used to write operators, including controller-runtime , kubebuilder , and operator-sdk , they will be introduced later in this series. ...

Posted on: 2024-09-14 · Edited on: 2024-09-14 · Chi-Sheng Liu
Image modified from [Kubernetes Icons Set](https://github.com/kubernetes/community/tree/master/icons)

What are Kubernetes Operators and Custom Resources?

Kubernetes API Resources I assume that you have a basic understanding of Kubernetes and know how to use kubectl. Pod, ReplicaSet, Service, and even Namespace are actually types of API Resources. You can use kubectl api-resources to view all the API Resources currently available in your Kubernetes cluster. $ kubectl api-resources NAME SHORTNAMES APIVERSION NAMESPACED KIND bindings v1 true Binding componentstatuses cs v1 false ComponentStatus configmaps cm v1 true ConfigMap endpoints ep v1 true Endpoints events ev v1 true Event limitranges limits v1 true LimitRange namespaces ns v1 false Namespace nodes no v1 false Node persistentvolumeclaims pvc v1 true PersistentVolumeClaim persistentvolumes pv v1 false PersistentVolume pods po v1 true Pod podtemplates v1 true PodTemplate replicationcontrollers rc v1 true ReplicationController resourcequotas quota v1 true ResourceQuota secrets v1 true Secret serviceaccounts sa v1 true ServiceAccount services svc v1 true Service ... ...

Posted on: 2024-08-29 · Edited on: 2024-08-31 · Chi-Sheng Liu
Photo by [Kent Pilcher](https://unsplash.com/@kent_pilcher?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash) on [Unsplash](https://unsplash.com/photos/black-instrument-cluster-panel-jW8hkB_Qmj8?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash)

How to Reproduce Kubernetes Node-pressure Eviction via K3d

Background A few days ago, while developing the KubeRay project, I learned about a Kubernetes behavior from the issue’s comment section . There are two types of Eviction: Node-pressure Eviction and API-initiated Eviction . API-initiated Eviction is done by directly calling the API or using commands like kubectl drain. Pods evicted this way will ultimately be deleted and usually recreated on another node. However, for Node-pressure Eviction, kubelet will only set the Pod’s Phase to Failed without deleting it. Therefore, if the controller does not handle it properly, the Pod will not be recreated on another node. ...

Posted on: 2024-07-05 · Edited on: 2024-08-31 · Chi-Sheng Liu