Module: NODE

Mange nodes in a declarative manner


Concept

Node is an abstraction of hardware resources, which can be bare metal, virtual machines, or even k8s pods.

There are different types of nodes in Pigsty:

  • Common nodes, nodes that managed by Pigsty
  • Admin node, the node where pigsty is installed and issue admin commands
  • The Infra node, the node where the INFRA module is installed, admin node are usually the first of all infra nodes.

Common Node

You can manage nodes with Pigsty, and install modules on them. The node.yml playbook will adjust the node to desired state.

Some services will be added to all nodes by default:

ComponentPortDescription
Node Exporter9100Node Monitoring Metrics Exporter
HAProxy Admin9101HAProxy admin page
Promtail9080Log collecting agent

Admin Node

There is one and only one admin node in a pigsty deployment, which is specified by admin_ip. It is set to the local primary IP during configure.

The node will have ssh / sudo access to all other nodes, which is critical; ensure it’s fully secured.

INFRA Node

A pigsty deployment may have one or more infra nodes, usually 2 ~ 3, in a large production environment.

The infra group specifies infra nodes in the inventory. And infra nodes will have INFRA module installed (DNS, Nginx, Prometheus, Grafana, etc…),

The admin node is also the default and first infra node, and infra nodes can be used as ‘backup’ admin nodes.

PGSQL Node

The node with PGSQL module installed is called a PGSQL node. The node and pg instance is 1:1 deployed. And node instance can be borrowed from corresponding pg instances with node_id_from_pg.

ComponentPortDescription
Postgres5432Pigsty CMDB
Pgbouncer6432Pgbouncer Connection Pooling Service
Patroni8008Patroni HA Component
Haproxy Primary5433Primary connection pool: Read/Write Service
Haproxy Replica5434Replica connection pool: Read-only Service
Haproxy Default5436Primary Direct Connect Service
Haproxy Offline5438Offline Direct Connect: Offline Read Service
Haproxy service543xCustomized Services
Haproxy Admin9101Monitoring metrics and traffic management
PG Exporter9630PG Monitoring Metrics Exporter
PGBouncer Exporter9631PGBouncer Monitoring Metrics Exporter
Node Exporter9100Node Monitoring Metrics Exporter
Promtail9080Collection of Postgres, Pgbouncer, Patroni logs (Optional)
vip-manager-Bind VIP to the primary

Administration

Add Node

To add a node into Pigsty, you need to have nopass ssh/sudo access to the node

  1. bin/node-add [ip...] # add node to pigsty: ./node.yml -l <cls|ip|group>

Remove Node

To remove a node from Pigsty, you can use the following:

  1. bin/node-rm [ip...] # remove node from pigsty: ./node-rm.yml -l <cls|ip|group>

Create Admin

If the current user does not have nopass ssh/sudo access to the node, you can use another admin user to bootstrap the node:

  1. node.yml -t node_admin -k -K -e ansible_user=<another admin> # input ssh/sudo password for another admin

Playbooks


Dashboards

There are four dashboards for NODE module.


Parameters

There are 9 sections, 58 parameters about NODE module.

Parameters

ParameterSectionTypeLevelComment
nodenameNODE_IDstringInode instance identity, use hostname if missing, optional
node_clusterNODE_IDstringCnode cluster identity, use ’nodes’ if missing, optional
nodename_overwriteNODE_IDboolCoverwrite node’s hostname with nodename?
nodename_exchangeNODE_IDboolCexchange nodename among play hosts?
node_id_from_pgNODE_IDboolCuse postgres identity as node identity if applicable?
node_default_etc_hostsNODE_DNSstring[]Gstatic dns records in /etc/hosts
node_etc_hostsNODE_DNSstring[]Cextra static dns records in /etc/hosts
node_dns_methodNODE_DNSenumChow to handle dns servers: add,none,overwrite
node_dns_serversNODE_DNSstring[]Cdynamic nameserver in /etc/resolv.conf
node_dns_optionsNODE_DNSstring[]Cdns resolv options in /etc/resolv.conf
node_repo_methodNODE_PACKAGEenumChow to setup node repo: none,local,public
node_repo_removeNODE_PACKAGEboolCremove existing repo on node?
node_repo_local_urlsNODE_PACKAGEstring[]Clocal repo url, if node_repo_method = local
node_packagesNODE_PACKAGEstring[]Cpackages to be installed current nodes
node_default_packagesNODE_PACKAGEstring[]Gdefault packages to be installed on all nodes
node_disable_firewallNODE_TUNEboolCdisable node firewall? true by default
node_disable_selinuxNODE_TUNEboolCdisable node selinux? true by default
node_disable_numaNODE_TUNEboolCdisable node numa, reboot required
node_disable_swapNODE_TUNEboolCdisable node swap, use with caution
node_static_networkNODE_TUNEboolCpreserve dns resolver settings after reboot
node_disk_prefetchNODE_TUNEboolCsetup disk prefetch on HDD to increase performance
node_kernel_modulesNODE_TUNEstring[]Ckernel modules to be enabled on this node
node_hugepage_countNODE_TUNEintCnumber of 2MB hugepage, take precedence over ratio
node_hugepage_ratioNODE_TUNEfloatCnode mem hugepage ratio, 0 disable it by default
node_overcommit_ratioNODE_TUNEintCnode mem overcommit ratio (50-100), 0 disable it by default
node_tuneNODE_TUNEenumCnode tuned profile: none,oltp,olap,crit,tiny
node_sysctl_paramsNODE_TUNEdictCsysctl parameters in k:v format in addition to tuned
node_dataNODE_ADMINpathCnode main data directory, /data by default
node_admin_enabledNODE_ADMINboolCcreate a admin user on target node?
node_admin_uidNODE_ADMINintCuid and gid for node admin user
node_admin_usernameNODE_ADMINusernameCname of node admin user, dba by default
node_admin_ssh_exchangeNODE_ADMINboolCexchange admin ssh key among node cluster
node_admin_pk_currentNODE_ADMINboolCadd current user’s ssh pk to admin authorized_keys
node_admin_pk_listNODE_ADMINstring[]Cssh public keys to be added to admin user
node_timezoneNODE_TIMEstringCsetup node timezone, empty string to skip
node_ntp_enabledNODE_TIMEboolCenable chronyd time sync service?
node_ntp_serversNODE_TIMEstring[]Cntp servers in /etc/chrony.conf
node_crontab_overwriteNODE_TIMEboolCoverwrite or append to /etc/crontab?
node_crontabNODE_TIMEstring[]Ccrontab entries in /etc/crontab
haproxy_enabledHAPROXYboolCenable haproxy on this node?
haproxy_cleanHAPROXYboolG/C/Acleanup all existing haproxy config?
haproxy_reloadHAPROXYboolAreload haproxy after config?
haproxy_auth_enabledHAPROXYboolGenable authentication for haproxy admin page
haproxy_admin_usernameHAPROXYusernameGhaproxy admin username, admin by default
haproxy_admin_passwordHAPROXYpasswordGhaproxy admin password, pigsty by default
haproxy_exporter_portHAPROXYportChaproxy admin/exporter port, 9101 by default
haproxy_client_timeoutHAPROXYintervalCclient side connection timeout, 24h by default
haproxy_server_timeoutHAPROXYintervalCserver side connection timeout, 24h by default
haproxy_servicesHAPROXYservice[]Clist of haproxy service to be exposed on node
node_exporter_enabledNODE_EXPORTERboolCsetup node_exporter on this node?
node_exporter_portNODE_EXPORTERportCnode exporter listen port, 9100 by default
node_exporter_optionsNODE_EXPORTERargCextra server options for node_exporter
promtail_enabledPROMTAILboolCenable promtail logging collector?
promtail_cleanPROMTAILboolG/Apurge existing promtail status file during init?
promtail_portPROMTAILportCpromtail listen port, 9080 by default
promtail_positionsPROMTAILpathCpromtail position status file path

Last modified 2023-02-27: add v2.0 images and docs (5b09f12)