ETCD

  •  ETCD : Port 2379 : You can then attach any service or client.

 


 A default client that comes with Etcd is  Ectd control client. It is command line client for etcd

etcd is a distributed key-value store used for the management of distributed systems. It is a crucial component in many cloud-native and container orchestration platforms such as Kubernetes. Here are some key points about etcd:

  1. Distributed Key-Value Store: etcd provides a reliable way to store and manage data across a distributed cluster of machines. It is based on a simple key-value pair data model.

  2. Consistency and Reliability: etcd is designed to be highly available and fault-tolerant. It uses a consensus algorithm (Raft) to ensure consistency and reliability in a distributed environment.

  3. Raft Consensus Algorithm: Raft is a consensus algorithm that etcd uses to ensure that all nodes in a cluster agree on the state of the system. It helps in maintaining consistency even in the presence of network partitions or node failures.

  4. Configuration Management: etcd is often used for configuration management in distributed systems. It allows services to dynamically discover and update their configurations.

  5. Service Discovery: etcd can be used as a service discovery mechanism. Applications can register their services, and others can discover and connect to these services through etcd.

  6. Distributed Locks: etcd provides support for distributed locks, which can be used to coordinate actions across multiple nodes in a distributed system.

  7. Used in Kubernetes: Kubernetes, the popular container orchestration platform, relies heavily on etcd for storing its cluster state, configuration, and metadata. Each Kubernetes cluster typically has a dedicated etcd cluster.

  8. API: etcd provides a simple HTTP/JSON API, making it easy to interact with programmatically. Clients can use tools like curl or programming languages like Go or Python to interact with etcd.

  9. Security: etcd supports encryption in transit and at rest, authentication, and authorization to ensure the security of the stored data.

  10. Open Source: etcd is an open-source project and is part of the Cloud Native Computing Foundation (CNCF). It is actively developed and maintained by the community.

When working with etcd, it's important to consider factors such as data consistency, availability, and partition tolerance, especially in distributed and highly dynamic



The Etcd datastore stores data about the cluster such as information about the cluster

If you setup your cluster using Kubeadm , then kubeadm deployes the etcd server as a Pod in the kube system namespace . You can explore the etcd control database using etcdctl utility .

kubectl get pods -n kube-system

You can explore the etcdctl utility using the etcdctl utility

To list all keys stores by kubernetes

etcctl get / --prefix -keys-only

The root directory is a registry and under that you have the various constructs

kubernetes stores data in the specific data structure .  kubernetes store data in a specific directory structure
The root directory under which we have various kubernetes constructs such as minions and nodes.


In a High Availability Environment you will have multiple master nodes in the cluster . And you will have multiple etcd spread across the master nodes. In that case make sure etcd instances know about each other by setting the right parameter in the etcd service configuration files. 

The initial cluster option is where you will set the instances of the etcd service . We speak about HA much more detail in this course.


ETCD - Commands (Optional)

(Optional) Additional information about ETCDCTL Utility

ETCDCTL is the CLI tool used to interact with ETCD.

ETCDCTL can interact with ETCD Server using 2 API versions - Version 2 and Version 3.  By default its set to use Version 2. Each version has different sets of commands.

For example ETCDCTL version 2 supports the following commands:

    etcdctl backup
    etcdctl cluster-health
    etcdctl mk
    etcdctl mkdir
    etcdctl set


Whereas the commands are different in version 3

    etcdctl snapshot save
    etcdctl endpoint health
    etcdctl get
    etcdctl put


To set the right version of API set the environment variable ETCDCTL_API command

export ETCDCTL_API=3


When API version is not set, it is assumed to be set to version 2. And version 3 commands listed above don't work. When API version is set to version 3, version 2 commands listed above don't work.


Apart from that, you must also specify path to certificate files so that ETCDCTL can authenticate to the ETCD API Server. The certificate files are available in the etcd-master at the following path. We discuss more about certificates in the security section of this course. So don't worry if this looks complex:

    --cacert /etc/kubernetes/pki/etcd/ca.crt     
    --cert /etc/kubernetes/pki/etcd/server.crt     
    --key /etc/kubernetes/pki/etcd/server.key



So for the commands I showed in the previous video to work you must specify the ETCDCTL API version and path to certificate files. Below is the final form:


    kubectl exec etcd-master -n kube-system -- sh -c "ETCDCTL_API=3 etcdctl get / --prefix --keys-only --limit=10 --cacert /etc/kubernetes/pki/etcd/ca.crt --cert /etc/kubernetes/pki/etcd/server.crt  --key /etc/kubernetes/pki/etcd/server.key"

The etcd datastore 

we set in etcd.service configuration. If you want etcd instances to know each other you need to configure this file.








This is the URL which you need to update on High Availability in kubernetes .


This is the URL that needs to configured in the kubeApi server when it tries to reach the etcd server.





Comments

Popular posts from this blog

Delploy Cluster : Managed K8 & Self Managed K8

ctr | nerdctl | crictl

Deploy To Kubernetes with Jenkins GitOps GitHub Pipeline