Search in sources :

Example 1 with OperatorGroup

use of io.fabric8.openshift.api.model.operatorhub.v1.OperatorGroup in project quarkus-test-framework by quarkus-qe.

the class OpenShiftClient method installOperator.

public void installOperator(Service service, String name, String channel, String source, String sourceNamespace) {
    if (!ENABLED_EPHEMERAL_NAMESPACES.getAsBoolean()) {
        throw new UnsupportedOperationException("Operators not supported with ephemeral namespaces disabled");
    }
    // Install the operator group
    OperatorGroup groupModel = new OperatorGroup();
    groupModel.setMetadata(new ObjectMeta());
    groupModel.getMetadata().setName(service.getName());
    groupModel.setSpec(new OperatorGroupSpec());
    groupModel.getSpec().setTargetNamespaces(Arrays.asList(currentNamespace));
    client.resource(groupModel).createOrReplace();
    // Install the subscription
    Subscription subscriptionModel = new Subscription();
    subscriptionModel.setMetadata(new ObjectMeta());
    subscriptionModel.getMetadata().setName(name);
    subscriptionModel.getMetadata().setNamespace(currentNamespace);
    subscriptionModel.setSpec(new SubscriptionSpec());
    subscriptionModel.getSpec().setChannel(channel);
    subscriptionModel.getSpec().setName(name);
    subscriptionModel.getSpec().setSource(source);
    subscriptionModel.getSpec().setSourceNamespace(sourceNamespace);
    Log.info("Installing operator... %s", service.getName());
    client.operatorHub().subscriptions().create(subscriptionModel);
    // Wait for the operator to be installed
    untilIsTrue(() -> {
        // Get Cluster Service Version
        Subscription subscription = client.operatorHub().subscriptions().withName(name).get();
        String installedCsv = subscription.getStatus().getInstalledCSV();
        if (StringUtils.isEmpty(installedCsv)) {
            return false;
        }
        // Check Cluster Service Version status
        ClusterServiceVersion operatorService = client.operatorHub().clusterServiceVersions().withName(installedCsv).get();
        return OPERATOR_PHASE_INSTALLED.equals(operatorService.getStatus().getPhase());
    }, AwaitilitySettings.defaults().withService(service).usingTimeout(service.getConfiguration().getAsDuration(OPERATOR_INSTALL_TIMEOUT, TIMEOUT_DEFAULT)));
    Log.info("Operator installed... %s", service.getName());
}
Also used : ObjectMeta(io.fabric8.kubernetes.api.model.ObjectMeta) OperatorGroupSpec(io.fabric8.openshift.api.model.operatorhub.v1.OperatorGroupSpec) ClusterServiceVersion(io.fabric8.openshift.api.model.operatorhub.v1alpha1.ClusterServiceVersion) Subscription(io.fabric8.openshift.api.model.operatorhub.v1alpha1.Subscription) OperatorGroup(io.fabric8.openshift.api.model.operatorhub.v1.OperatorGroup) SubscriptionSpec(io.fabric8.openshift.api.model.operatorhub.v1alpha1.SubscriptionSpec)

Example 2 with OperatorGroup

use of io.fabric8.openshift.api.model.operatorhub.v1.OperatorGroup in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class OlmBasedStrimziOperatorManager method installOperatorGroup.

private void installOperatorGroup() {
    OperatorGroup operatorGroup = new OperatorGroupBuilder().withNewMetadata().withName(OLM_OPERATOR_GROUP_NAME).withNamespace(namespace).endMetadata().build();
    OpenShiftClient client = kubeClient.client().adapt(OpenShiftClient.class);
    client.operatorHub().operatorGroups().inNamespace(namespace).createOrReplace(operatorGroup);
}
Also used : OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) OperatorGroup(io.fabric8.openshift.api.model.operatorhub.v1.OperatorGroup) OperatorGroupBuilder(io.fabric8.openshift.api.model.operatorhub.v1.OperatorGroupBuilder)

Example 3 with OperatorGroup

use of io.fabric8.openshift.api.model.operatorhub.v1.OperatorGroup in project apicurio-registry by Apicurio.

the class OperatorUtils method createOperatorGroup.

public static OperatorGroup createOperatorGroup(ExtensionContext testContext, String namespace) {
    String name = namespace + "-operator-group";
    LOGGER.info("Creating operator group {} in namespace {} targeting namespace {}...", name, namespace, namespace);
    OperatorGroup operatorGroup = new OperatorGroupBuilder().withNewMetadata().withName(name).withNamespace(namespace).endMetadata().withNewSpec().withTargetNamespaces(namespace).endSpec().build();
    ResourceManager.getInstance().createResource(testContext, true, operatorGroup);
    return operatorGroup;
}
Also used : OperatorGroup(io.fabric8.openshift.api.model.operatorhub.v1.OperatorGroup) OperatorGroupBuilder(io.fabric8.openshift.api.model.operatorhub.v1.OperatorGroupBuilder)

Aggregations

OperatorGroup (io.fabric8.openshift.api.model.operatorhub.v1.OperatorGroup)3 OperatorGroupBuilder (io.fabric8.openshift.api.model.operatorhub.v1.OperatorGroupBuilder)2 ObjectMeta (io.fabric8.kubernetes.api.model.ObjectMeta)1 OperatorGroupSpec (io.fabric8.openshift.api.model.operatorhub.v1.OperatorGroupSpec)1 ClusterServiceVersion (io.fabric8.openshift.api.model.operatorhub.v1alpha1.ClusterServiceVersion)1 Subscription (io.fabric8.openshift.api.model.operatorhub.v1alpha1.Subscription)1 SubscriptionSpec (io.fabric8.openshift.api.model.operatorhub.v1alpha1.SubscriptionSpec)1 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)1