Skip to content

Commit

Permalink
refactor: package naming
Browse files Browse the repository at this point in the history
Signed-off-by: Attila Mészáros <[email protected]>
  • Loading branch information
csviri committed Dec 23, 2024
1 parent 0008aac commit 74c8515
Show file tree
Hide file tree
Showing 85 changed files with 266 additions and 261 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Either in the discussion section here on GitHub or at [Kubernetes Slack Operator
The project introduces two Kubernetes custom resources `Glue` and `GlueOperator`.
You can use `GlueOperator` to define your own operator.
Let's take a look at an example, where we define an operator for WebPage custom resource, that represents a static website served from the Cluster. (You can see the
[full example here](https://github.com/csviri/kubernetes-glue-operator/blob/main/src/test/resources/sample/webpage))
[full example here](https://github.com/java-operator-sdk/kubernetes-glue-operator/blob/main/src/test/resources/sample/webpage))

```yaml

Expand All @@ -48,12 +48,12 @@ spec:
```
To create an operator (or more precisely the controller part) with `kubernetes-glue-operator` we have first apply
the [CRD for WebPage](https://github.com/csviri/kubernetes-glue-operator/blob/main/src/test/resources/sample/webpage/webpage.crd.yml).
the [CRD for WebPage](https://github.com/java-operator-sdk/kubernetes-glue-operator/blob/main/src/test/resources/sample/webpage/webpage.crd.yml).
To define how the `WebPage` should be reconciled, thus what resources should be created for
a `WebPage`, we prepare a `GlueOperator`:

```yaml
apiVersion: io.csviri.operator.glue/v1beta1
apiVersion: io.javaoperatorsdk.operator.glue/v1beta1
kind: GlueOperator
metadata:
name: webpage-operator
Expand Down Expand Up @@ -128,11 +128,11 @@ resources are applied, however, there are certain cases when this is needed also
The following example shows how to deploy a [dynamic admission controller](https://kubernetes.io/docs/reference/access-authn-authz/extensible-admission-controllers/) that mutates
all the `Pods`, adding annotation on them. Note that this is a tricky situation since the endpoint for the `MutatingWebhookConfiguration` is also a `Pod`, thus 'Pods' should be
first up and running before the configuration is applied, otherwise, the mutation webhook will block the changes on the pods, which would render the cluster unable to manage `Pods'.
(Irrelevant details are omitted, see the full version [here](https://github.com/csviri/kubernetes-glue-operator/blob/main/src/test/resources/sample/mutation/mutation.glue.yaml),
see the full E2E test [here](https://github.com/csviri/kubernetes-glue-operator/blob/main/src/test/java/io/csviri/operator/glue/sample/mutation/MutationWebhookDeploymentE2E.java))
(Irrelevant details are omitted, see the full version [here](https://github.com/java-operator-sdk/kubernetes-glue-operator/blob/main/src/test/resources/sample/mutation/mutation.glue.yaml),
see the full E2E test [here](https://github.com/java-operator-sdk/kubernetes-glue-operator/blob/main/src/test/java/io/java-operator-sdk/operator/glue/sample/mutation/MutationWebhookDeploymentE2E.java))

```yaml
apiVersion: io.csviri.operator.glue/v1beta1
apiVersion: io.javaoperatorsdk.operator.glue/v1beta1
kind: Glue
metadata:
name: mutation-webhook-deployment
Expand Down Expand Up @@ -161,7 +161,7 @@ spec:
template:
spec:
containers:
image: ghcr.io/csviri/sample-pod-mutating-webhook:0.1.0
image: ghcr.io/javaoperatorsdk/sample-pod-mutating-webhook:0.1.0
name: pod-mutating-hook
ports:
- containerPort: 443
Expand Down
2 changes: 1 addition & 1 deletion docs/comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ As mentioned before there are solutions that are comparable to ours, and all of

In summary *metacontroller* is a bit more generic solution this moment,
but with additional complexity to manage, and much harder to start with.
The main practical difference is in supporting ["bulk resources"](https://github.com/csviri/kubernetes-glue-operator/issues/75)
The main practical difference is in supporting ["bulk resources"](https://github.com/java-operator-sdk/kubernetes-glue-operator/issues/75)
we will also support it in future versions.

- [Helm Operators](https://sdk.operatorframework.io/docs/building-operators/helm/tutorial/) - are a very efficient
Expand Down
12 changes: 6 additions & 6 deletions docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,35 @@ Start a local Kubernetes cluster using for example [Minikube](https://minikube.s
Apply the CustomResourceDefinitions:

```bash
kubectl apply -f https://github.com/csviri/kubernetes-glue-operator/releases/latest/download/glues.io.csviri.operator.glue-v1.yml -f https://github.com/csviri/kubernetes-glue-operator/releases/latest/download/glueoperators.io.csviri.operator.glue-v1.yml
kubectl apply -f https://github.com/java-operator-sdk/kubernetes-glue-operator/releases/latest/download/glues.io.java-operator-sdk.operator.glue-v1.yml -f https://github.com/java-operator-sdk/kubernetes-glue-operator/releases/latest/download/glueoperators.io.java-operator-sdk.operator.glue-v1.yml
```

Deploy the `kubernetes-glue-operator`:

```bash
kubectl apply -f https://github.com/csviri/kubernetes-glue-operator/releases/latest/download/kubernetes.yml
kubectl apply -f https://github.com/java-operator-sdk/kubernetes-glue-operator/releases/latest/download/kubernetes.yml
```

Note that this deployment gives the controller access to all the resources on the cluster, this is not what you might want in production.

## Try out the [WebPage Sample](https://github.com/csviri/kubernetes-glue-operator/tree/main/src/test/resources/sample/webpage)
## Try out the [WebPage Sample](https://github.com/java-operator-sdk/kubernetes-glue-operator/tree/main/src/test/resources/sample/webpage)

First apply the CustomResourceDefinition for `WebPage` :

```bash
kubectl apply -f https://raw.githubusercontent.com/csviri/kubernetes-glue-operator/main/src/test/resources/sample/webpage/webpage.crd.yaml
kubectl apply -f https://raw.githubusercontent.com/java-operator-sdk/kubernetes-glue-operator/main/src/test/resources/sample/webpage/webpage.crd.yaml
```

Apply the `GlueOperator` for `WebPage`:

```bash
kubectl apply -f https://raw.githubusercontent.com/csviri/kubernetes-glue-operator/main/src/test/resources/sample/webpage/webpage.operator.yaml
kubectl apply -f https://raw.githubusercontent.com/java-operator-sdk/kubernetes-glue-operator/main/src/test/resources/sample/webpage/webpage.operator.yaml
```

Create a new static `WebPage`:

```bash
kubectl apply -f https://raw.githubusercontent.com/csviri/kubernetes-glue-operator/main/src/test/resources/sample/webpage/webpage.sample.yaml
kubectl apply -f https://raw.githubusercontent.com/java-operator-sdk/kubernetes-glue-operator/main/src/test/resources/sample/webpage/webpage.sample.yaml
```

All done! Check the resources created, if using minikube you can open the served WebPage with `minikube service webpage1`.
Expand Down
38 changes: 19 additions & 19 deletions docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ of [Java Operator SDK](https://github.com/operator-framework/java-operator-sdk)
Although it is limited only to Kubernetes resources it makes it very easy to use in language-independent
(DependentResources in JOSDK are also covering external resources) way.

## [Glue resource](https://github.com/csviri/kubernetes-glue-operator/releases/latest/download/glues.glue-v1.yml)
## [Glue resource](https://github.com/java-operator-sdk/kubernetes-glue-operator/releases/latest/download/glues.glue-v1.yml)

`Glue` is the heart of the operator. Note that `GlueOperator` controller just creates a new `Glue` with a related resource,
for each parent custom resource. `Glue` defines `childResources` (sometimes referred to as managed resources) and `related resources`:
Expand Down Expand Up @@ -40,16 +40,16 @@ It has several attributes:

At the moment there are two types of built-in conditions provided:

- **`ReadyCondition`** - check if a resource is up and running. Use it only as a `readyPostCondition`. See sample usage [here](https://github.com/csviri/kubernetes-glue-operator/blob/main/src/test/resources/sample/mutation/mutation.glue.yaml#L24-L25).
- **`ReadyCondition`** - check if a resource is up and running. Use it only as a `readyPostCondition`. See sample usage [here](https://github.com/java-operator-sdk/kubernetes-glue-operator/blob/main/src/test/resources/sample/mutation/mutation.glue.yaml#L24-L25).
- **`JSCondition`** - a generic condition, that allows writing conditions in JavaScript. As input, all the resources are available which
are either child or related. The script should return a boolean value.
See accessing the related resource in [WebPage sample](https://github.com/csviri/kubernetes-glue-operator/blob/main/src/test/resources/sample/webpage/webpage.operator.yaml#L62-L64),
and cross-referencing resources [here](https://github.com/csviri/kubernetes-glue-operator/blob/main/src/test/resources/glue/TwoResourcesAndCondition.yaml#L23-L28).
See accessing the related resource in [WebPage sample](https://github.com/java-operator-sdk/kubernetes-glue-operator/blob/main/src/test/resources/sample/webpage/webpage.operator.yaml#L62-L64),
and cross-referencing resources [here](https://github.com/java-operator-sdk/kubernetes-glue-operator/blob/main/src/test/resources/glue/TwoResourcesAndCondition.yaml#L23-L28).

### Related resources

Related resources are resources that are not reconciled (not created, updated, or deleted) during reconciliation, but serve as an input for it.
See sample usage within `Glue` [here](https://github.com/csviri/kubernetes-glue-operator/blob/main/src/test/resources/glue/RelatedResourceSimpleWithCondition.yaml)
See sample usage within `Glue` [here](https://github.com/java-operator-sdk/kubernetes-glue-operator/blob/main/src/test/resources/glue/RelatedResourceSimpleWithCondition.yaml)
The following attributes can be defined for a related resource:

- **`name`** - same as for child resource, unique identifier, used to reference the resource.
Expand All @@ -63,15 +63,15 @@ The following attributes can be defined for a related resource:
Both in `JSCondition` and resource templates other resources can be referenced by the name.

If there are more `resourceNames` specified for a related resource, the resource is referenced in a form
`[related resource name]#[resource name]`. See sample [here](https://github.com/csviri/kubernetes-glue-operator/blob/main/src/test/resources/glue/MultiNameRelatedResource.yaml).
`[related resource name]#[resource name]`. See sample [here](https://github.com/java-operator-sdk/kubernetes-glue-operator/blob/main/src/test/resources/glue/MultiNameRelatedResource.yaml).

When a resource `B` references another resource `A`, resource `A` will be guaranteed to be in the cache - especially for initial reconciliation when the resource is created -
only if `B` depends on `A` on it. This is natural, in other words, after reconciliation up-to-date version of the resource is guaranteed to be in the cache after reconciliation.
See sample resource cross-referencing [here](https://github.com/csviri/kubernetes-glue-operator/blob/main/src/test/resources/glue/CrossReferenceResource.yaml).
See sample resource cross-referencing [here](https://github.com/java-operator-sdk/kubernetes-glue-operator/blob/main/src/test/resources/glue/CrossReferenceResource.yaml).

The metadata of `Glue` can be referenced under `glueMetadata`, see sample [here](https://github.com/csviri/kubernetes-glue-operator/blob/main/src/test/resources/glue/TemplateForConcurrency.yaml#L12-L12)
The metadata of `Glue` can be referenced under `glueMetadata`, see sample [here](https://github.com/java-operator-sdk/kubernetes-glue-operator/blob/main/src/test/resources/glue/TemplateForConcurrency.yaml#L12-L12)

In addition to that in `GlueOperator` the **`parent`** attribute can be used to reference the parent resource on which behalf the resources are created. See sample [here](https://github.com/csviri/kubernetes-glue-operator/blob/main/src/test/resources/glueoperator/Templating.yaml).
In addition to that in `GlueOperator` the **`parent`** attribute can be used to reference the parent resource on which behalf the resources are created. See sample [here](https://github.com/java-operator-sdk/kubernetes-glue-operator/blob/main/src/test/resources/glueoperator/Templating.yaml).

### Reconciliation notes

Expand All @@ -82,7 +82,7 @@ for a resource that depends on it.

The `DependentResource` implementation of JOSDK makes all kinds of optimizations on the reconciliation which are utilized (or will be also here).

## [GlueOperator resource](https://github.com/csviri/kubernetes-glue-operator/releases/latest/download/glueoperators.glue-v1.yml)
## [GlueOperator resource](https://github.com/java-operator-sdk/kubernetes-glue-operator/releases/latest/download/glueoperators.glue-v1.yml)

The specs of `GlueOperator` are almost identical to `Glue`, it just adds some additional attributes:

Expand All @@ -94,9 +94,9 @@ The specs of `GlueOperator` are almost identical to `Glue`, it just adds some ad
- **`glueMetadata`** - optionally, you can customize the `Glue` resource created for each parent resource.
This is especially important when the parent is a cluster scoped resource - in that case it is mandatory to set.
Using this you can specify the **`name`** and **`namespace`** of the created `Glue`.
See usage on the sample [secret-copy-operator](https://github.com/csviri/kubernetes-glue-operator/blob/main/src/test/resources/sample/secretcopy/secret-copy.operator.yaml#L10-L12).
See usage on the sample [secret-copy-operator](https://github.com/java-operator-sdk/kubernetes-glue-operator/blob/main/src/test/resources/sample/secretcopy/secret-copy.operator.yaml#L10-L12).

See minimal `GlueOperator` [here](https://github.com/csviri/kubernetes-glue-operator/blob/main/src/test/resources/glueoperator/SimpleGlueOperator.yaml).
See minimal `GlueOperator` [here](https://github.com/java-operator-sdk/kubernetes-glue-operator/blob/main/src/test/resources/glueoperator/SimpleGlueOperator.yaml).

## Deployment

Expand All @@ -105,7 +105,7 @@ the default [configuration options](https://docs.quarkiverse.io/quarkus-operator
defined by QOSDK can be overridden using environment variables.

With every release, there are Kubernetes resources provided to make an initial deployment very simple.
See `kubernetes.yml` in [release assets](https://github.com/csviri/kubernetes-glue-operator/releases).
See `kubernetes.yml` in [release assets](https://github.com/java-operator-sdk/kubernetes-glue-operator/releases).
While we will provide more options, users are encouraged to enhance/adjust this for their purposes.

Since the project is a meta-controller, it needs to have access rights to all the resources it manages.
Expand Down Expand Up @@ -144,7 +144,7 @@ custom resource tracked, so if there is a label selector defined for `Glue` it n
to the `Glue` resource when it is created. Since it is not trivial to parse label selectors, in more
complex forms of label selectors (other the ones mentioned above), the labels to add to the `Glue` resources
by a `GlueOperator` needs to be specified explicitly using
[`glue.operator.glue-operator-managed-glue-label`](https://github.com/csviri/kubernetes-glue-operator/blob/main/src/main/java/io/csviri/operator/glue/ControllerConfig.java#L10-L10)
[`glue.operator.glue-operator-managed-glue-label`](https://github.com/java-operator-sdk/kubernetes-glue-operator/blob/main/src/main/java/io/java-operator-sdk/operator/glue/ControllerConfig.java#L10-L10)
config key (which is a type of map). Therefore, for a label selector that specified two values for a glue:

`quarkus.operator-sdk.controllers.glue.selector=mylabel1=value1,mylabel2=value2`
Expand All @@ -156,7 +156,7 @@ you need to add the following configuration params:
`glue.operator.glue-operator-managed-glue-label.mylabel2=value2`

This will ensure that the labels are added correctly to the `Glue`. See the related
[integration test](https://github.com/csviri/kubernetes-glue-operator/blob/main/src/test/java/io/csviri/operator/glue/GlueOperatorComplexLabelSelectorTest.java#L23-L23).
[integration test](https://github.com/java-operator-sdk/kubernetes-glue-operator/blob/main/src/test/java/io/java-operator-sdk/operator/glue/GlueOperatorComplexLabelSelectorTest.java#L23-L23).

### Label selectors managed resources

Expand Down Expand Up @@ -185,12 +185,12 @@ be continuously improved in the follow-up releases.

## Samples

1. [WebPage](https://github.com/csviri/kubernetes-glue-operator/tree/main/src/test/resources/sample/webpage) `GlueOperator`, serves a static website from the cluster.
1. [WebPage](https://github.com/java-operator-sdk/kubernetes-glue-operator/tree/main/src/test/resources/sample/webpage) `GlueOperator`, serves a static website from the cluster.
To achieve this, it creates three resources a `Deployment` running Nginx, a `ConfigMap` that contains the HTML file an mounted to nginx, a `Service` and an optional `Ingress`
to expose the static web page.
3. [Muatation Hook Deployment](https://github.com/csviri/kubernetes-glue-operator/tree/main/src/test/resources/sample/mutation), described on the project home page.
4. [Additional `Glue` samples](https://github.com/csviri/kubernetes-glue-operator/tree/main/src/test/resources/glue), note that these are used for integration testing.
5. [Additional `GlueOperator` samples](https://github.com/csviri/kubernetes-glue-operator/tree/main/src/test/resources/glueoperator), also used for integration testing.
3. [Muatation Hook Deployment](https://github.com/java-operator-sdk/kubernetes-glue-operator/tree/main/src/test/resources/sample/mutation), described on the project home page.
4. [Additional `Glue` samples](https://github.com/java-operator-sdk/kubernetes-glue-operator/tree/main/src/test/resources/glue), note that these are used for integration testing.
5. [Additional `GlueOperator` samples](https://github.com/java-operator-sdk/kubernetes-glue-operator/tree/main/src/test/resources/glueoperator), also used for integration testing.

## Related documents

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>io.csviri.operator.glue</groupId>
<groupId>io.javaoperatorsdk.operator.glue</groupId>
<artifactId>kubernetes-glue-operator</artifactId>
<version>0.4.2-SNAPSHOT</version>
<packaging>jar</packaging>
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.csviri.operator.glue;
package io.javaoperatorsdk.operator.glue;

import java.util.Map;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.csviri.operator.glue;
package io.javaoperatorsdk.operator.glue;

public class GlueException extends RuntimeException {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package io.csviri.operator.glue;
package io.javaoperatorsdk.operator.glue;

import io.quarkus.runtime.Quarkus;
import io.quarkus.runtime.annotations.QuarkusMain;
Expand Down
Loading

0 comments on commit 74c8515

Please sign in to comment.