use of org.apache.flink.kubernetes.operator.config.FlinkConfigManager in project flink-kubernetes-operator by apache.
the class IngressUtilsTest method testIngress.
@Test
public void testIngress() {
FlinkDeployment appCluster = TestUtils.buildApplicationCluster();
Configuration config = new FlinkConfigManager(new Configuration()).getDeployConfig(appCluster.getMetadata(), appCluster.getSpec());
// no ingress when ingressDomain is empty
IngressUtils.updateIngressRules(appCluster.getMetadata(), appCluster.getSpec(), config, client);
assertNull(client.network().v1().ingresses().inNamespace(appCluster.getMetadata().getNamespace()).withName(appCluster.getMetadata().getName()).get());
// host based routing
IngressSpec.IngressSpecBuilder builder = IngressSpec.builder();
builder.template("{{name}}.{{namespace}}.example.com");
appCluster.getSpec().setIngress(builder.build());
IngressUtils.updateIngressRules(appCluster.getMetadata(), appCluster.getSpec(), config, client);
Ingress ingress = client.network().v1().ingresses().inNamespace(appCluster.getMetadata().getNamespace()).withName(appCluster.getMetadata().getName()).get();
List<IngressRule> rules = ingress.getSpec().getRules();
assertEquals(1, rules.size());
assertEquals(appCluster.getMetadata().getName() + "." + appCluster.getMetadata().getNamespace() + ".example.com", rules.get(0).getHost());
assertNull(rules.get(0).getHttp().getPaths().get(0).getPath());
// path based routing
builder.template("/{{namespace}}/{{name}}(/|$)(.*)");
builder.className("nginx");
builder.annotations(Map.of("nginx.ingress.kubernetes.io/rewrite-target", "/$2"));
appCluster.getSpec().setIngress(builder.build());
IngressUtils.updateIngressRules(appCluster.getMetadata(), appCluster.getSpec(), config, client);
ingress = client.network().v1().ingresses().inNamespace(appCluster.getMetadata().getNamespace()).withName(appCluster.getMetadata().getName()).get();
rules = ingress.getSpec().getRules();
assertEquals(1, rules.size());
assertNull(rules.get(0).getHost());
assertEquals(1, rules.get(0).getHttp().getPaths().size());
assertEquals("/" + appCluster.getMetadata().getNamespace() + "/" + appCluster.getMetadata().getName() + "(/|$)(.*)", rules.get(0).getHttp().getPaths().get(0).getPath());
assertEquals(Map.of("nginx.ingress.kubernetes.io/rewrite-target", "/$2"), ingress.getMetadata().getAnnotations());
assertEquals("nginx", ingress.getSpec().getIngressClassName());
// host + path based routing
builder.template("example.com/{{namespace}}/{{name}}(/|$)(.*)");
builder.className("nginx");
appCluster.getSpec().setIngress(builder.build());
IngressUtils.updateIngressRules(appCluster.getMetadata(), appCluster.getSpec(), config, client);
ingress = client.network().v1().ingresses().inNamespace(appCluster.getMetadata().getNamespace()).withName(appCluster.getMetadata().getName()).get();
rules = ingress.getSpec().getRules();
assertEquals(1, rules.size());
assertEquals(1, rules.get(0).getHttp().getPaths().size());
assertEquals("/" + appCluster.getMetadata().getNamespace() + "/" + appCluster.getMetadata().getName() + "(/|$)(.*)", rules.get(0).getHttp().getPaths().get(0).getPath());
assertEquals(Map.of("nginx.ingress.kubernetes.io/rewrite-target", "/$2"), ingress.getMetadata().getAnnotations());
assertEquals("nginx", ingress.getSpec().getIngressClassName());
}
use of org.apache.flink.kubernetes.operator.config.FlinkConfigManager in project flink-kubernetes-operator by apache.
the class ArtifactManagerTest method setup.
@BeforeEach
public void setup() {
Configuration configuration = new Configuration();
configuration.setString(KubernetesOperatorConfigOptions.OPERATOR_USER_ARTIFACTS_BASE_DIR, tempDir.toAbsolutePath().toString());
artifactManager = new ArtifactManager(new FlinkConfigManager(configuration));
}
use of org.apache.flink.kubernetes.operator.config.FlinkConfigManager in project flink-kubernetes-operator by apache.
the class RollbackTest method setup.
@BeforeEach
public void setup() {
flinkService = new TestingFlinkService();
context = flinkService.getContext();
testController = TestUtils.createTestController(new FlinkConfigManager(new Configuration()), kubernetesClient, flinkService);
kubernetesClient.resource(TestUtils.buildApplicationCluster()).createOrReplace();
}
use of org.apache.flink.kubernetes.operator.config.FlinkConfigManager in project flink-kubernetes-operator by apache.
the class ValidatorUtilsTest method testDiscoverValidators.
@Test
public void testDiscoverValidators() throws IOException {
File validatorRootFolder = temporaryFolder.newFolder();
File testValidatorFolder = new File(validatorRootFolder, VALIDATOR_NAME);
assertTrue(testValidatorFolder.mkdirs());
File testValidatorJar = new File("target", VALIDATOR_JAR);
assertTrue(testValidatorJar.exists());
Files.copy(testValidatorJar.toPath(), Paths.get(testValidatorFolder.toString(), VALIDATOR_JAR));
Map<String, String> originalEnv = System.getenv();
try {
Map<String, String> systemEnv = new HashMap<>(originalEnv);
systemEnv.put(ConfigConstants.ENV_FLINK_PLUGINS_DIR, validatorRootFolder.getPath());
TestUtils.setEnv(systemEnv);
assertEquals(new HashSet<>(Arrays.asList(DefaultValidator.class.getName(), TestValidator.class.getName())), ValidatorUtils.discoverValidators(new FlinkConfigManager(new Configuration())).stream().map(v -> v.getClass().getName()).collect(Collectors.toSet()));
} finally {
TestUtils.setEnv(originalEnv);
}
}
use of org.apache.flink.kubernetes.operator.config.FlinkConfigManager in project flink-kubernetes-operator by apache.
the class DefaultValidatorTest method testValidationWithDefaultConfig.
@Test
public void testValidationWithDefaultConfig() {
final Configuration defaultFlinkConf = new Configuration();
defaultFlinkConf.set(HighAvailabilityOptions.HA_MODE, KubernetesHaServicesFactory.class.getCanonicalName());
defaultFlinkConf.set(CheckpointingOptions.CHECKPOINTS_DIRECTORY, "cpdir");
final DefaultValidator validatorWithDefaultConfig = new DefaultValidator(new FlinkConfigManager(defaultFlinkConf));
testSuccess(dep -> {
dep.getSpec().setFlinkConfiguration(new HashMap<>());
dep.getSpec().getJob().setUpgradeMode(UpgradeMode.LAST_STATE);
}, validatorWithDefaultConfig);
}
Aggregations