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
Fixes #898
  • Loading branch information
gastaldi committed Jul 30, 2019
1 parent 9f9f063 commit d4ef035
Show file tree
Hide file tree
Showing 22 changed files with 677 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
15 changes: 15 additions & 0 deletions operator/deploy/crds/launcher_v1alpha1_launcher_crd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: apiextensions.k8s.io/v1beta1
kind: CustomResourceDefinition
metadata:
name: launchers.launcher.fabric8.io
spec:
group: launcher.fabric8.io
names:
kind: Launcher
listKind: LauncherList
plural: launchers
singular: launcher
scope: Namespaced
version: v1alpha2
subresources:
status: {}
51 changes: 51 additions & 0 deletions operator/deploy/operator.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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
ports:
- containerPort: 60000
name: metrics
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
env:
- name: WATCH_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: OPERATOR_NAME
value: "launcher-operator"
72 changes: 72 additions & 0 deletions operator/deploy/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
creationTimestamp: null
name: launcher-operator
rules:
- apiGroups:
- ""
resources:
- pods
- services
- endpoints
- persistentvolumeclaims
- events
- configmaps
- secrets
- serviceaccounts
- 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:
- monitoring.coreos.com
resources:
- servicemonitors
verbs:
- get
- create
- apiGroups:
- launcher.fabric8.io
resources:
- '*'
verbs:
- '*'
- apiGroups:
- apiextensions.k8s.io
resources:
- customresourcedefinitions
verbs:
- list
11 changes: 11 additions & 0 deletions operator/deploy/role_binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: launcher-operator
subjects:
- kind: ServiceAccount
name: launcher-operator
roleRef:
kind: Role
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
78 changes: 78 additions & 0 deletions operator/example/cr_next.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
apiVersion: launcher.fabric8.io/v1alpha2
kind: Launcher
metadata:
name: example-launcher
environment: production
spec:
catalog:
repositoryUrl: http://github.com/fabric8-launcher/launcher-booster-catalog
repositoryRef: master
filter: filter expression
reindexToken: token
openshift:
apiUrl: apiUrl (default is the same cluster as the operator is installed)
consoleUrl: consoleUrl
subscriptionToken: token
username: username
password: password
token:
valueFrom:
secretKeyRef:
name: openshift-test-secret
key: token
impersonate: true
clusters:
- id: starter-us-east-1
name: "Starter: US East (Virginia)"
apiUrl: https://api.starter-us-east-1.openshift.com
consoleUrl: https://console.starter-us-east-1.openshift.com
type: starter
- id: starter-us-west-1
name: "Starter: US West (California)"
apiUrl: https://api.starter-us-west-1.openshift.com
consoleUrl: https://console.starter-us-west-1.openshift.com
type: starter
- id: starter-us-west-2
name: "Starter: US West (Oregon)"
apiUrl: https://api.starter-us-west-2.openshift.com
consoleUrl: https://console.starter-us-west-2.openshift.com
type: starter
- id: starter-ca-central-1
name: "Starter: Canada (Central)"
apiUrl: https://api.starter-ca-central-1.openshift.com
consoleUrl: https://console.starter-ca-central-1.openshift.com
type: starter
- id: pro-us-east-1
name: "Pro: US East (N. Virginia)"
apiUrl: https://api.pro-us-east-1.openshift.com
consoleUrl: https://console.pro-us-east-1.openshift.com
type: pro
- id: pro-eu-west-1
name: "Pro: EU West (Ireland)"
apiUrl: https://api.pro-eu-west-1.openshift.com
consoleUrl: https://console.pro-eu-west-1.openshift.com
type: pro
- id: pro-ap-southeast-2
name: "Pro: Asia Pacific (Sydney)"
apiUrl: https://api.pro-ap-southeast-2.openshift.com
consoleUrl: https://console.pro-ap-southeast-2.openshift.com
type: pro
git:
provider: GITHUB
url: https://github.com
repositoryDescription: Generated by the Red Hat Developer Launch (https://developers.redhat.com/launch)
username: username (or secretKeyRef as below)
token:
valueFrom:
secretKeyRef:
name: github-test-secret
key: token
keycloak:
url: https://sso.openshift.io/auth
realm: rh-developers-launch
clientId:
segment:
token: token
sentry:
backendToken: value or valueFrom/secretKeyRef
frontendToken: value or valueFrom/secretKeyRef
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/v1alpha2
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>
Loading

0 comments on commit d4ef035

Please sign in to comment.