Skip to content
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
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ unacceptable behaviour to any of the project admins or adam.sandor@container-sol

## Bugs

If you find a bug, please [open an issue](https://github.com/ContainerSolutions/java-operator-sdk/issues)! Do try
If you find a bug, please [open an issue](https://github.com/java-operator-sdk/java-operator-sdk/issues)! Do try
to include all the details needed to recreate your problem. This is likely to include:

- The version of the Operator SDK being used
Expand All @@ -24,7 +24,7 @@ to include all the details needed to recreate your problem. This is likely to in
## Building Features and Documentation

If you're looking for something to work on, take look at the issue tracker, in particular any items
labelled [good first issue](https://github.com/ContainerSolutions/java-operator-sdk/labels/good%20first%20issue).
labelled [good first issue](https://github.com/java-operator-sdk/java-operator-sdk/labels/good%20first%20issue).
Please leave a comment on the issue to mention that you have started work, in order to avoid
multiple people working on the same issue.

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ![java-operator-sdk](docs/assets/images/logo.png)
![Java CI with Maven](https://github.com/ContainerSolutions/java-operator-sdk/workflows/Java%20CI%20with%20Maven/badge.svg)
![Java CI with Maven](https://github.com/java-operator-sdk/java-operator-sdk/workflows/Java%20CI%20with%20Maven/badge.svg)

Build Kubernetes Operators in Java without hassle. Inspired by [operator-sdk](https://github.com/operator-framework/operator-sdk).

Expand Down Expand Up @@ -57,7 +57,7 @@ Add [dependency](https://search.maven.org/search?q=a:operator-framework) to your

```xml
<dependency>
<groupId>com.github.containersolutions</groupId>
<groupId>io.javaoperatorsdk</groupId>
<artifactId>operator-framework</artifactId>
<version>{see https://search.maven.org/search?q=a:operator-framework for latest version}</version>
</dependency>
Expand Down Expand Up @@ -145,7 +145,7 @@ Add [this dependency](https://search.maven.org/search?q=a:spring-boot-operator-f

```xml
<dependency>
<groupId>com.github.containersolutions</groupId>
<groupId>io.javaoperatorsdk</groupId>
<artifactId>spring-boot-operator-framework-starter</artifactId>
<version>{see https://search.maven.org/search?q=a:spring-boot-operator-framework-starter for latest version}</version>
</dependency>
Expand Down
2 changes: 1 addition & 1 deletion docs/DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ You can read about the common problems what is this operator framework is solvin
## Getting Started

The easiest way to get started with SDK is start [minikube](https://kubernetes.io/docs/tasks/tools/install-minikube/) and
execute one of our [examples](https://github.com/ContainerSolutions/java-operator-sdk/tree/master/samples/mysql-schema)
execute one of our [examples](https://github.com/java-operator-sdk/java-operator-sdk/tree/master/samples/mysql-schema)

Here are the main steps to develop the code and deploy the operator to a Kubernetes cluster. A more detailed and specific
version can be found under `samples/mysql-schema/README.md`.
Expand Down
10 changes: 5 additions & 5 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ Operators are the way to go. This SDK will make it easy for Java developers to e
We are a friendly team of Java and Kubernetes enthusiasts and welcome everyone to contribute in any way to the framework!
Get in touch either on GitHub or our [Discord server](https://discord.gg/DacEhAy), we are always happy to chat and help
you find the right issue to get started. Feel free to stop by for questions, comments or just saying hi.
We have a [code of conduct](https://github.com/ContainerSolutions/java-operator-sdk/blob/master/CODE_OF_CONDUCT.md)
which we strictly enforce, as well as [issues marked for new joiners](https://github.com/ContainerSolutions/java-operator-sdk/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22).
We have a [code of conduct](https://github.com/java-operator-sdk/java-operator-sdk/blob/master/CODE_OF_CONDUCT.md)
which we strictly enforce, as well as [issues marked for new joiners](https://github.com/java-operator-sdk/java-operator-sdk/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22).

We are also supporting [#HacktoberFest](https://hacktoberfest.digitalocean.com/) and have several issues marked as [good
candidates](https://github.com/ContainerSolutions/java-operator-sdk/issues?q=is%3Aissue+is%3Aopen+label%3A%22hacktoberfest%22+) to pick up during the event.
candidates](https://github.com/java-operator-sdk/java-operator-sdk/issues?q=is%3Aissue+is%3Aopen+label%3A%22hacktoberfest%22+) to pick up during the event.

[Maven](https://mvnrepository.com/artifact/com.github.containersolutions/java-operator-sdk){:.button-text}
[GitHub](https://github.com/ContainerSolutions/java-operator-sdk){:.button-text}
[Maven](https://mvnrepository.com/artifact/io.javaoperatorsdk/java-operator-sdk){:.button-text}
[GitHub](https://github.com/java-operator-sdk/java-operator-sdk){:.button-text}
[Discord](https://discord.gg/DacEhAy){:.button-text}
3 changes: 2 additions & 1 deletion operator-framework/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.github.containersolutions</groupId>
<groupId>io.javaoperatorsdk</groupId>
<artifactId>java-operator-sdk</artifactId>
<version>1.3.1-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>operator-framework</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.containersolutions.operator;
package io.javaoperatorsdk.operator;

import com.github.containersolutions.operator.api.Controller;
import com.github.containersolutions.operator.api.ResourceController;
import io.javaoperatorsdk.operator.api.Controller;
import io.javaoperatorsdk.operator.api.ResourceController;
import io.fabric8.kubernetes.api.builder.Function;
import io.fabric8.kubernetes.client.CustomResource;
import io.fabric8.kubernetes.client.CustomResourceDoneable;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.github.containersolutions.operator;
package io.javaoperatorsdk.operator;

import com.github.containersolutions.operator.api.ResourceController;
import com.github.containersolutions.operator.processing.EventDispatcher;
import com.github.containersolutions.operator.processing.EventScheduler;
import com.github.containersolutions.operator.processing.retry.GenericRetry;
import com.github.containersolutions.operator.processing.retry.Retry;
import io.javaoperatorsdk.operator.api.ResourceController;
import io.javaoperatorsdk.operator.processing.EventDispatcher;
import io.javaoperatorsdk.operator.processing.EventScheduler;
import io.javaoperatorsdk.operator.processing.retry.GenericRetry;
import io.javaoperatorsdk.operator.processing.retry.Retry;
import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition;
import io.fabric8.kubernetes.client.CustomResource;
import io.fabric8.kubernetes.client.CustomResourceDoneable;
Expand All @@ -21,8 +21,6 @@
import java.util.HashMap;
import java.util.Map;

import static com.github.containersolutions.operator.ControllerUtils.*;

@SuppressWarnings("rawtypes")
public class Operator {

Expand Down Expand Up @@ -54,11 +52,11 @@ public <R extends CustomResource> void registerController(ResourceController<R>
@SuppressWarnings("rawtypes")
private <R extends CustomResource> void registerController(ResourceController<R> controller,
boolean watchAllNamespaces, Retry retry, String... targetNamespaces) throws OperatorException {
Class<R> resClass = getCustomResourceClass(controller);
Class<R> resClass = ControllerUtils.getCustomResourceClass(controller);
CustomResourceDefinitionContext crd = getCustomResourceDefinitionForController(controller);
KubernetesDeserializer.registerCustomKind(crd.getVersion(), crd.getKind(), resClass);
String finalizer = getDefaultFinalizer(controller);
MixedOperation client = k8sClient.customResources(crd, resClass, CustomResourceList.class, getCustomResourceDoneableClass(controller));
String finalizer = ControllerUtils.getDefaultFinalizer(controller);
MixedOperation client = k8sClient.customResources(crd, resClass, CustomResourceList.class, ControllerUtils.getCustomResourceDoneableClass(controller));
EventDispatcher eventDispatcher = new EventDispatcher(controller,
finalizer, new EventDispatcher.CustomResourceFacade(client), ControllerUtils.getGenerationEventProcessing(controller));
EventScheduler eventScheduler = new EventScheduler(eventDispatcher, retry);
Expand Down Expand Up @@ -87,7 +85,7 @@ private <R extends CustomResource> void registerWatches(ResourceController<R> co
}

private CustomResourceDefinitionContext getCustomResourceDefinitionForController(ResourceController controller) {
String crdName = getCrdName(controller);
String crdName = ControllerUtils.getCrdName(controller);
CustomResourceDefinition customResourceDefinition = k8sClient.customResourceDefinitions().withName(crdName).get();
if (customResourceDefinition == null) {
throw new OperatorException("Cannot find Custom Resource Definition with name: " + crdName);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.containersolutions.operator;
package io.javaoperatorsdk.operator;

public class OperatorException extends RuntimeException {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.containersolutions.operator.api;
package io.javaoperatorsdk.operator.api;

import io.fabric8.kubernetes.client.CustomResource;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.containersolutions.operator.api;
package io.javaoperatorsdk.operator.api;

import io.fabric8.kubernetes.client.CustomResource;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.containersolutions.operator.api;
package io.javaoperatorsdk.operator.api;

import io.fabric8.kubernetes.client.CustomResource;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.containersolutions.operator.api;
package io.javaoperatorsdk.operator.api;

import io.fabric8.kubernetes.client.CustomResource;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.containersolutions.operator.api;
package io.javaoperatorsdk.operator.api;

public class RetryInfo {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.containersolutions.operator.api;
package io.javaoperatorsdk.operator.api;

import io.fabric8.kubernetes.client.CustomResource;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.containersolutions.operator.processing;
package io.javaoperatorsdk.operator.processing;

import com.github.containersolutions.operator.processing.retry.Retry;
import com.github.containersolutions.operator.processing.retry.RetryExecution;
import io.javaoperatorsdk.operator.processing.retry.Retry;
import io.javaoperatorsdk.operator.processing.retry.RetryExecution;
import io.fabric8.kubernetes.client.CustomResource;
import io.fabric8.kubernetes.client.Watcher;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.containersolutions.operator.processing;
package io.javaoperatorsdk.operator.processing;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.github.containersolutions.operator.processing;
package io.javaoperatorsdk.operator.processing;

import com.github.containersolutions.operator.ControllerUtils;
import com.github.containersolutions.operator.api.*;
import io.javaoperatorsdk.operator.ControllerUtils;
import io.fabric8.kubernetes.client.CustomResource;
import io.fabric8.kubernetes.client.Watcher;
import io.fabric8.kubernetes.client.dsl.MixedOperation;
import io.fabric8.kubernetes.client.dsl.Resource;
import io.javaoperatorsdk.operator.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.containersolutions.operator.processing;
package io.javaoperatorsdk.operator.processing;


import com.github.containersolutions.operator.processing.retry.Retry;
import io.javaoperatorsdk.operator.processing.retry.Retry;
import io.fabric8.kubernetes.client.CustomResource;
import io.fabric8.kubernetes.client.KubernetesClientException;
import io.fabric8.kubernetes.client.Watcher;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.containersolutions.operator.processing;
package io.javaoperatorsdk.operator.processing;

import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.containersolutions.operator.processing.retry;
package io.javaoperatorsdk.operator.processing.retry;

public class GenericRetry implements Retry {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.containersolutions.operator.processing.retry;
package io.javaoperatorsdk.operator.processing.retry;

import java.util.Optional;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.containersolutions.operator.processing.retry;
package io.javaoperatorsdk.operator.processing.retry;

public interface Retry {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.containersolutions.operator.processing.retry;
package io.javaoperatorsdk.operator.processing.retry;

import java.util.Optional;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.containersolutions.operator;
package io.javaoperatorsdk.operator;

import com.github.containersolutions.operator.sample.TestCustomResource;
import com.github.containersolutions.operator.sample.TestCustomResourceController;
import io.javaoperatorsdk.operator.sample.TestCustomResource;
import io.javaoperatorsdk.operator.sample.TestCustomResourceController;
import io.fabric8.kubernetes.api.model.ConfigMap;
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClient;
Expand All @@ -17,7 +17,6 @@
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

import static com.github.containersolutions.operator.IntegrationTestSupport.TEST_NAMESPACE;
import static org.assertj.core.api.Assertions.assertThat;

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
Expand Down Expand Up @@ -48,13 +47,13 @@ public void manyResourcesGetCreatedUpdatedAndDeleted() {
log.info("Creating {} new resources", NUMBER_OF_RESOURCES_CREATED);
for (int i = 0; i < NUMBER_OF_RESOURCES_CREATED; i++) {
TestCustomResource tcr = integrationTest.createTestCustomResource(String.valueOf(i));
integrationTest.getCrOperations().inNamespace(TEST_NAMESPACE).create(tcr);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This files consist undesired changes related to auto refactoring code using IDEA, but it looks good.

integrationTest.getCrOperations().inNamespace(IntegrationTestSupport.TEST_NAMESPACE).create(tcr);
}

Awaitility.await().atMost(1, TimeUnit.MINUTES)
.untilAsserted(() -> {
List<ConfigMap> items = integrationTest.getK8sClient().configMaps()
.inNamespace(TEST_NAMESPACE)
.inNamespace(IntegrationTestSupport.TEST_NAMESPACE)
.withLabel("managedBy", TestCustomResourceController.class.getSimpleName())
.list().getItems();
assertThat(items).hasSize(NUMBER_OF_RESOURCES_CREATED);
Expand All @@ -64,33 +63,33 @@ public void manyResourcesGetCreatedUpdatedAndDeleted() {
// update some resources
for (int i = 0; i < NUMBER_OF_RESOURCES_UPDATED; i++) {
TestCustomResource tcr = (TestCustomResource) integrationTest.getCrOperations()
.inNamespace(TEST_NAMESPACE)
.inNamespace(IntegrationTestSupport.TEST_NAMESPACE)
.withName(IntegrationTestSupport.TEST_CUSTOM_RESOURCE_PREFIX + i)
.get();
tcr.getSpec().setValue(i + UPDATED_SUFFIX);
integrationTest.getCrOperations().inNamespace(TEST_NAMESPACE).createOrReplace(tcr);
integrationTest.getCrOperations().inNamespace(IntegrationTestSupport.TEST_NAMESPACE).createOrReplace(tcr);
}
// sleep for a short time to make variability to the test, so some updates are not executed before delete
Thread.sleep(300);

log.info("Deleting {} resources", NUMBER_OF_RESOURCES_DELETED);
for (int i = 0; i < NUMBER_OF_RESOURCES_DELETED; i++) {
TestCustomResource tcr = integrationTest.createTestCustomResource(String.valueOf(i));
integrationTest.getCrOperations().inNamespace(TEST_NAMESPACE).delete(tcr);
integrationTest.getCrOperations().inNamespace(IntegrationTestSupport.TEST_NAMESPACE).delete(tcr);
}

Awaitility.await().atMost(1, TimeUnit.MINUTES)
.untilAsserted(() -> {
List<ConfigMap> items = integrationTest.getK8sClient().configMaps()
.inNamespace(TEST_NAMESPACE)
.inNamespace(IntegrationTestSupport.TEST_NAMESPACE)
.withLabel("managedBy", TestCustomResourceController.class.getSimpleName())
.list().getItems();
//reducing configmaps to names only - better for debugging
List<String> itemDescs = items.stream().map(configMap -> configMap.getMetadata().getName()).collect(Collectors.toList());
assertThat(itemDescs).hasSize(NUMBER_OF_RESOURCES_CREATED - NUMBER_OF_RESOURCES_DELETED);

List<TestCustomResource> crs = integrationTest.getCrOperations()
.inNamespace(TEST_NAMESPACE)
.inNamespace(IntegrationTestSupport.TEST_NAMESPACE)
.list().getItems();
assertThat(crs).hasSize(NUMBER_OF_RESOURCES_CREATED - NUMBER_OF_RESOURCES_DELETED);
});
Expand Down
Loading