You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+63-1Lines changed: 63 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,10 @@ This project contains multiple plugins for Apache Hadoop, which are intended to
6
6
7
7
1. OpenPolicyAgent (OPA) authorizer: For every action performed in HDFS an OPA instance is asked if the user is allowed to perform the action.
8
8
2. GroupMapper: It can look up group memberships for users from an OPA instance.
9
-
3.Not (yet?) in this repository is a [TopologyProvider](https://github.com/stackabletech/hdfs-topology-provider/).
9
+
3.TopologyProvider: It is used to feed information from Kubernetes into the HDFS rack awareness functionality.
10
10
11
11
## Installation
12
+
12
13
Run `mvn package` and put the resulting `target/hdfs-utils-*.jar` file on your HDFS classpath.
13
14
The easiest way to achieve this is to put it in the directory `/stackable/hadoop/share/hadoop/tools/lib/`.
14
15
The Stackable HDFS already takes care of this, you don't need to do anything in this case.
@@ -650,3 +651,64 @@ and the Hadoop logs will show that the lookup has taken place:
650
651
- Groups for [nn]: [[admin, superuser]]
651
652
```
652
653
654
+
## Network Topology Provider
655
+
656
+
Hadoop supports a concept called [rack awareness](https://hadoop.apache.org/docs/stable/hadoop-project-dist/hadoop-common/RackAwareness.html) (lately also often called topology awareness).
657
+
658
+
Historically this has been used to distinguish racks, datacenters and the like and often been read from a manually updated topology file or similar solutions.
659
+
660
+
In Kubernetes, the most commonly used mechanism for topology awareness are labels - mostly labels set on the Kubernetes nodes.
661
+
The most prevalent example for this is the node label [topology.kubernetes.io/zone](https://kubernetes.io/docs/reference/labels-annotations-taints/#topologykubernetesiozone) which often refers to availability zones in cloud providers or similar things.
662
+
663
+
The purpose of this tool is to feed information from Kubernetes into the HDFS rack awareness functionality.
664
+
In order to do this, it implements the Hadoop interface `org.apache.hadoop.net.DNSToSwitchMapping` which then allows this tool to be configured on the NameNode via the parameter `net.topology.node.switch.mapping.impl`.
665
+
666
+
The topology provider watches all HDFS pods deployed by Stackable and Kubernetes nodes and keeps an in memory cache of the current state of these objects.
667
+
From this state store the tool can then calculate rack IDs for nodes that HDFS asks for without needing to talk to the api-server and incurring an extra network round-trip.
668
+
669
+
Results are cached for a configurable amount of time and served from the cache if present.
670
+
671
+
In a Kubernetes environment it is likely that the majority of writes will not come from the DataNodes themselves, but rather from other processes such as Spark executors writing data to HDFS. The NameNode passes these on to the topology provider to request the rack ID i.e. it provides the IP addresses of whichever pods are doing the writing. If a datanode resides on the same Kubernetes node as one of these pods, then this datanode is used for label resolution for that pod.
672
+
673
+
## Configuration
674
+
675
+
Configuration of the tool happens via environment variables, as shown below:
676
+
677
+
### TOPOLOGY_LABELS
678
+
679
+
A semicolon separated list of labels that should be used to build a rack id for a datanode.
| node:topology.kubernetes.io/zone | The value of the label 'topology.kubernetes.io/zone' on the node to which the pod has been assigned. |
688
+
| pod:app.kubernetes.io/role-group | The value of the label 'app.kubernetes.io/role-group' on the datanode pod. |
689
+
690
+
Multiple levels of labels can be combined (up to MAX_TOPOLOGY_LABELS levels) by separating them with a semicolon:
691
+
692
+
So for example `node:topology.kubernetes.io/zone;pod:app.kubernetes.io/role-group` would resolve to `/<value of label topology.kubernetes.io/zone on the node>/<value of label app.kubernetes.io/role-group on the pod>`.
693
+
694
+
### TOPOLOGY_CACHE_EXPIRATION_SECONDS
695
+
696
+
Default: 5 Minutes
697
+
698
+
The default time for which rack ids are cached, HDFS can influence caching, as the provider offers methods to invalidate the cache, so this is not a totally _reliable_ value, as there are external factors not under the control of this tool.
699
+
700
+
### MAX_TOPOLOGY_LEVELS
701
+
702
+
Default: 2
703
+
704
+
The maximum number of levels that can be specified to build a rack id from.
705
+
706
+
While this can be changed, HDFS probably only supports a maximum of two levels, so it is not recommended to change the default for this setting.
707
+
708
+
## Testing
709
+
710
+
There are currently no unit tests.
711
+
712
+
CRDs for spinning up test infrastructure are provided in `test/stack`.
713
+
714
+
The actual testing for this happens in the integration tests of the HDFS operator.
0 commit comments