Skip to content
This repository has been archived by the owner on May 29, 2024. It is now read-only.

Commit

Permalink
feat(operator): Add Quarkus Operator
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed Aug 1, 2019
1 parent a159a48 commit 5e8e43d
Show file tree
Hide file tree
Showing 23 changed files with 664 additions and 2 deletions.
7 changes: 6 additions & 1 deletion cico_build_deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ docker build -t ${BUILDER_IMAGE} -f Dockerfile.build .

docker run --detach=true --name ${BUILDER_CONT} -t -v $(pwd)/${TARGET_DIR}:/${TARGET_DIR}:Z ${BUILDER_IMAGE} /bin/tail -f /dev/null #FIXME

docker exec ${BUILDER_CONT} ./mvnw -B clean install -Dmaven.test.skip=true -DfailIfNoTests=false -DskipTests -Ddownload.plugin.skip.cache
docker exec ${BUILDER_CONT} ./mvnw -B clean install -Dmaven.test.skip=true -DfailIfNoTests=false -DskipTests -Ddownload.plugin.skip.cache -DoperatorNative
docker exec -u root ${BUILDER_CONT} cp web/target/launcher-runner.jar /${TARGET_DIR}
docker exec -u root ${BUILDER_CONT} cp -r web/target/lib/ /${TARGET_DIR}/lib

Expand All @@ -84,6 +84,11 @@ if [ -z $CICO_LOCAL ]; then
tag_push "${REGISTRY_URL}:${TAG}"
tag_push "${REGISTRY_URL}:latest"

# Push Operator
docker tag "quay.io/launcher/launcher-operator:latest" "quay.io/launcher/launcher-operator:${TAG}"
docker push "quay.io/launcher/launcher-operator:${TAG}"
docker push "quay.io/launcher/launcher-operator:latest"

if [[ "$TARGET" != "rhel" && -n "${GENERATOR_DOCKER_HUB_PASSWORD}" ]]; then
docker_login "${GENERATOR_DOCKER_HUB_USERNAME}" "${GENERATOR_DOCKER_HUB_PASSWORD}"
tag_push "${DOCKER_HUB_URL}:${TAG}"
Expand Down
14 changes: 14 additions & 0 deletions operator/deploy/crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: launchers.launcher.fabric8.io
namespace: launcher
spec:
group: launcher.fabric8.io
version: v1beta1
scope: Namespaced
names:
kind: Launcher
listKind: LauncherList
plural: launchers
singular: launcher
4 changes: 4 additions & 0 deletions operator/deploy/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: launcher
48 changes: 48 additions & 0 deletions operator/deploy/operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: launcher-operator
spec:
replicas: 1
selector:
matchLabels:
name: launcher-operator
template:
metadata:
labels:
name: launcher-operator
spec:
serviceAccountName: launcher-operator
containers:
- name: launcher-operator
image: quay.io/gastaldi/launcher-operator:latest
imagePullPolicy: Always
readinessProbe:
httpGet:
path: /health
port: 8080
scheme: HTTP
initialDelaySeconds: 4
periodSeconds: 10
timeoutSeconds: 10
failureThreshold: 1
livenessProbe:
httpGet:
path: /health
port: 8080
scheme: HTTP
initialDelaySeconds: 4
periodSeconds: 10
timeoutSeconds: 10
failureThreshold: 1
ports:
- containerPort: 8080
env:
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
62 changes: 62 additions & 0 deletions operator/deploy/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: launcher-operator
rules:
- apiGroups:
- ""
resources:
- pods
- services
- endpoints
- persistentvolumeclaims
- events
- configmaps
- secrets
- processedtemplates.template.openshift.io
verbs:
- '*'
- apiGroups:
- template.openshift.io
resources:
- processedtemplates
verbs: [ get, list, create, update, delete, deletecollection, watch]
- apiGroups:
- apps.openshift.io
resources:
- deploymentconfigs
- deploymentconfigs/instantiate
verbs: [ get, list, create, update, delete, deletecollection, watch]
- apiGroups:
- route.openshift.io
resources:
- routes
- routes/custom-host
verbs: [ get, list, create, update, delete, deletecollection, watch]
- apiGroups:
- ""
resources:
- namespaces
verbs:
- get
- apiGroups:
- apps
resources:
- deployments
- daemonsets
- replicasets
- statefulsets
verbs:
- '*'
- apiGroups:
- launcher.fabric8.io
resources:
- '*'
verbs:
- '*'
- apiGroups:
- apiextensions.k8s.io
resources:
- customresourcedefinitions
verbs:
- get
12 changes: 12 additions & 0 deletions operator/deploy/role_binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: launcher-operator
subjects:
- kind: ServiceAccount
name: launcher-operator
namespace: launcher
roleRef:
kind: ClusterRole
name: launcher-operator
apiGroup: rbac.authorization.k8s.io
4 changes: 4 additions & 0 deletions operator/deploy/service_account.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: launcher-operator
19 changes: 19 additions & 0 deletions operator/example/cr_minimum.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: launcher.fabric8.io/v1beta1
kind: Launcher
metadata:
name: example-launcher
spec:
openshift:
consoleUrl: consoleUrl
git:
providers:
- id: GitHub
name: "GitHub"
apiUrl: https://api.github.com
repositoryUrl: https://github.com
type: GITHUB
clientProperties:
clientId: CHANGE_TO_CLIENT_ID
serverProperties:
oauthUrl: https://github.com/login/oauth/access_token
clientSecret: CHANGE_TO_CLIENT_SECRET
36 changes: 36 additions & 0 deletions operator/example/cr_next.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
apiVersion: launcher.fabric8.io/v1beta1
kind: Launcher
metadata:
name: example-launcher
spec:
environment: production
catalog:
repositoryUrl: http://github.com/fabric8-launcher/launcher-booster-catalog
repositoryRef: master
filter: filter expression
openshift:
apiUrl: https://api.cluster.openshift.com
consoleUrl: https://console.cluster.openshift.com
username: username
password: password
token: token
impersonate: true
clientId: launcher
git:
providers:
- id: GitHub
name: "GitHub"
apiUrl: https://api.github.com
repositoryUrl: https://github.com
type: GITHUB
clientProperties:
clientId: CHANGE_TO_CLIENT_ID
serverProperties:
oauthUrl: https://github.com/login/oauth/access_token
clientSecret: CHANGE_TO_CLIENT_SECRET
username: username
token: token
keycloak:
url: https://sso.openshift.io/auth
realm: rh-developers-launch
clientId: launcher
13 changes: 13 additions & 0 deletions operator/example/launcher_cr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
apiVersion: launcher.fabric8.io/v1beta1
kind: Launcher
metadata:
name: launcher
spec:

####### OpenShift Configuration
openshift:
consoleUrl: #<the OpenShift Console Url (ex: 'https://192.168.64.4:8443')>#

####### OAuth Configuration
oauth:
enabled: true
112 changes: 112 additions & 0 deletions operator/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<parent>
<artifactId>launcher-parent</artifactId>
<groupId>io.fabric8.launcher</groupId>
<version>1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>launcher-operator</artifactId>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-kubernetes-client</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-health</artifactId>
</dependency>
<!-- Test dependencies -->
<dependency>
<groupId>io.fabric8.launcher</groupId>
<artifactId>launcher-base-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-test-kubernetes-client</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<finalName>launcher-operator</finalName>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>operatorNative</name>
</property>
</activation>
<properties>
<native-image.docker-build>true</native-image.docker-build>
</properties>
<build>
<plugins>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>native-image</goal>
</goals>
<configuration>
<enableHttpUrlHandler>true</enableHttpUrlHandler>
<additionalBuildArgs>-H:IncludeResources=../templates/openshift/launcher-template.yaml</additionalBuildArgs>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemProperties>
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
</systemProperties>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
22 changes: 22 additions & 0 deletions operator/src/main/docker/Dockerfile.jvm
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
####
# This Dockerfile is used in order to build a container that runs the Quarkus application in JVM mode
#
# Before building the docker image run:
#
# mvn package
#
# Then, build the image with:
#
# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/operator-example-jvm .
#
# Then run the container using:
#
# docker run -i --rm -p 8080:8080 quarkus/operator-example-jvm
#
###
FROM fabric8/java-alpine-openjdk8-jre
ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV AB_ENABLED=jmx_exporter
COPY target/lib/* /deployments/lib/
COPY target/*-runner.jar /deployments/app.jar
ENTRYPOINT [ "/deployments/run-java.sh" ]
Loading

0 comments on commit 5e8e43d

Please sign in to comment.