Skip to content
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

Fix all operators to be cluster wide #24

Merged
merged 4 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@
<executable>sh</executable>
<arguments>
<argument>-c</argument>
<argument>helm template flink-kubernetes-operator flink-operator-repo/flink-kubernetes-operator > ${basedir}/${operator.files.destination}/flink/deploy.yaml</argument>
<argument>helm template flink-kubernetes-operator flink-operator-repo/flink-kubernetes-operator --set watchNamespaces="" --set podSecurityContext=null --namespace flink-kubernetes-operator > ${basedir}/${operator.files.destination}/flink/deploy.yaml</argument>
</arguments>
</configuration>
</execution>
Expand Down
1 change: 1 addition & 0 deletions src/main/java/io/streams/constants/TestTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@

public interface TestTags {
String SMOKE = "smoke";
String SQL_EXAMPLE = "sql-example";
String DUMMY = "dummy";
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,14 @@
*/
package io.streams.operators.manifests;

import io.fabric8.kubernetes.api.model.Container;
import io.fabric8.kubernetes.api.model.EnvVar;
import io.fabric8.kubernetes.api.model.EnvVarBuilder;
import io.fabric8.kubernetes.api.model.HasMetadata;
import io.fabric8.kubernetes.api.model.Namespace;
import io.fabric8.kubernetes.api.model.NamespaceBuilder;
import io.fabric8.kubernetes.api.model.Namespaced;
import io.fabric8.kubernetes.api.model.apps.Deployment;
import io.fabric8.kubernetes.api.model.rbac.ClusterRoleBinding;
import io.fabric8.kubernetes.api.model.rbac.RoleBinding;
import io.skodjob.testframe.TestFrameConstants;
Expand All @@ -20,6 +24,8 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
Expand Down Expand Up @@ -72,6 +78,8 @@ public static CompletableFuture<Void> install() throws IOException {
crb.getMetadata().setName(crb.getMetadata().getName() + "." + OPERATOR_NS);
} else if (res instanceof RoleBinding rb) {
rb.getSubjects().forEach(sbj -> sbj.setNamespace(OPERATOR_NS));
} else if (res instanceof Deployment dep && DEPLOYMENT_NAME.equals(res.getMetadata().getName())) {
modifyDeployment(dep);
}
KubeResourceManager.getInstance().createOrUpdateResourceWithoutWait(res);
});
Expand All @@ -80,6 +88,14 @@ public static CompletableFuture<Void> install() throws IOException {
TestFrameConstants.GLOBAL_TIMEOUT, ApicurioRegistryManifestInstaller::isReady);
}

private static void modifyDeployment(Deployment deployment) {
Container container = deployment.getSpec().getTemplate().getSpec().getContainers().get(0);
List<EnvVar> env = new ArrayList<>(container.getEnv() == null ? Collections.emptyList() : container.getEnv());
env.removeIf(envVar -> envVar.getName().equals("WATCH_NAMESPACE"));
env.add(new EnvVarBuilder().withName("WATCH_NAMESPACE").withValue("").build());
container.setEnv(env);
}

private static boolean isReady() {
if (KubeResourceManager.getKubeClient().getClient().apps()
.deployments().inNamespace(OPERATOR_NS).withName(DEPLOYMENT_NAME).isReady()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import io.fabric8.kubernetes.api.model.Namespace;
import io.fabric8.kubernetes.api.model.NamespaceBuilder;
import io.fabric8.kubernetes.api.model.Namespaced;
import io.fabric8.kubernetes.api.model.apps.Deployment;
import io.fabric8.kubernetes.api.model.rbac.ClusterRoleBinding;
import io.fabric8.kubernetes.api.model.rbac.RoleBinding;
import io.skodjob.testframe.TestFrameConstants;
Expand Down Expand Up @@ -73,8 +72,6 @@ public static CompletableFuture<Void> install() throws IOException {
crb.getMetadata().setName(crb.getMetadata().getName() + "." + OPERATOR_NS);
} else if (res instanceof RoleBinding rb) {
rb.getSubjects().forEach(sbj -> sbj.setNamespace(OPERATOR_NS));
} else if (res instanceof Deployment && DEPLOYMENT_NAME.equals(res.getMetadata().getName())) {
modifyDeployment((Deployment) res);
} else {
res.getMetadata().setNamespace(OPERATOR_NS);
}
Expand All @@ -85,10 +82,6 @@ public static CompletableFuture<Void> install() throws IOException {
TestFrameConstants.GLOBAL_TIMEOUT, FlinkManifestInstaller::isReady);
}

private static void modifyDeployment(Deployment deployment) {
deployment.getSpec().getTemplate().getSpec().setSecurityContext(null);
}

private static boolean isReady() {
if (KubeResourceManager.getKubeClient().getClient().apps()
.deployments().inNamespace(OPERATOR_NS).withName(DEPLOYMENT_NAME).isReady()) {
Expand Down
34 changes: 34 additions & 0 deletions src/test/java/io/streams/e2e/flink/sql/SqlExampleST.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package io.streams.e2e.flink.sql;

import io.streams.e2e.Abstract;
import io.streams.operators.manifests.ApicurioRegistryManifestInstaller;
import io.streams.operators.manifests.CertManagerManifestInstaller;
import io.streams.operators.manifests.FlinkManifestInstaller;
import io.streams.operators.manifests.StrimziManifestInstaller;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.util.concurrent.CompletableFuture;

import static io.streams.constants.TestTags.SQL_EXAMPLE;

@Tag(SQL_EXAMPLE)
public class SqlExampleST extends Abstract {

@BeforeAll
void prepareOperators() throws IOException {
CompletableFuture.allOf(
StrimziManifestInstaller.install(),
CertManagerManifestInstaller.install(),
FlinkManifestInstaller.install(),
ApicurioRegistryManifestInstaller.install()
).join();
}

@Test
void testFlinkSqlExample() {
//TODO
}
}