forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
570 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...es/spi/src/main/java/io/quarkus/kubernetes/spi/KubernetesAdditionalResourceBuildItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
package io.quarkus.kubernetes.spi; | ||
|
||
import java.util.Collection; | ||
|
||
import io.quarkus.builder.item.MultiBuildItem; | ||
|
||
public final class KubernetesAdditionalResourceBuildItem extends MultiBuildItem { | ||
|
||
private final String name; | ||
|
||
public KubernetesAdditionalResourceBuildItem(String name) { | ||
this.name = name; | ||
} | ||
|
||
public String getName() { | ||
return this.name; | ||
} | ||
|
||
public static boolean hasItem(String name, Collection<KubernetesAdditionalResourceBuildItem> items) { | ||
return items.stream().filter(i -> name.equals(i.name)).findAny().isPresent(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-tekton-parent</artifactId> | ||
<version>999-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>quarkus-tekton-deployment</artifactId> | ||
<name>Quarkus - Kubernetes - Tekton - Deployment</name> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.dekorate</groupId> | ||
<artifactId>tekton-annotations</artifactId> | ||
<classifier>noapt</classifier> | ||
<exclusions> | ||
<exclusion> | ||
<groupId>io.sundr</groupId> | ||
<artifactId>*</artifactId> | ||
</exclusion> | ||
<exclusion> | ||
<groupId>com.sun</groupId> | ||
<artifactId>tools</artifactId> | ||
</exclusion> | ||
</exclusions> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-tekton</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-kubernetes-deployment</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<annotationProcessorPaths> | ||
<path> | ||
<groupId>io.quarkus</groupId> | ||
<artifactId>quarkus-extension-processor</artifactId> | ||
<version>${project.version}</version> | ||
</path> | ||
</annotationProcessorPaths> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
39 changes: 39 additions & 0 deletions
39
...kton/deployment/src/main/java/io/quarkus/tekton/deployment/ApplyParamToTaskDecorator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package io.quarkus.tekton.deployment; | ||
|
||
import io.dekorate.deps.tekton.pipeline.v1beta1.TaskSpecFluent; | ||
import io.dekorate.kubernetes.decorator.Decorator; | ||
import io.dekorate.kubernetes.decorator.ResourceProvidingDecorator; | ||
import io.dekorate.tekton.decorator.AddParamToTaskDecorator; | ||
import io.dekorate.tekton.decorator.NamedTaskDecorator; | ||
import io.dekorate.tekton.decorator.TaskProvidingDecorator; | ||
|
||
/** | ||
* Adds a param to a task. | ||
* Similar to {@link AddParamToTaskDecorator} but is meant to be executed at a later point, so it can replace values added by | ||
* it. | ||
*/ | ||
public class ApplyParamToTaskDecorator extends NamedTaskDecorator { | ||
|
||
private final String name; | ||
private final String description; | ||
private final String defaultValue; | ||
|
||
public ApplyParamToTaskDecorator(String taskName, String name, String description, String defaultValue) { | ||
super(taskName); | ||
this.name = name; | ||
this.description = description; | ||
this.defaultValue = defaultValue; | ||
} | ||
|
||
@Override | ||
public void andThenVisit(TaskSpecFluent<?> taskSpec) { | ||
taskSpec.removeMatchingFromParams(p -> name.equals(p.getName())); | ||
taskSpec.addNewParam().withName(name).withDescription(description).withNewDefault().withStringVal(defaultValue) | ||
.endDefault().endParam(); | ||
} | ||
|
||
@Override | ||
public Class<? extends Decorator>[] after() { | ||
return new Class[] { ResourceProvidingDecorator.class, TaskProvidingDecorator.class, AddParamToTaskDecorator.class }; | ||
} | ||
} |
190 changes: 190 additions & 0 deletions
190
...kubernetes/tekton/deployment/src/main/java/io/quarkus/tekton/deployment/TektonConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,190 @@ | ||
package io.quarkus.tekton.deployment; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
import io.quarkus.kubernetes.deployment.PvcVolumeConfig; | ||
import io.quarkus.runtime.annotations.ConfigItem; | ||
import io.quarkus.runtime.annotations.ConfigRoot; | ||
|
||
@ConfigRoot | ||
public class TektonConfig { | ||
|
||
public static final String DEFAULT_DEPLOYER_IMAGE = "lachlanevenson/k8s-kubectl:v1.18.0"; | ||
|
||
public static final String DEFAULT_JVM_DOCKERFILE = "src/main/docker/Dockerfile.jvm"; | ||
public static final String DEFAULT_NATIVE_DOCKERFILE = "src/main/docker/Dockerfile.native"; | ||
|
||
/** | ||
* Feature flag for tekton | ||
*/ | ||
@ConfigItem(defaultValue = "true") | ||
boolean enabled; | ||
|
||
/** | ||
* The name of the group this component belongs too | ||
*/ | ||
@ConfigItem | ||
Optional<String> partOf; | ||
|
||
/** | ||
* The name of the application. This value will be used for naming Kubernetes | ||
* resources like: - Deployment - Service and so on ... | ||
*/ | ||
@ConfigItem(defaultValue = "${quarkus.container-image.name}") | ||
Optional<String> name; | ||
|
||
/** | ||
* The version of the application. | ||
*/ | ||
@ConfigItem(defaultValue = "${quarkus.container-image.tag}") | ||
Optional<String> version; | ||
|
||
/** | ||
* The namespace the generated resources should belong to. If not value is set, | ||
* then the 'namespace' field will not be added to the 'metadata' section of the | ||
* generated manifests. This in turn means that when the manifests are applied | ||
* to a cluster, the namespace will be resolved from the current Kubernetes | ||
* context (see | ||
* https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/#context | ||
* for more details). | ||
*/ | ||
@ConfigItem | ||
Optional<String> namespace; | ||
|
||
/** | ||
* Custom labels to add to all resources | ||
*/ | ||
@ConfigItem | ||
Map<String, String> labels; | ||
|
||
/** | ||
* Custom annotations to add to all resources | ||
*/ | ||
@ConfigItem | ||
Map<String, String> annotations; | ||
|
||
/** | ||
* The name of an external git pipeline resource. | ||
*/ | ||
@ConfigItem | ||
Optional<String> externalGitPipelineResource; | ||
|
||
/** | ||
* The name of the source workspace. | ||
*/ | ||
@ConfigItem(defaultValue = "source") | ||
Optional<String> sourceWorkspace; | ||
|
||
/** | ||
* The name of an external PVC to be used for the source workspace. | ||
*/ | ||
@ConfigItem | ||
Optional<String> externalSourceWorkspaceClaim; | ||
|
||
/** | ||
* The persistent volume claim configuration for the source workspace. The | ||
* option only makes sense when the PVC is going to be generated (no external | ||
* pvc specified). | ||
*/ | ||
@ConfigItem | ||
Optional<PvcVolumeConfig> sourceWorkspaceClaim; | ||
|
||
/** | ||
* The name of workspace to use as a maven artifact repository. | ||
*/ | ||
@ConfigItem | ||
Optional<String> m2Workspace; | ||
|
||
/** | ||
* The name of an external PVC to be used for the m2 artifact repository. | ||
*/ | ||
@ConfigItem | ||
Optional<String> externalM2WorkspaceClaim; | ||
|
||
/** | ||
* The persistent volume claim configuration for the artifact repository. The | ||
* option only makes sense when the PVC is going to be generated (no external | ||
* pvc specified). | ||
*/ | ||
@ConfigItem | ||
Optional<PvcVolumeConfig> m2WorkspaceClaim; | ||
|
||
/** | ||
* The builder image to use. | ||
*/ | ||
@ConfigItem | ||
Optional<String> builderImage; | ||
|
||
/** | ||
* The builder command to use. | ||
*/ | ||
@ConfigItem | ||
Optional<String> builderCommand; | ||
|
||
/** | ||
* The builder command arguments to use. | ||
*/ | ||
@ConfigItem | ||
Optional<List<String>> builderArguments; | ||
|
||
/** | ||
* The docker image to be used for the deployment task. Such image needs to have | ||
* kubectl available. | ||
*/ | ||
@ConfigItem(defaultValue = DEFAULT_DEPLOYER_IMAGE) | ||
Optional<String> deployerImage; | ||
|
||
/** | ||
* The service account to use for the image pushing tasks. An existing or a | ||
* generated service account can be used. If no existing service account is | ||
* provided one will be generated based on the context. | ||
*/ | ||
@ConfigItem | ||
Optional<String> imagePushServiceAccount; | ||
|
||
/** | ||
* The secret to use when generating an image push service account. When no | ||
* existing service account is provided, one will be generated. The generated | ||
* service account may or may not use an existing secret. | ||
*/ | ||
@ConfigItem | ||
Optional<String> imagePushSecret; | ||
|
||
/** | ||
* Wether to upload the local `.docker/config.json` to automatically create the | ||
* secret. | ||
*/ | ||
@ConfigItem | ||
boolean useLocalDockerConfigJson; | ||
|
||
/** | ||
* The username to use for generating image builder secrets. | ||
*/ | ||
@ConfigItem(defaultValue = "docker.io") | ||
Optional<String> registry; | ||
|
||
/** | ||
* The username to use for generating image builder secrets. | ||
*/ | ||
Optional<String> registryUsername; | ||
|
||
/** | ||
* The password to use for generating image builder secrets. | ||
*/ | ||
@ConfigItem | ||
Optional<String> registryPassword; | ||
|
||
/** | ||
* The default Dockerfile to use for jvm builds | ||
*/ | ||
@ConfigItem(defaultValue = DEFAULT_JVM_DOCKERFILE) | ||
public String jvmDockerfile; | ||
|
||
/** | ||
* The default Dockerfile to use for native builds | ||
*/ | ||
@ConfigItem(defaultValue = DEFAULT_NATIVE_DOCKERFILE) | ||
public String nativeDockerfile; | ||
} |
18 changes: 18 additions & 0 deletions
18
...ubernetes/tekton/deployment/src/main/java/io/quarkus/tekton/deployment/TektonEnabled.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
package io.quarkus.tekton.deployment; | ||
|
||
import java.util.function.BooleanSupplier; | ||
|
||
public class TektonEnabled implements BooleanSupplier { | ||
|
||
private final TektonConfig config; | ||
|
||
public TektonEnabled(TektonConfig config) { | ||
this.config = config; | ||
} | ||
|
||
@Override | ||
public boolean getAsBoolean() { | ||
return config.enabled; | ||
} | ||
} |
Oops, something went wrong.