Posts

KB:Process Manager (Supervisord/Tini)

Image
The container process manager, often referred to as an "init system" (such as tini or supervisord), is a lightweight and essential component within containerized environments. Acting as the first process (PID 1) in a container, its primary responsibility is to monitor and manage all subsequent processes, ensuring that any child processes are properly started, monitored, and restarted in case of failure. This process manager is critical for maintaining container stability, as it handles important tasks like reaping zombie processes, forwarding system signals, and ensuring that resource consumption remains efficient.  However, it is not considered best practice to run multiple processes within a single container or pod; each pod/container should have a primary init process focused on a single responsibility to align with the principles of containerization, such as process isolation and microservices architecture. References:  https://docs.docker.com/engine/containers/multi-serv...

KB:Kubectl EXPLAIN

Describe fields and structure of various resources. This command describes the fields associated with each supported API resource. Fields are identified via a simple JSONPath identifier: Behind the scenes, kubectl just made an API request to my Kubernetes cluster, grabbed the current Swagger documentation of the API version running in the cluster, and output the documentation and object types. kubectl explain deployment kubectl explain deployment -- recursive kubectl explain deployment.spec.strategy References: https://kubernetes.io/docs/reference/kubectl/generated/kubectl_explain/ https://blog.heptio.com/kubectl-explain-heptioprotip-ee883992a243

KB:Kubernetes ReplicaSet

Image
A ReplicaSet's purpose is to maintain a stable set of replica Pods running at any given time. Usually, you define a Deployment and let that Deployment manage ReplicaSets automatically. --- The reason why the Selector is added to the spec of a Kubernetes ReplicaSet is to allow it to manage Pods that match a specified label, regardless of whether the ReplicaSet itself created them . This is particularly useful because it enables the ReplicaSet to manage Pods that might have been created manually or by another process (assuming they don't already have another controller managing them). As long as the Pods have the same labels that match the ReplicaSet's Selector, the ReplicaSet controller will treat them as its own and manage their lifecycle—ensuring the desired number of replicas is running. This behavior helps the controller maintain the correct state, but it also means care should be taken when using labels to avoid conflicting control over Pods by different controllers. Wh...

KB: Kubectl auto completion setup

kubectl completion Synopsis Output shell completion code for the specified shell (bash, zsh, fish, or powershell). The shell code must be evaluated to provide interactive completion of kubectl commands. This can be done by sourcing it from the .bash_profile. Detailed instructions on how to do this are available here: for macOS: https://kubernetes.io/docs/tasks/tools/install-kubectl-macos/#enable-shell-autocompletion for linux: https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/#enable-shell-autocompletion for windows: https://kubernetes.io/docs/tasks/tools/install-kubectl-windows/#enable-shell-autocompletion Note for zsh users: [1] zsh completions are only supported in versions of zsh >= 5.2. kubectl completion SHELL ref: https://kubernetes.io/docs/reference/kubectl/generated/kubectl_completion/

KB:Json Path Query

Image
Jason root = $ $.element. if you have "jq" installed you can use the -c 'path'  to see compacted list of all the elements.  the $ symbol is often used to represent the root element in JSON data when using tools or languages that support JSONPath, which is a query language for JSON data similar to XPath for XML. Here's why and how it's used: Why Use $ in JSONPath? Root Reference: The $ symbol in JSONPath represents the root object or array. It's a way to anchor your query to the very beginning of the JSON structure. Navigation: From the $ root, you can navigate through the JSON structure to access nested elements or values by specifying keys or indices.   Function Description Example Result text the plain text kind is {.kind} kind is List @ the current object {@} the same as input .  or  [] child operator {.kind} ,  {['kind']}  or  {['name\.type']} List .. recursive descent {..name} 127.0.0.1 127.0.0.2 myself e2e * wildcard. Get all ob...

KB:LLM Vectors vs Embeddings

Image
The sequence is from "Text" to "Tokens," then "Vectors," and finally "Embeddings." In data processing and machine learning, the creation or extraction of a vector typically precedes the embedding process. Initially, data is converted into a vector form, which is a numerical representation, and then, embeddings are generated from these vectors. Embeddings are lower-dimensional representations that capture the relationships and features of the data, making it easier to use in various machine learning models.  This generalized concept reflects the idea that vectors serve as the foundation upon which embeddings are built. When a model is trained, the initial vectorized values (those random vectors assigned at the beginning) don’t exist separately after the embeddings are created. Here’s how it works: Training Process: Initial Vectors: These are the starting points, just random numbers. They exist at the beginning of the training process but are not ...

KB:SQL DDL/DML

Image
DDL (Data Definition Language) provides the ability to define, create and modify database objects such as tables, views, indexes, and users. DML (Data Manipulation Language) allows for manipulating data in a database, such as inserting, updating, and deleting records. In SQL, DDL (Data Definition Language) and DML (Data Manipulation Language) are two categories of SQL commands used for different purposes: Data Definition Language (DDL) DDL commands are used to define and manage database schema, which includes creating, altering, and deleting database objects such as tables, indexes, and views. Common DDL commands include: CREATE : Used to create database objects like tables, indexes, views, etc. Example: CREATE TABLE Employees ( EmployeeID int PRIMARY KEY, FirstName varchar ( 255 ), LastName varchar ( 255 ), BirthDate date ); ALTER : Used to modify an existing database object. Example: ALTER TABLE Employees ADD COLUMN Salary decimal ( 10 , 2 ); DROP : Used to...