mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(eks): support per-cluster kubelet and API server arguments (#4772)
* feat(eks): support per-cluster kubelet and API server arguments * fix(eks): prevent security group leak and reject authorization-mode override * refactor(eks): classify authorization-mode as refused argument * fix(eks): strip modifier suffixes before collision validation
This commit is contained in:
1 parent
044c700d68
commit
86c06247e3
9 files changed
+895
-2
No files matched your search
@@ -0,0 +1,223 @@
|
||||
package io.github.hectorvent.floci.services.eks;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.ValueSource;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class EksClusterArgsTest {
|
||||
|
||||
@Test
|
||||
void parsePrefixedKubeletArgWithKeyEqualsValue() {
|
||||
Map<String, String> tags = Map.of("floci:kubelet-arg:max-pods=250", "true");
|
||||
List<String> args = EksClusterArgs.parseAndValidateClusterArgs(tags, "demo");
|
||||
assertEquals(List.of("--kubelet-arg=max-pods=250"), args);
|
||||
}
|
||||
|
||||
@Test
|
||||
void parsePrefixedKubeletArgWithKeyValue() {
|
||||
Map<String, String> tags = Map.of("floci:kubelet-arg:max-pods", "250");
|
||||
List<String> args = EksClusterArgs.parseAndValidateClusterArgs(tags, "demo");
|
||||
assertEquals(List.of("--kubelet-arg=max-pods=250"), args);
|
||||
}
|
||||
|
||||
@Test
|
||||
void parseSingularKubeApiserverArg() {
|
||||
Map<String, String> tags = Map.of("floci:kube-apiserver-arg", "feature-gates=CSIStorageCapacity=true");
|
||||
List<String> args = EksClusterArgs.parseAndValidateClusterArgs(tags, "demo");
|
||||
assertEquals(List.of("--kube-apiserver-arg=feature-gates=CSIStorageCapacity=true"), args);
|
||||
}
|
||||
|
||||
@Test
|
||||
void parsePluralJsonArrayArgs() {
|
||||
Map<String, String> tags = Map.of(
|
||||
"floci:kubelet-args", "[\"max-pods=250\", \"image-gc-high-threshold-percent=80\"]"
|
||||
);
|
||||
List<String> args = EksClusterArgs.parseAndValidateClusterArgs(tags, "demo");
|
||||
assertEquals(List.of(
|
||||
"--kubelet-arg=max-pods=250",
|
||||
"--kubelet-arg=image-gc-high-threshold-percent=80"
|
||||
), args);
|
||||
}
|
||||
|
||||
@Test
|
||||
void parsePluralNewlineSeparatedArgs() {
|
||||
Map<String, String> tags = Map.of(
|
||||
"floci:kubelet-args", "max-pods=250\nimage-gc-high-threshold-percent=80"
|
||||
);
|
||||
List<String> args = EksClusterArgs.parseAndValidateClusterArgs(tags, "demo");
|
||||
assertEquals(List.of(
|
||||
"--kubelet-arg=max-pods=250",
|
||||
"--kubelet-arg=image-gc-high-threshold-percent=80"
|
||||
), args);
|
||||
}
|
||||
|
||||
@Test
|
||||
void stripsRedundantPrefixesAndDashes() {
|
||||
Map<String, String> tags = Map.of(
|
||||
"floci:kubelet-arg:--max-pods=250", "true",
|
||||
"floci:kube-apiserver-arg", "--kube-apiserver-arg=feature-gates=Test=true"
|
||||
);
|
||||
List<String> args = EksClusterArgs.parseAndValidateClusterArgs(tags, "demo");
|
||||
assertTrue(args.contains("--kubelet-arg=max-pods=250"));
|
||||
assertTrue(args.contains("--kube-apiserver-arg=feature-gates=Test=true"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void supportsAllK3sComponents() {
|
||||
Map<String, String> tags = Map.of(
|
||||
"floci:kubelet-arg:max-pods=250", "true",
|
||||
"floci:kube-apiserver-arg:runtime-config=batch/v1=true", "true",
|
||||
"floci:kube-controller-manager-arg:leader-elect=false", "true",
|
||||
"floci:kube-scheduler-arg:leader-elect=false", "true",
|
||||
"floci:kube-cloud-controller-manager-arg:cloud-provider=aws", "true"
|
||||
);
|
||||
List<String> args = EksClusterArgs.parseAndValidateClusterArgs(tags, "demo");
|
||||
assertTrue(args.contains("--kubelet-arg=max-pods=250"));
|
||||
assertTrue(args.contains("--kube-apiserver-arg=runtime-config=batch/v1=true"));
|
||||
assertTrue(args.contains("--kube-controller-manager-arg=leader-elect=false"));
|
||||
assertTrue(args.contains("--kube-scheduler-arg=leader-elect=false"));
|
||||
assertTrue(args.contains("--kube-cloud-controller-manager-arg=cloud-provider=aws"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void supportsShortComponentAliases() {
|
||||
Map<String, String> tags = Map.of(
|
||||
"floci:apiserver-arg:runtime-config=batch/v1=true", "true",
|
||||
"floci:controller-manager-arg:leader-elect=false", "true",
|
||||
"floci:scheduler-arg:leader-elect=false", "true"
|
||||
);
|
||||
List<String> args = EksClusterArgs.parseAndValidateClusterArgs(tags, "demo");
|
||||
assertTrue(args.contains("--kube-apiserver-arg=runtime-config=batch/v1=true"));
|
||||
assertTrue(args.contains("--kube-controller-manager-arg=leader-elect=false"));
|
||||
assertTrue(args.contains("--kube-scheduler-arg=leader-elect=false"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void preservesModifierSuffixOnValidArguments() {
|
||||
Map<String, String> tags = Map.of(
|
||||
"floci:kubelet-arg:max-pods+=10", "true",
|
||||
"floci:kube-apiserver-arg:feature-gates+=CSIStorageCapacity=true", "true"
|
||||
);
|
||||
List<String> args = EksClusterArgs.parseAndValidateClusterArgs(tags, "demo");
|
||||
assertTrue(args.contains("--kubelet-arg=max-pods+=10"));
|
||||
assertTrue(args.contains("--kube-apiserver-arg=feature-gates+=CSIStorageCapacity=true"));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {
|
||||
"provider-id",
|
||||
"node-labels",
|
||||
"system-reserved",
|
||||
"kube-reserved",
|
||||
"eviction-hard",
|
||||
"--provider-id=custom-id",
|
||||
"providerId=custom-id",
|
||||
"node-labels=topology.kubernetes.io/zone=custom",
|
||||
"provider-id+=aws:///custom-id",
|
||||
"node-labels-=zone=custom"
|
||||
})
|
||||
void rejectsCollidingKubeletArguments(String collidingFlag) {
|
||||
Map<String, String> tags = Map.of("floci:kubelet-arg:" + collidingFlag, "true");
|
||||
IllegalArgumentException e = assertThrows(IllegalArgumentException.class,
|
||||
() -> EksClusterArgs.parseAndValidateClusterArgs(tags, "demo"));
|
||||
assertNotNull(e.getMessage());
|
||||
assertTrue(e.getMessage().contains("collides with Floci-managed kubelet argument"));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {
|
||||
"authentication-token-webhook-config-file",
|
||||
"authentication-token-webhook-version",
|
||||
"authentication-token-webhook-cache-ttl",
|
||||
"service-account-issuer",
|
||||
"service-account-key-file",
|
||||
"service-account-signing-key-file",
|
||||
"audit-policy-file",
|
||||
"audit-log-path",
|
||||
"audit-log-maxage",
|
||||
"audit-log-maxbackup",
|
||||
"audit-log-maxsize",
|
||||
"--service-account-issuer=https://override.example.com",
|
||||
"auditPolicyFile=/custom/path",
|
||||
"audit-policy-file+=/custom/path",
|
||||
"audit-policy-file-=/custom/path"
|
||||
})
|
||||
void rejectsCollidingKubeApiserverArguments(String collidingFlag) {
|
||||
Map<String, String> tags = Map.of("floci:kube-apiserver-arg:" + collidingFlag, "true");
|
||||
IllegalArgumentException e = assertThrows(IllegalArgumentException.class,
|
||||
() -> EksClusterArgs.parseAndValidateClusterArgs(tags, "demo"));
|
||||
assertNotNull(e.getMessage());
|
||||
assertTrue(e.getMessage().contains("collides with Floci-managed kube-apiserver argument"));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {
|
||||
"storage-backend",
|
||||
"etcd-servers",
|
||||
"authorization-mode",
|
||||
"authorization-mode=AlwaysAllow",
|
||||
"authorization-mode+=AlwaysAllow",
|
||||
"authorization-mode-=AlwaysAllow",
|
||||
"authorization-mode+",
|
||||
"storage-backend=etcd3",
|
||||
"storage-backend+=etcd3",
|
||||
"etcd-servers=https://127.0.0.1:2379"
|
||||
})
|
||||
void rejectsRefusedApiserverArguments(String refusedFlag) {
|
||||
Map<String, String> tags = Map.of("floci:kube-apiserver-arg:" + refusedFlag, "true");
|
||||
IllegalArgumentException e = assertThrows(IllegalArgumentException.class,
|
||||
() -> EksClusterArgs.parseAndValidateClusterArgs(tags, "demo"));
|
||||
assertNotNull(e.getMessage());
|
||||
assertTrue(e.getMessage().contains("is refused outright"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void malformedInputLogsWarningAndContinuesWithoutThrowing() {
|
||||
// Empty flag name
|
||||
Map<String, String> tags = Map.of(
|
||||
"floci:kubelet-arg:", "",
|
||||
"floci:kubelet-arg:max-pods=250", "true"
|
||||
);
|
||||
List<String> args = EksClusterArgs.parseAndValidateClusterArgs(tags, "demo");
|
||||
assertEquals(List.of("--kubelet-arg=max-pods=250"), args);
|
||||
}
|
||||
|
||||
@Test
|
||||
void controlCharactersLogWarningAndAreSkipped() {
|
||||
Map<String, String> tags = Map.of(
|
||||
"floci:kubelet-arg:bad\u0000flag=1", "true",
|
||||
"floci:kubelet-arg:max-pods=250", "true"
|
||||
);
|
||||
List<String> args = EksClusterArgs.parseAndValidateClusterArgs(tags, "demo");
|
||||
assertEquals(List.of("--kubelet-arg=max-pods=250"), args);
|
||||
}
|
||||
|
||||
@Test
|
||||
void unparseableJsonArrayLogsWarningAndIsSkipped() {
|
||||
Map<String, String> tags = Map.of(
|
||||
"floci:kubelet-args", "[not-valid-json",
|
||||
"floci:kubelet-arg:max-pods=250", "true"
|
||||
);
|
||||
List<String> args = EksClusterArgs.parseAndValidateClusterArgs(tags, "demo");
|
||||
assertEquals(List.of("--kubelet-arg=max-pods=250"), args);
|
||||
}
|
||||
|
||||
@Test
|
||||
void nonReservedTagsAreIgnored() {
|
||||
Map<String, String> tags = Map.of(
|
||||
"Environment", "production",
|
||||
"Team", "core",
|
||||
"floci:kubelet-arg:max-pods=250", "true"
|
||||
);
|
||||
List<String> args = EksClusterArgs.parseAndValidateClusterArgs(tags, "demo");
|
||||
assertEquals(List.of("--kubelet-arg=max-pods=250"), args);
|
||||
}
|
||||
}
|
||||
@@ -2748,4 +2748,143 @@ class EksClusterManagerTest {
|
||||
assertTrue(policy.contains("/version"));
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
class ClusterArgsPassthrough {
|
||||
|
||||
private ContainerBuilder containerBuilder;
|
||||
private ContainerBuilder.Builder builder;
|
||||
private ContainerLifecycleManager lifecycleManager;
|
||||
private EksClusterManager manager;
|
||||
|
||||
@BeforeEach
|
||||
void setUp() {
|
||||
EmulatorConfig config = Mockito.mock(EmulatorConfig.class);
|
||||
EmulatorConfig.ServicesConfig services = Mockito.mock(EmulatorConfig.ServicesConfig.class);
|
||||
EmulatorConfig.EksServiceConfig eks = Mockito.mock(EmulatorConfig.EksServiceConfig.class);
|
||||
when(config.services()).thenReturn(services);
|
||||
when(services.eks()).thenReturn(eks);
|
||||
when(eks.defaultImage()).thenReturn("rancher/k3s:v1.30.0-k3s1");
|
||||
when(eks.apiServerBasePort()).thenReturn(6440);
|
||||
when(eks.apiServerMaxPort()).thenReturn(6499);
|
||||
when(eks.dockerNetwork()).thenReturn(Optional.empty());
|
||||
when(eks.disableCni()).thenReturn(false);
|
||||
when(eks.iamAuthWebhook()).thenReturn(false);
|
||||
when(eks.ecrRegistryMirror()).thenReturn(false);
|
||||
|
||||
lifecycleManager = Mockito.mock(ContainerLifecycleManager.class);
|
||||
when(lifecycleManager.create(any())).thenReturn("container-id");
|
||||
when(lifecycleManager.startCreated(any(), any())).thenReturn(
|
||||
new ContainerInfo("container-id", Map.of()));
|
||||
|
||||
containerBuilder = Mockito.mock(ContainerBuilder.class);
|
||||
builder = Mockito.mock(ContainerBuilder.Builder.class, Mockito.RETURNS_SELF);
|
||||
when(containerBuilder.newContainer(anyString())).thenReturn(builder);
|
||||
when(builder.build()).thenReturn(Mockito.mock(ContainerSpec.class));
|
||||
|
||||
RegionResolver regionResolver = Mockito.mock(RegionResolver.class);
|
||||
when(regionResolver.getAccountId()).thenReturn("000000000000");
|
||||
when(regionResolver.getDefaultRegion()).thenReturn("us-east-1");
|
||||
when(regionResolver.buildGlobalArn(anyString(), anyString(), anyString())).thenAnswer(invocation ->
|
||||
"arn:aws:" + invocation.getArgument(0) + "::" + invocation.getArgument(1) + ":" + invocation.getArgument(2));
|
||||
|
||||
manager = new EksClusterManager(containerBuilder, lifecycleManager,
|
||||
Mockito.mock(ContainerDetector.class), Mockito.mock(PortAllocator.class),
|
||||
Mockito.mock(DockerHostResolver.class), Mockito.mock(EcrRegistryManager.class),
|
||||
config, regionResolver);
|
||||
}
|
||||
|
||||
@Test
|
||||
void callerArgsAppearAlongsideFlociArgs() {
|
||||
Cluster cluster = new Cluster();
|
||||
cluster.setName("my-cluster");
|
||||
cluster.setClusterArgs(List.of(
|
||||
"--kubelet-arg=max-pods=250",
|
||||
"--kube-apiserver-arg=feature-gates=CSIStorageCapacity=true"
|
||||
));
|
||||
|
||||
manager.startCluster(cluster);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
ArgumentCaptor<List<String>> cmdCaptor = ArgumentCaptor.forClass(List.class);
|
||||
verify(builder).withCmd(cmdCaptor.capture());
|
||||
List<String> cmd = cmdCaptor.getValue();
|
||||
|
||||
assertTrue(cmd.contains("server"));
|
||||
assertTrue(cmd.contains("--kubelet-arg=max-pods=250"));
|
||||
assertTrue(cmd.contains("--kube-apiserver-arg=feature-gates=CSIStorageCapacity=true"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void twoClustersWithDifferentArgsGetTheirOwn() {
|
||||
Cluster cluster1 = new Cluster();
|
||||
cluster1.setName("cluster-one");
|
||||
cluster1.setClusterArgs(List.of("--kubelet-arg=max-pods=250"));
|
||||
|
||||
Cluster cluster2 = new Cluster();
|
||||
cluster2.setName("cluster-two");
|
||||
cluster2.setClusterArgs(List.of("--kubelet-arg=max-pods=500"));
|
||||
|
||||
manager.startCluster(cluster1);
|
||||
manager.startCluster(cluster2);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
ArgumentCaptor<List<String>> cmdCaptor = ArgumentCaptor.forClass(List.class);
|
||||
verify(builder, Mockito.times(2)).withCmd(cmdCaptor.capture());
|
||||
List<List<String>> allCmds = cmdCaptor.getAllValues();
|
||||
|
||||
List<String> cmd1 = allCmds.get(0);
|
||||
List<String> cmd2 = allCmds.get(1);
|
||||
|
||||
assertTrue(cmd1.contains("--kubelet-arg=max-pods=250"));
|
||||
assertFalse(cmd1.contains("--kubelet-arg=max-pods=500"));
|
||||
|
||||
assertTrue(cmd2.contains("--kubelet-arg=max-pods=500"));
|
||||
assertFalse(cmd2.contains("--kubelet-arg=max-pods=250"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void clusterWithoutCustomArgsProducesExactExistingArguments() {
|
||||
Cluster clusterWithNoArgs = new Cluster();
|
||||
clusterWithNoArgs.setName("plain-cluster");
|
||||
|
||||
manager.startCluster(clusterWithNoArgs);
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
ArgumentCaptor<List<String>> cmdCaptor = ArgumentCaptor.forClass(List.class);
|
||||
verify(builder).withCmd(cmdCaptor.capture());
|
||||
List<String> cmd = cmdCaptor.getValue();
|
||||
|
||||
assertFalse(cmd.stream().anyMatch(a -> a.contains("max-pods")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void collisionThrowsExpectedException() {
|
||||
Cluster cluster = new Cluster();
|
||||
cluster.setName("colliding-cluster");
|
||||
cluster.setClusterArgs(List.of("--kubelet-arg=provider-id=custom-id"));
|
||||
|
||||
IllegalArgumentException e = assertThrows(IllegalArgumentException.class,
|
||||
() -> manager.startCluster(cluster));
|
||||
assertTrue(e.getMessage().contains("collides with Floci-managed kubelet argument"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void malformedInputLogsWarningAndStartsCluster() {
|
||||
Cluster cluster = new Cluster();
|
||||
cluster.setName("malformed-cluster");
|
||||
cluster.setTags(Map.of(
|
||||
"floci:kubelet-arg:", "",
|
||||
"floci:kubelet-arg:max-pods=250", "true"
|
||||
));
|
||||
|
||||
assertDoesNotThrow(() -> manager.startCluster(cluster));
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
ArgumentCaptor<List<String>> cmdCaptor = ArgumentCaptor.forClass(List.class);
|
||||
verify(builder).withCmd(cmdCaptor.capture());
|
||||
List<String> cmd = cmdCaptor.getValue();
|
||||
assertTrue(cmd.contains("--kubelet-arg=max-pods=250"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2495,4 +2495,94 @@ class EksServiceTest {
|
||||
new EksOidcService(storageFactory, new ObjectMapper()), mock(EksAccessEntryService.class),
|
||||
mock(EksPodIdentityAssociationService.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void createClusterWithClusterArgsExtractsArgsAndStripsReservedTags() {
|
||||
CreateClusterRequest req = createTestClusterRequest("args-cluster");
|
||||
req.setTags(Map.of(
|
||||
"floci:kubelet-arg:max-pods=250", "true",
|
||||
"floci:kube-apiserver-arg:runtime-config=batch/v1=true", "true",
|
||||
"env", "production"
|
||||
));
|
||||
|
||||
Cluster created = eksService.createCluster(req);
|
||||
assertNotNull(created.getClusterArgs());
|
||||
assertEquals(2, created.getClusterArgs().size());
|
||||
assertTrue(created.getClusterArgs().contains("--kubelet-arg=max-pods=250"));
|
||||
assertTrue(created.getClusterArgs().contains("--kube-apiserver-arg=runtime-config=batch/v1=true"));
|
||||
|
||||
// Reserved tags must be stripped from public tags
|
||||
assertNotNull(created.getTags());
|
||||
assertEquals(Map.of("env", "production"), created.getTags());
|
||||
assertFalse(created.getTags().containsKey("floci:kubelet-arg:max-pods=250"));
|
||||
|
||||
Cluster described = eksService.describeCluster("args-cluster");
|
||||
assertEquals(Map.of("env", "production"), described.getTags());
|
||||
assertEquals(created.getClusterArgs(), described.getClusterArgs());
|
||||
}
|
||||
|
||||
@Test
|
||||
void createClusterWithCollidingArgThrowsInvalidParameterException() {
|
||||
CreateClusterRequest req = createTestClusterRequest("colliding-cluster");
|
||||
req.setTags(Map.of("floci:kubelet-arg:provider-id", "my-id"));
|
||||
|
||||
AwsException ex = assertThrows(AwsException.class, () -> eksService.createCluster(req));
|
||||
assertEquals("InvalidParameterException", ex.getErrorCode());
|
||||
assertEquals(400, ex.getHttpStatus());
|
||||
assertTrue(ex.getMessage().contains("collides with Floci-managed kubelet argument"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void createClusterWithCollidingArgDoesNotLeakSecurityGroup() {
|
||||
Ec2Service ec2 = realEc2Service();
|
||||
ec2.ensureDefaultResources("us-east-1");
|
||||
String vpcId = ec2.createVpc("us-east-1", "172.31.0.0/16", false).getVpcId();
|
||||
String subnetId = ec2.createSubnet("us-east-1", vpcId, "172.31.1.0/24", "us-east-1a").getSubnetId();
|
||||
|
||||
EksService service = new EksService(storageFactory, testConfig(), regionResolver, null, ec2,
|
||||
new EksOidcService(storageFactory, new ObjectMapper()), mock(EksAccessEntryService.class),
|
||||
mock(EksPodIdentityAssociationService.class));
|
||||
|
||||
CreateClusterRequest req = createTestClusterRequest("colliding-sg-leak");
|
||||
ResourcesVpcConfig vpcConfig = new ResourcesVpcConfig();
|
||||
vpcConfig.setSubnetIds(List.of(subnetId));
|
||||
req.setResourcesVpcConfig(vpcConfig);
|
||||
req.setTags(Map.of("floci:kubelet-arg:provider-id", "my-id"));
|
||||
|
||||
AwsException ex = assertThrows(AwsException.class, () -> service.createCluster(req));
|
||||
assertEquals("InvalidParameterException", ex.getErrorCode());
|
||||
|
||||
List<SecurityGroup> allSgs = ec2.describeSecurityGroups("us-east-1", List.of(), List.of(), Map.of());
|
||||
boolean leaked = allSgs.stream().anyMatch(sg -> sg.getGroupName().startsWith("eks-cluster-sg-colliding-sg-leak-"));
|
||||
assertFalse(leaked, "Cluster security group should not be created when argument validation fails");
|
||||
}
|
||||
|
||||
@Test
|
||||
void tagResourceWithReservedTagThrowsValidationException() {
|
||||
createTestCluster("tag-resource-cluster");
|
||||
Cluster cluster = eksService.describeCluster("tag-resource-cluster");
|
||||
|
||||
AwsException ex = assertThrows(AwsException.class, () ->
|
||||
eksService.tagResource(cluster.getArn(), Map.of("floci:kubelet-arg:max-pods=250", "true")));
|
||||
assertEquals("ValidationException", ex.getErrorCode());
|
||||
assertEquals(400, ex.getHttpStatus());
|
||||
}
|
||||
|
||||
@Test
|
||||
void clusterArgsSurviveRestart(@TempDir Path directory) {
|
||||
EksService before = persistentEksService(directory);
|
||||
before.init();
|
||||
|
||||
CreateClusterRequest req = createTestClusterRequest("restart-args-cluster");
|
||||
req.setTags(Map.of("floci:kubelet-arg:max-pods=250", "true", "owner", "ops"));
|
||||
Cluster created = before.createCluster(req);
|
||||
assertEquals(List.of("--kubelet-arg=max-pods=250"), created.getClusterArgs());
|
||||
|
||||
EksService after = persistentEksService(directory);
|
||||
after.init();
|
||||
|
||||
Cluster described = after.describeCluster("restart-args-cluster");
|
||||
assertEquals(List.of("--kubelet-arg=max-pods=250"), described.getClusterArgs());
|
||||
assertEquals(Map.of("owner", "ops"), described.getTags());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user