-
Notifications
You must be signed in to change notification settings - Fork 891
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cluster ip for Kubernetes Nat Manager #1156
Add cluster ip for Kubernetes Nat Manager #1156
Conversation
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes requested
+ e.getMessage() | ||
+ ". NONE mode will be used"); | ||
disableNatManager(); | ||
String.format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't use String.format
, use standard logging placeholder instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
|
||
import io.kubernetes.client.models.V1Service; | ||
|
||
public class ClusterIpBasedDetector implements IpDetector { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not worth creating a class for such a simple implementation IMO. You can inject the code as a lambda directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch
final String serviceType = v1Service.getSpec().getType(); | ||
switch (KubernetesServiceType.fromName(serviceType)) { | ||
case CLUSTER_IP: | ||
return new ClusterIpBasedDetector(v1Service); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return a lambda instead IMO
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -197,6 +197,24 @@ public void assertThatManagerSwitchToNoneForInvalidNatEnvironment() | |||
assertThat(natService.queryLocalIPAddress(fallbackLocalIp)).isEqualTo(fallbackLocalIp); | |||
} | |||
|
|||
@Test(expected = RuntimeException.class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use assertThatThrownBy
instead.
Example here:
besu/besu/src/test/java/org/hyperledger/besu/chainexport/RlpBlockExporterTest.java
Line 213 in 71f2872
assertThatThrownBy(() -> exporter.exportBlocks(outputPath, Optional.of(-1L), Optional.empty())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
@@ -61,7 +63,14 @@ public void assertThatExternalIPIsEqualToRemoteHost() | |||
@Test | |||
public void assertThatExternalIPIsEqualToDefaultHostIfIpDetectorCannotRetrieveIP() | |||
throws ExecutionException, InterruptedException { | |||
when(hostBasedIpDetector.detectExternalIp()).thenReturn(Optional.empty()); | |||
NatManager natManager = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
final ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You right . Done
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Signed-off-by: Karim TAAM <karim.t2am@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
Add hyperledger#1156 and hyperledger#1149 Signed-off-by: Karim TAAM <karim.t2am@gmail.com> Co-authored-by: Ratan (Rai) Sur <ratan.r.sur@gmail.com> (cherry picked from commit baa11a2) Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
Signed-off-by: Karim TAAM karim.t2am@gmail.com
PR description
Kubernetes nat manager could work with
LoadBalancer
services. This PR add compatibility withClusterIP
services.A code refactor was made in order to facilitate the addition of new services thereafter such as the
NodePort
Sample of
ClusterIP
service :You can find the IP that will be used by BESU by launching the following command
Update of the fallback mechanism
If the
nat-method
is equal toAUTO
(default). A bad configuration (invalid service, ingress not found, etc.) will cause a switch to theNONE
mode.If the
nat-method
is equal toKUBERNETES
andXnat-method-fallback-enabled
is equal totrue
. A bad configuration will cause a switch to theNONE
mode.If the
nat-method
is equal toKUBERNETES
andXnat-method-fallback-enabled
is equal tofalse
. A bad configuration will cause a stop ofBESU
in order to indicate to him that the automatic configuration has failedNew error message added
If you are trying to use not implemented service you will now have an issue :
Tested
Fixed Issue(s)