Skip to content

Commit

Permalink
[ST] Specify correct registry, org, and tag for Helm and remove unuse…
Browse files Browse the repository at this point in the history
…d code for OCP

Signed-off-by: Lukas Kral <[email protected]>
  • Loading branch information
im-konge committed Dec 13, 2024
1 parent 6749169 commit 21f78bd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ public class Environment {
/**
* Defaults
*/
public static final String STRIMZI_TAG_DEFAULT = "latest";
public static final String STRIMZI_ORG_DEFAULT = "strimzi";
public static final String STRIMZI_REGISTRY_DEFAULT = "quay.io";
public static final String TEST_CLIENTS_ORG_DEFAULT = "strimzi-test-clients";
Expand Down Expand Up @@ -243,7 +244,9 @@ public class Environment {
private static final String TEST_CLIENTS_VERSION = getOrDefault(TEST_CLIENTS_VERSION_ENV, TEST_CLIENTS_VERSION_DEFAULT);
private static final String TEST_CLIENTS_IMAGE_DEFAULT = STRIMZI_REGISTRY_DEFAULT + "/" + TEST_CLIENTS_ORG_DEFAULT + "/test-clients:" + TEST_CLIENTS_VERSION + "-kafka-" + CLIENTS_KAFKA_VERSION;
public static final String TEST_CLIENTS_IMAGE = getOrDefault(TEST_CLIENTS_IMAGE_ENV, TEST_CLIENTS_IMAGE_DEFAULT);
private static final String SCRAPER_IMAGE_DEFAULT = STRIMZI_REGISTRY + "/" + STRIMZI_ORG + "/kafka:" + STRIMZI_TAG + "-kafka-" + ST_KAFKA_VERSION;
private static final String SCRAPER_IMAGE_DEFAULT = getIfNotEmptyOrDefault(STRIMZI_REGISTRY, STRIMZI_REGISTRY_DEFAULT) + "/" +
getIfNotEmptyOrDefault(STRIMZI_ORG, STRIMZI_ORG_DEFAULT) + "/kafka:" +
getIfNotEmptyOrDefault(STRIMZI_TAG, STRIMZI_TAG_DEFAULT) + "-kafka-" + ST_KAFKA_VERSION;
public static final String SCRAPER_IMAGE = getOrDefault(SCRAPER_IMAGE_ENV, SCRAPER_IMAGE_DEFAULT);

// variables for kafka bridge image
Expand Down Expand Up @@ -449,4 +452,8 @@ private static boolean isWriteable(String var, String value) {
public static boolean isEnvVarSet(String envVarName) {
return System.getenv(envVarName) != null;
}

public static String getIfNotEmptyOrDefault(String envVar, String defaultValue) {
return envVar.isEmpty() ? defaultValue : envVar;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@
import io.strimzi.systemtest.utils.specific.OlmUtils;
import io.strimzi.test.ReadWriteUtils;
import io.strimzi.test.TestUtils;
import io.strimzi.test.executor.Exec;
import io.strimzi.test.k8s.KubeClusterResource;
import io.strimzi.test.k8s.cluster.OpenShift;
import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.jupiter.api.extension.ExtensionContext;
Expand Down Expand Up @@ -288,7 +285,7 @@ private void bundleInstallation() {
LOGGER.info("Install Cluster Operator via Yaml bundle");
// check if namespace is already created
createClusterOperatorNamespaceIfPossible();
prepareEnvForOperator(namespaceInstallTo, bindingsNamespaces);
prepareEnvForOperator(namespaceInstallTo);
// if we manage directly in the individual test one of the Role, ClusterRole, RoleBindings and ClusterRoleBinding we must do it
// everything by ourselves in scope of RBAC permissions otherwise we apply the default one
if (this.isRolesAndBindingsManagedByAnUser()) {
Expand Down Expand Up @@ -554,21 +551,10 @@ public SetupClusterOperator createInstallation() {
* Prepare environment for cluster operator which includes creation of namespaces, custom resources and operator
* specific config files such as ServiceAccount, Roles and CRDs.
* @param clientNamespace namespace which will be created and used as default by kube client
* @param namespaces list of namespaces which will be created
*/
public void prepareEnvForOperator(String clientNamespace, List<String> namespaces) {
public void prepareEnvForOperator(String clientNamespace) {
assumeTrue(!Environment.isHelmInstall() && !Environment.isOlmInstall());
applyClusterOperatorInstallFiles(clientNamespace);

if (cluster.cluster() instanceof OpenShift) {
// This is needed in case you are using internal kubernetes registry and you want to pull images from there
if (kubeClient().getNamespace(Environment.STRIMZI_ORG) != null) {
for (String namespace : namespaces) {
LOGGER.debug("Setting group policy for Openshift registry in Namespace: " + namespace);
Exec.exec(null, Arrays.asList("oc", "policy", "add-role-to-group", "system:image-puller", "system:serviceaccounts:" + namespace, "-n", Environment.STRIMZI_ORG), 0, Level.DEBUG, false);
}
}
}
}

public String changeLeaseNameInResourceIfNeeded(String yamlPath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ private void clusterOperator(long operationTimeout, long reconciliationInterval,

Map<String, Object> values = new HashMap<>();
// image registry config
values.put("defaultImageRegistry", Environment.STRIMZI_REGISTRY);
values.put("defaultImageRegistry", Environment.getIfNotEmptyOrDefault(Environment.STRIMZI_REGISTRY, Environment.STRIMZI_REGISTRY_DEFAULT));
values.put("kafkaBridge.image.registry", Environment.STRIMZI_REGISTRY_DEFAULT);

// image repository config
values.put("defaultImageRepository", Environment.STRIMZI_ORG);
values.put("defaultImageRepository", Environment.getIfNotEmptyOrDefault(Environment.STRIMZI_ORG, Environment.STRIMZI_ORG_DEFAULT));
values.put("kafkaBridge.image.repository", Environment.STRIMZI_ORG_DEFAULT);

// image tags config
values.put("defaultImageTag", Environment.STRIMZI_TAG);
values.put("defaultImageTag", Environment.getIfNotEmptyOrDefault(Environment.STRIMZI_TAG, Environment.STRIMZI_TAG_DEFAULT));
values.put("kafkaBridge.image.tag", BridgeUtils.getBridgeVersion());

// Additional config
Expand Down

0 comments on commit 21f78bd

Please sign in to comment.