Skip to content

Commit

Permalink
Merge branch 'WINDUP-3407' into wildfly
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/java/org/jboss/windup/operator/util/WindupDeployment.java
  • Loading branch information
carlosthe19916 committed Aug 22, 2022
2 parents 22843d3 + bd3a97f commit b98839a
Show file tree
Hide file tree
Showing 25 changed files with 236 additions and 109 deletions.
23 changes: 13 additions & 10 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: MTA Operator E2E Tests
name: Windup Operator E2E Tests

on: [pull_request,push]

Expand All @@ -8,16 +8,19 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
kubernetes_version: [v1.19.16, v1.20.15, v1.21.10, v1.22.7, v1.23.4]
# check versions in https://github.com/kubernetes/kubernetes/releases
kubernetes_version: [v1.19.16, v1.20.15, v1.21.14, v1.22.13, v1.23.10, v1.24.4]
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Minikube-Kubernetes
uses: manusa/actions-setup-minikube@v2.4.3
# check version in https://github.com/manusa/actions-setup-minikube/releases
uses: manusa/actions-setup-minikube@v2.7.0
with:
minikube version: v1.25.2
# check version in https://github.com/kubernetes/minikube/releases
minikube version: v1.26.1
kubernetes version: ${{ matrix.kubernetes_version }}
github token: ${{ secrets.GITHUB_TOKEN }}
start args: ' --force'
Expand Down Expand Up @@ -59,21 +62,21 @@ jobs:
time: '10s'

- name: Operator Logs
run: kubectl logs --tail=-1 -l app=windup-operator -n mta
run: kubectl logs --tail=-1 -l app=windup-operator -n windup

- name: Sleep for 30 seconds to allow objects to be created
uses: jakejarvis/wait-action@master
with:
time: '30s'

- name: List k8s objects on mta namespace
- name: List k8s objects on windup namespace
id: listobjects
run: kubectl get all,ing,pvc -n mta -o name
run: kubectl get all,ing,pvc -n windup -o name
shell: bash

- name: Get and store number of k8s objects on mta namespace
- name: Get and store number of k8s objects on windup namespace
id: getobjects
run: echo "::set-output name=value::$(kubectl get all,ing,pvc -n mta -o name | wc -l)"
run: echo "::set-output name=value::$(kubectl get all,ing,pvc -n windup -o name | wc -l)"
shell: bash

- name: Operator Test
Expand All @@ -96,7 +99,7 @@ jobs:

- name: List k8s pods for the executor
id: executorpods
run: echo "::set-output name=value::$(kubectl get pods -n mta -o name | grep executor | wc -l)"
run: echo "::set-output name=value::$(kubectl get pods -n windup -o name | grep executor | wc -l)"
shell: bash

- name: Check executor pods are the expected
Expand Down
79 changes: 74 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
# windup-operator project
This project creates an Operator to deploy Windup/MTA on an Openshift cluster ( Kubernetes in future releases)

It consists on a series of yaml files to deploy the operator (CRD, role, rolebinding, serviceaccount) and the native artifact compiled using Quarkus and GraalVM.
This project creates an Operator to deploy Windup on an Openshift cluster ( Kubernetes in future releases)

At this moment the operator reacts to creation of the Windup Custom Resource and will deploy all needed objects ( deployments, ingress, services, persistent volumes).
It consists on a series of yaml files to deploy the operator (CRD, role, rolebinding, serviceaccount) and the native
artifact compiled using Quarkus and GraalVM.

At this moment the operator reacts to creation of the Windup Custom Resource and will deploy all needed objects (
deployments, ingress, services, persistent volumes).

# Installation using Openshift 4.4+ OperatorHub

1. Using a Cluster Wide permissions user
2. Go to Openshift Web Console
3. Administration->Operators->OperatorHub
4. Filter by keyword "mta"
4. Filter by keyword "windup"
5. Click on "Migration Toolkit for Applications"
6. Install the operator
7. Select a namespace created previously by you
Expand All @@ -25,4 +29,69 @@ At this moment the operator reacts to creation of the Windup Custom Resource and

You can create as many applications as you like inside the same namespace.

For every namespace you need to install the operator in order to be able to install the Migration Toolkit for Applications application.
For every namespace you need to install the operator in order to be able to install the Migration Toolkit for
Applications application.

## Deploy the operator into Minikube

### Container image of the operator

Execute:

```shell
mvn clean package -DskipTests \
-Dquarkus.container-image.build=true \
-Dquarkus.container-image.registry=quay.io \
-Dquarkus.container-image.group=$USER \
-Dquarkus.container-image.tag=test
```

Push container to the quay.io registry:

```shell
podman push quay.io/$USER/windup-operator:test
```

### Minikube

Start Minikube:

```shell
minikube start --memory=12g
minikube addons enable ingress
minikube addons enable dashboard
```

Create the k8s `namespace`:

```shell
kubectl create ns windup
```

### Deploy operator

Point to your custom container image:

```shell
sed -i "s\image: quay.io/windupeng/windup-operator-native:latest\image: quay.io/$USER/windup-operator:test\g" src/main/resources/k8s/def/windup.deployment.yaml
```

Create k8s resources:

```shell
cd src/main/resources/k8s/def/
./script.create.all.sh
cd ../../../../../
```

### Init Windup

```shell
kubectl apply -f src/main/resources/k8s/examples/windup.yaml
```

### See your Pods

```shell
minikube dashboard
```
23 changes: 23 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,29 @@
</execution>
</executions>
</plugin>
<!-- added to have the native "runner" application deployed as any other artifact -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.3.0</version>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>${project.build.directory}/${project.build.finalName}-runner</file>
<type>runner</type>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void onStart(@Observes StartupEvent event) {
crClient.watch(windupController);

log.info("Adding Windup Deployments watcher ....");
k8Client.apps().deployments().inNamespace(namespace).withLabel(WindupDeployment.CREATEDBY, WindupDeployment.MTAOPERATOR) .watch(windupDeploymentController);
k8Client.apps().deployments().inNamespace(namespace).withLabel(WindupDeployment.CREATEDBY, WindupDeployment.WINDUP_OPERATOR) .watch(windupDeploymentController);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ private void onUpdate(WindupResource newResource) {
private void updateCRStatus(WindupResource newResource) {
// Consolidate status of the CR
// retrieving number of Pods ready in the namespace and created by the operator
long operandsReady = k8sClient.apps().deployments().inNamespace(namespace).withLabel(WindupDeployment.CREATED_BY, WindupDeployment.MTA_OPERATOR).list()
long operandsReady = k8sClient.apps().deployments().inNamespace(namespace).withLabel(WindupDeployment.CREATED_BY, WindupDeployment.WINDUP_OPERATOR).list()
.getItems().stream().filter(e -> e.getStatus() != null && e.getStatus().getReadyReplicas() != null).mapToInt(e -> e.getStatus().getReadyReplicas()).sum();

boolean shouldbeReady = operandsReady == newResource.desiredDeployments();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public WindupResource() {
}

public int desiredDeployments() {
// mta-web-console=1 , mta-postgres=1, mta-executor=executor_desired_replicas
// windup-web-console=1 , windup-postgres=1, windup-executor=executor_desired_replicas
return 2 + ObjectUtils.defaultIfNull(spec.getExecutor_desired_replicas(), 1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class WindupResourceSpec implements KubernetesResource {
private String application_name;
private String hostname_http;
private String volumeCapacity;
private String mta_Volume_Capacity;
private String windup_Volume_Capacity;
private String docker_images_repository;
private String docker_images_user;
private String docker_images_tag;
Expand Down

0 comments on commit b98839a

Please sign in to comment.