Skip to content

Commit

Permalink
Merge pull request #69 from fabiobrz/exp.xtf-k8s-client-672
Browse files Browse the repository at this point in the history
[Upgrade Fabric8 Kubernetes Client to 6.8.1] - Solving broken APIs changes
  • Loading branch information
marekkopecky authored Sep 1, 2023
2 parents ca0ab32 + a7cae1a commit 1d8d036
Show file tree
Hide file tree
Showing 16 changed files with 175 additions and 79 deletions.
2 changes: 1 addition & 1 deletion global-test.properties
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ intersmash.activemq.operators.package_manifest=activemq-artemis-operator
intersmash.activemq.operators.channel=upstream

# Kafka operator settings
intersmash.kafka.operators.channel=strimzi-0.29.x
intersmash.kafka.operators.channel=stable

# DB
intersmash.mysql.image=quay.io/centos7/mysql-80-centos7
Expand Down
33 changes: 27 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@

<!--
Using XTF snapshot in order to include fixes in:
https://github.com/xtf-cz/xtf/commit/a833c545082b314db538ed0c73e93310752654f7
https://github.com/xtf-cz/xtf/commit/0ed7dc16c88087ce9073a447311be6c01a520f8a
https://github.com/xtf-cz/xtf/pull/532
-->
<xtf.version>0.31-202305291230-SNAPSHOT</xtf.version>
<xtf.version>0.31-update_kn_client-SNAPSHOT</xtf.version>

<version.junit.jupiter>5.7.0</version.junit.jupiter>

Expand All @@ -39,10 +38,11 @@
<version.logback>1.2.3</version.logback>
<version.org.slf4j>1.7.30</version.org.slf4j>
<version.ide-config>1.1</version.ide-config>
<version.io.strimzi-api>0.28.0</version.io.strimzi-api>
<!-- Strimzi 0.37 SNAPSHOT to have Fabric8 kubernetes client version aligned with XTF (6.8.1) -->
<version.io.strimzi-api>0.37.0-SNAPSHOT</version.io.strimzi-api>
<version.com.fasterxml.jackson>2.13.1</version.com.fasterxml.jackson>
<version.io.fabric8>6.6.0</version.io.fabric8>
<version.openshift-client>5.12.2</version.openshift-client>
<version.io.fabric8>6.8.1</version.io.fabric8>
<version.openshift-client>6.8.1</version.openshift-client>

<!--
Version used for the activemq-artemis-operator;
Expand Down Expand Up @@ -295,6 +295,10 @@
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model-common</artifactId>
</exclusion>
<exclusion>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-client-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- The following ones are used by the generated code for the Hyperfoil APIs -->
Expand Down Expand Up @@ -344,6 +348,11 @@
<artifactId>system-stubs-jupiter</artifactId>
<version>${version.junit5.jupiter.system.stubs}</version>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model-core</artifactId>
<version>${version.io.fabric8}</version>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>generator-annotations</artifactId>
Expand Down Expand Up @@ -602,6 +611,18 @@
<enabled>false</enabled>
</releases>
</repository>
<!-- Strimzi 0.37 SNAPSHOT to have Fabric8 kubernetes client version aligned with XTF (6.8.1) -->
<repository>
<id>ossrh-s</id>
<name>OSS Sonatype Snapshots Repository</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
</repository>
</repositories>

<pluginRepositories>
Expand Down
4 changes: 4 additions & 0 deletions testsuite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
<groupId>io.fabric8</groupId>
<artifactId>openshift-client</artifactId>
</dependency>
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model-core</artifactId>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import org.junit.jupiter.api.Test;
import org.keycloak.k8s.v2alpha1.Keycloak;
import org.keycloak.k8s.v2alpha1.KeycloakRealmImport;
import org.keycloak.k8s.v2alpha1.KeycloakRealmImportOperatorKeycloakList;
import org.keycloak.k8s.v2alpha1.KeycloakRealmImportOperatorRealmImportList;
import org.keycloak.k8s.v2alpha1.KeycloakRealmImportSpec;
import org.keycloak.k8s.v2alpha1.KeycloakSpec;
import org.keycloak.k8s.v2alpha1.keycloakrealmimportspec.Realm;
Expand All @@ -55,7 +57,6 @@
import cz.xtf.core.waiting.SimpleWaiter;
import cz.xtf.junit5.annotations.CleanBeforeAll;
import io.fabric8.kubernetes.api.model.DeletionPropagation;
import io.fabric8.kubernetes.api.model.KubernetesResourceList;
import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation;
import io.fabric8.kubernetes.client.dsl.Resource;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -315,9 +316,9 @@ private void verifyKeycloak(Keycloak keycloak, boolean waitForPods) {
}

private void verifyKeycloak(Keycloak keycloak, KeycloakRealmImport realmImport, boolean waitForPods) {
NonNamespaceOperation<Keycloak, KubernetesResourceList<Keycloak>, Resource<Keycloak>> keycloakClient = KEYCLOAK_OPERATOR_PROVISIONER
NonNamespaceOperation<Keycloak, KeycloakRealmImportOperatorKeycloakList, Resource<Keycloak>> keycloakClient = KEYCLOAK_OPERATOR_PROVISIONER
.keycloakClient();
NonNamespaceOperation<KeycloakRealmImport, KubernetesResourceList<KeycloakRealmImport>, Resource<KeycloakRealmImport>> keycloakRealmImportClient = KEYCLOAK_OPERATOR_PROVISIONER
NonNamespaceOperation<KeycloakRealmImport, KeycloakRealmImportOperatorRealmImportList, Resource<KeycloakRealmImport>> keycloakRealmImportClient = KEYCLOAK_OPERATOR_PROVISIONER
.keycloakRealmImportClient();
// create and verify that object exists
keycloakClient.createOrReplace(keycloak);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public Subscription() {
super();
}

private SubscriptionFluent.SpecNested<SubscriptionBuilder> getConfiguredSubscriptionBuilder(String sourceNamespace,
private SubscriptionFluent<SubscriptionBuilder>.SpecNested<SubscriptionBuilder> getConfiguredSubscriptionBuilder(
String sourceNamespace,
String source, String name, String channel,
String installPlanApproval) {
return new SubscriptionBuilder()
Expand Down
15 changes: 12 additions & 3 deletions tools/intersmash-tools-provisioners/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,16 @@
<dependency>
<groupId>io.fabric8</groupId>
<artifactId>generator-annotations</artifactId>
<version>6.6.0</version>
</dependency>

<dependency>
<groupId>io.fabric8</groupId>
<artifactId>kubernetes-model-core</artifactId>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
</dependency>

</dependencies>
Expand Down Expand Up @@ -194,8 +203,8 @@
<url>https://raw.githubusercontent.com/artemiscloud/activemq-artemis-operator/${version.intersmash.activemq.operators}/bundle/manifests/broker.amq.io_activemqartemisaddresses.yaml</url>
<url>https://raw.githubusercontent.com/artemiscloud/activemq-artemis-operator/${version.intersmash.activemq.operators}/bundle/manifests/broker.amq.io_activemqartemisscaledowns.yaml</url>
<!-- Keycloak Operator -->
<url>https://raw.githubusercontent.com/keycloak/keycloak-k8s-resources/21.1.1/kubernetes/keycloaks.k8s.keycloak.org-v1.yml</url>
<url>https://raw.githubusercontent.com/keycloak/keycloak-k8s-resources/21.1.1/kubernetes/keycloakrealmimports.k8s.keycloak.org-v1.yml</url>
<url>https://raw.githubusercontent.com/keycloak/keycloak-k8s-resources/22.0.1/kubernetes/keycloaks.k8s.keycloak.org-v1.yml</url>
<url>https://raw.githubusercontent.com/keycloak/keycloak-k8s-resources/22.0.1/kubernetes/keycloakrealmimports.k8s.keycloak.org-v1.yml</url>
</urls>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
*/
public interface KafkaOperatorApplication extends OperatorApplication {

String KAFKA_VERSION = "3.2.0";
String INTER_BROKER_PROTOCOL_VERSION = "3.2";
String KAFKA_VERSION = "3.5.1";
String INTER_BROKER_PROTOCOL_VERSION = "3.5";
int KAFKA_INSTANCE_NUM = 3;
int TOPIC_RECONCILIATION_INTERVAL_SECONDS = 90;
long USER_RECONCILIATION_INTERVAL_SECONDS = 120L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,8 @@ public NonNamespaceOperation<ActiveMQArtemisAddress, ActiveMQArtemisAddressList,
throw new RuntimeException(String.format("[%s] custom resource is not provided by [%s] operator.",
ACTIVE_MQ_ARTEMIS_ADDRESS_RESOURCE, OPERATOR_ID));
}

MixedOperation<ActiveMQArtemisAddress, ActiveMQArtemisAddressList, Resource<ActiveMQArtemisAddress>> addressesClient = OpenShifts
.master().customResources(crdc, ActiveMQArtemisAddress.class, ActiveMQArtemisAddressList.class);
.master().newHasMetadataOperation(crdc, ActiveMQArtemisAddress.class, ActiveMQArtemisAddressList.class);
ACTIVE_MQ_ARTEMIS_ADDRESSES_CLIENT = addressesClient.inNamespace(OpenShiftConfig.namespace());
}
return ACTIVE_MQ_ARTEMIS_ADDRESSES_CLIENT;
Expand Down Expand Up @@ -125,9 +124,8 @@ public NonNamespaceOperation<ActiveMQArtemis, ActiveMQArtemisList, Resource<Acti
throw new RuntimeException(String.format("[%s] custom resource is not provided by [%s] operator.",
ACTIVE_MQ_ARTEMIS_RESOURCE, OPERATOR_ID));
}

MixedOperation<ActiveMQArtemis, ActiveMQArtemisList, Resource<ActiveMQArtemis>> amqClient = OpenShifts
.master().customResources(crdc, ActiveMQArtemis.class, ActiveMQArtemisList.class);
.master().newHasMetadataOperation(crdc, ActiveMQArtemis.class, ActiveMQArtemisList.class);
ACTIVE_MQ_ARTEMISES_CLIENT = amqClient.inNamespace(OpenShiftConfig.namespace());
}
return ACTIVE_MQ_ARTEMISES_CLIENT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ NonNamespaceOperation<Hyperfoil, HyperfoilList, Resource<Hyperfoil>> hyperfoilCl
HYPERFOIL_CUSTOM_RESOURCE_DEFINITION, OPERATOR_ID));
}
MixedOperation<Hyperfoil, HyperfoilList, Resource<Hyperfoil>> hyperfoilCrClient = OpenShifts
.master().customResources(crdc, Hyperfoil.class, HyperfoilList.class);
.master().newHasMetadataOperation(crdc, Hyperfoil.class, HyperfoilList.class);
HYPERFOIL_CUSTOM_RESOURCE_CLIENT = hyperfoilCrClient.inNamespace(OpenShiftConfig.namespace());
}
return HYPERFOIL_CUSTOM_RESOURCE_CLIENT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ public void deploy() {
// create custom resources
int replicas = getApplication().getInfinispan().getSpec().getReplicas();
infinispansClient().createOrReplace(getApplication().getInfinispan());
if (getApplication().getCaches().size() > 0)
cachesClient().createOrReplace(getApplication().getCaches().stream().toArray(Cache[]::new));
if (getApplication().getCaches().size() > 0) {
getApplication().getCaches().stream().forEach((i) -> cachesClient().resource(i).create());
}

// This might be a litle bit naive, but we need more use cases to see how will this behave and what other
// use-cases we have to cover wait for infinispan pods - look for "clusterName" in infinispan pod
Expand Down Expand Up @@ -220,10 +221,9 @@ public NonNamespaceOperation<Infinispan, InfinispanList, Resource<Infinispan>> i
throw new RuntimeException(String.format("[%s] custom resource is not provided by [%s] operator.",
INFINISPAN_RESOURCE, OPERATOR_ID));
}

MixedOperation<Infinispan, InfinispanList, Resource<Infinispan>> infinispansClient = OpenShifts
.master()
.customResources(crdc, Infinispan.class, InfinispanList.class);
.newHasMetadataOperation(crdc, Infinispan.class, InfinispanList.class);
INFINISPAN_CLIENT = infinispansClient.inNamespace(OpenShiftConfig.namespace());
}
return INFINISPAN_CLIENT;
Expand Down Expand Up @@ -254,10 +254,9 @@ public NonNamespaceOperation<Cache, CacheList, Resource<Cache>> cachesClient() {
throw new RuntimeException(String.format("[%s] custom resource is not provided by [%s] operator.",
INFINISPAN_CACHE_RESOURCE, OPERATOR_ID));
}

MixedOperation<Cache, CacheList, Resource<Cache>> cachesClient = OpenShifts
.master()
.customResources(crdc, Cache.class, CacheList.class);
.newHasMetadataOperation(crdc, Cache.class, CacheList.class);
INFINISPAN_CACHES_CLIENT = cachesClient.inNamespace(OpenShiftConfig.namespace());
}
return INFINISPAN_CACHES_CLIENT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public void undeploy() {
// delete the resources

if (getApplication().getUsers() != null) {
if (!kafkasUserClient().delete()) {
if (kafkasUserClient().delete().isEmpty()) {
log.warn("Wasn't able to remove all relevant 'Kafka User' resources created for '" + getApplication().getName()
+ "' instance!");
}
Expand All @@ -261,7 +261,7 @@ public void undeploy() {
}

if (getApplication().getTopics() != null) {
if (!kafkasTopicClient().delete()) {
if (kafkasTopicClient().delete().isEmpty()) {
log.warn("Wasn't able to remove all relevant 'Kafka Topic' resources created for '" + getApplication().getName()
+ "' instance!");
}
Expand All @@ -270,7 +270,7 @@ public void undeploy() {
}

if (getApplication().getKafka() != null) {
if (!kafka().withPropagationPolicy(DeletionPropagation.FOREGROUND).delete()) {
if (kafka().withPropagationPolicy(DeletionPropagation.FOREGROUND).delete().isEmpty()) {
log.warn("Wasn't able to remove all relevant 'Kafka' resources created for '" + getApplication().getName()
+ "' instance!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,16 +125,18 @@ public void deploy() {

// create custom resources
keycloaksClient().createOrReplace(getApplication().getKeycloak());
if (getApplication().getKeycloakRealms().size() > 0)
keycloakRealmsClient().createOrReplace(getApplication().getKeycloakRealms().stream().toArray(KeycloakRealm[]::new));
if (getApplication().getKeycloakClients().size() > 0)
keycloakClientsClient()
.createOrReplace(getApplication().getKeycloakClients().stream().toArray(KeycloakClient[]::new));
if (getApplication().getKeycloakUsers().size() > 0)
keycloakUsersClient().createOrReplace(getApplication().getKeycloakUsers().stream().toArray(KeycloakUser[]::new));
if (getApplication().getKeycloakBackups().size() > 0)
keycloakBackupsClient()
.createOrReplace(getApplication().getKeycloakBackups().stream().toArray(KeycloakBackup[]::new));
if (getApplication().getKeycloakRealms().size() > 0) {
getApplication().getKeycloakRealms().stream().forEach((i) -> keycloakRealmsClient().resource(i).create());
}
if (getApplication().getKeycloakClients().size() > 0) {
getApplication().getKeycloakClients().stream().forEach((i) -> keycloakClientsClient().resource(i).create());
}
if (getApplication().getKeycloakUsers().size() > 0) {
getApplication().getKeycloakUsers().stream().forEach((i) -> keycloakUsersClient().resource(i).create());
}
if (getApplication().getKeycloakBackups().size() > 0) {
getApplication().getKeycloakBackups().stream().forEach((i) -> keycloakBackupsClient().resource(i).create());
}

// Wait for Keycloak (and PostgreSQL) to be ready
waitFor(getApplication().getKeycloak());
Expand Down Expand Up @@ -287,10 +289,9 @@ public NonNamespaceOperation<Keycloak, KeycloakList, Resource<Keycloak>> keycloa
throw new RuntimeException(String.format("[%s] custom resource is not provided by [%s] operator.",
KEYCLOAK_RESOURCE, OPERATOR_ID));
}

MixedOperation<Keycloak, KeycloakList, Resource<Keycloak>> keycloaksClient = OpenShifts
.master()
.customResources(crdc, Keycloak.class, KeycloakList.class);
.newHasMetadataOperation(crdc, Keycloak.class, KeycloakList.class);
KEYCLOAKS_CLIENT = keycloaksClient.inNamespace(OpenShiftConfig.namespace());
}
return KEYCLOAKS_CLIENT;
Expand Down Expand Up @@ -321,10 +322,9 @@ public NonNamespaceOperation<KeycloakRealm, KeycloakRealmList, Resource<Keycloak
throw new RuntimeException(String.format("[%s] custom resource is not provided by [%s] operator.",
KEYCLOAK_REALM_RESOURCE, OPERATOR_ID));
}

MixedOperation<KeycloakRealm, KeycloakRealmList, Resource<KeycloakRealm>> keycloakRealmsClient = OpenShifts
.master()
.customResources(crdc, KeycloakRealm.class, KeycloakRealmList.class);
.newHasMetadataOperation(crdc, KeycloakRealm.class, KeycloakRealmList.class);
KEYCLOAK_REALMS_CLIENT = keycloakRealmsClient.inNamespace(OpenShiftConfig.namespace());
}
return KEYCLOAK_REALMS_CLIENT;
Expand Down Expand Up @@ -372,10 +372,9 @@ public NonNamespaceOperation<KeycloakBackup, KeycloakBackupList, Resource<Keyclo
throw new RuntimeException(String.format("[%s] custom resource is not provided by [%s] operator.",
KEYCLOAK_BACKUP_RESOURCE, OPERATOR_ID));
}

MixedOperation<KeycloakBackup, KeycloakBackupList, Resource<KeycloakBackup>> keycloakBackupsClient = OpenShifts
.master()
.customResources(crdc, KeycloakBackup.class, KeycloakBackupList.class);
.newHasMetadataOperation(crdc, KeycloakBackup.class, KeycloakBackupList.class);
KEYCLOAK_BACKUPS_CLIENT = keycloakBackupsClient.inNamespace(OpenShiftConfig.namespace());
}
return KEYCLOAK_BACKUPS_CLIENT;
Expand Down Expand Up @@ -423,10 +422,9 @@ public NonNamespaceOperation<KeycloakClient, KeycloakClientList, Resource<Keyclo
throw new RuntimeException(String.format("[%s] custom resource is not provided by [%s] operator.",
KEYCLOAK_CLIENT_RESOURCE, OPERATOR_ID));
}

MixedOperation<KeycloakClient, KeycloakClientList, Resource<KeycloakClient>> keycloakClientsClient = OpenShifts
.master()
.customResources(crdc, KeycloakClient.class, KeycloakClientList.class);
.newHasMetadataOperation(crdc, KeycloakClient.class, KeycloakClientList.class);
KEYCLOAK_CLIENTS_CLIENT = keycloakClientsClient.inNamespace(OpenShiftConfig.namespace());
}
return KEYCLOAK_CLIENTS_CLIENT;
Expand Down Expand Up @@ -474,10 +472,9 @@ public NonNamespaceOperation<KeycloakUser, KeycloakUserList, Resource<KeycloakUs
throw new RuntimeException(String.format("[%s] custom resource is not provided by [%s] operator.",
KEYCLOAK_USER_RESOURCE, OPERATOR_ID));
}

MixedOperation<KeycloakUser, KeycloakUserList, Resource<KeycloakUser>> keycloakUsersClient = OpenShifts
.master()
.customResources(crdc, KeycloakUser.class, KeycloakUserList.class);
.newHasMetadataOperation(crdc, KeycloakUser.class, KeycloakUserList.class);
KEYCLOAK_USERS_CLIENT = keycloakUsersClient.inNamespace(OpenShiftConfig.namespace());
}
return KEYCLOAK_USERS_CLIENT;
Expand Down
Loading

0 comments on commit 1d8d036

Please sign in to comment.