Skip to content

Commit

Permalink
Native build operator config
Browse files Browse the repository at this point in the history
  • Loading branch information
bouskaJ committed Jan 19, 2023
1 parent 3730a27 commit f0b3f84
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import io.fabric8.openshift.api.model.operatorhub.v1alpha1.InstallPlan;
import io.fabric8.openshift.api.model.operatorhub.v1alpha1.Subscription;
import io.fabric8.openshift.api.model.operatorhub.v1alpha1.SubscriptionBuilder;
import io.fabric8.openshift.api.model.operatorhub.v1alpha1.SubscriptionConfig;
import io.fabric8.openshift.client.OpenShiftConfig;
import io.fabric8.openshift.client.OpenShiftConfigBuilder;

Expand Down Expand Up @@ -145,6 +146,25 @@ public void createSubscription(String channel, String operatorName, String sourc
*/
public void createSubscription(String channel, String operatorName, String source, String subscriptionName,
String subscriptionSourceNamespace, String targetNamespace, boolean clusterWide, String startingWithCSV) {
createSubscription(channel, operatorName, source, subscriptionName, subscriptionSourceNamespace, targetNamespace, clusterWide,
startingWithCSV, null);
}

/**
* Creates the operatorgroup and subscription.
*
* @param channel operatorhub channel
* @param operatorName operator name
* @param source operator catalog source
* @param subscriptionName name of the subscription
* @param subscriptionSourceNamespace namespace of the catalogsource
* @param targetNamespace where the subscription should be created
* @param clusterWide if the installation is clusterwide or not
* @param startingWithCSV the starting CSV version
* @param config subscription config specification
*/
public void createSubscription(String channel, String operatorName, String source, String subscriptionName,
String subscriptionSourceNamespace, String targetNamespace, boolean clusterWide, String startingWithCSV, SubscriptionConfig config) {
LOG.info("Creating subcription with name \"{}\", for operator \"{}\", channel \"{}\", catalog source \"{}\" from \"{}\" namespace",
subscriptionName, operatorName, channel, source, subscriptionSourceNamespace);
// There can be only one operatorgroup in the namespace, otherwise the new operatorhub deployments complain about multiple operatorgroups
Expand Down Expand Up @@ -174,6 +194,7 @@ public void createSubscription(String channel, String operatorName, String sourc
.withSource(source)
.withSourceNamespace(subscriptionSourceNamespace)
.withStartingCSV(startingWithCSV)
.withConfig(config)
.endSpec()
.build();
get().operatorHub().subscriptions().inNamespace(targetNamespace).createOrReplace(s);
Expand Down
15 changes: 14 additions & 1 deletion fuse-products/src/main/java/software/tnb/product/ck/CamelK.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@
import io.fabric8.camelk.v1alpha1.Kamelet;
import io.fabric8.camelk.v1alpha1.KameletBinding;
import io.fabric8.kubernetes.api.model.ConfigMapKeySelector;
import io.fabric8.kubernetes.api.model.Quantity;
import io.fabric8.kubernetes.api.model.Secret;
import io.fabric8.kubernetes.client.dsl.base.PatchContext;
import io.fabric8.kubernetes.client.dsl.base.PatchType;
import io.fabric8.kubernetes.client.utils.Serialization;
import io.fabric8.openshift.api.model.operatorhub.v1alpha1.SubscriptionConfigBuilder;

@AutoService(Product.class)
public class CamelK extends OpenshiftProduct implements KameletOps {
Expand Down Expand Up @@ -89,8 +93,12 @@ public void setupProduct() {
CamelKConfiguration.SUBSCRIPTION_SOURCE, config.subscriptionSource(), config.subscriptionSourceNamespace());
throw new RuntimeException("Operator Hub catalog source " + config.subscriptionSource() + " not found!");
}

OpenshiftClient.get().createSubscription(config.subscriptionChannel(), config.subscriptionOperatorName(), config.subscriptionSource(),
config.subscriptionName(), config.subscriptionSourceNamespace());
config.subscriptionName(), config.subscriptionSourceNamespace(), OpenshiftClient.get().getNamespace(), false, null,
new SubscriptionConfigBuilder().withNewResources().withLimits(Map.of("memory",
// TODO(jbouska): Temporary workaround for native builds (it needs investigation why the memory consumption is so high)
Quantity.parse("7Gi"))).endResources().build());
OpenshiftClient.get().waitForInstallPlanToComplete(config.subscriptionName());
}

Expand Down Expand Up @@ -136,6 +144,11 @@ public void setupProduct() {
camelKClient.v1().integrationPlatforms().delete();
camelKClient.v1().integrationPlatforms().create(ip);

// TODO(@jbouska,@avano): Remove this workaround after migration of camel-k-client to =< v 6.0.0
camelKClient.v1().integrationPlatforms().withName(ip.getMetadata().getName())
.patch(PatchContext.of(PatchType.JSON_MERGE), "{\"spec\":{\"build\":{\"maven\":{\"cliOptions\":[\"-Dquarkus.native"
+ ".native-image-xmx=6g\"]}}}}");

if (TestConfiguration.streamLogs()) {
setupLogger();
}
Expand Down

0 comments on commit f0b3f84

Please sign in to comment.