Skip to content

Commit

Permalink
Merge pull request #7339 from iocanel/kubernetes-properties
Browse files Browse the repository at this point in the history
refactor: Kubernetes extension now uses `quarkus.`
  • Loading branch information
geoand authored Feb 23, 2020
2 parents 53d41bd + 2d97a42 commit 3699188
Show file tree
Hide file tree
Showing 40 changed files with 2,167 additions and 275 deletions.
333 changes: 161 additions & 172 deletions docs/src/main/asciidoc/kubernetes.adoc

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

package io.quarkus.kubernetes.deployment;

import java.util.Optional;

import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.annotations.ConfigItem;

@ConfigGroup
public class AwsElasticBlockStoreVolumeConfig {

/**
* The name of the disk to mount.
*/
@ConfigItem
String volumeId;

/**
* The partition.
*/
@ConfigItem
Optional<Integer> partition;

/**
* Filesystem type.
*/
@ConfigItem(defaultValue = "ext4")
String fsType;

/**
* Wether the volumeName is read only or not.
*/
@ConfigItem(defaultValue = "false")
boolean readOnly;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

package io.quarkus.kubernetes.deployment;

import java.util.Map;

import io.dekorate.kubernetes.config.AwsElasticBlockStoreVolume;
import io.dekorate.kubernetes.config.AwsElasticBlockStoreVolumeBuilder;

public class AwsElasticBlockStoreVolumeConverter {

public static AwsElasticBlockStoreVolume convert(Map.Entry<String, AwsElasticBlockStoreVolumeConfig> e) {
return convert(e.getValue()).withVolumeName(e.getKey()).build();
}

private static AwsElasticBlockStoreVolumeBuilder convert(AwsElasticBlockStoreVolumeConfig c) {
AwsElasticBlockStoreVolumeBuilder b = new AwsElasticBlockStoreVolumeBuilder();
b.withVolumeId(c.volumeId);
b.withFsType(c.fsType);
b.withReadOnly(c.readOnly);
c.partition.ifPresent(p -> b.withPartition(p));
return b;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@

package io.quarkus.kubernetes.deployment;

import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.annotations.ConfigItem;

@ConfigGroup
public class AzureDiskVolumeConfig {

public enum CachingMode {
ReadWrite,
ReadOnly,
None
}

public enum Kind {
Managed,
Shared
}

/**
* The name of the disk to mount.
*/
@ConfigItem
String diskName;

/**
* The URI of the vhd blob object OR the resourceID of an Azure managed data disk if Kind is Managed
*/
@ConfigItem
String diskURI;

/**
* Kind of disk.
*/
@ConfigItem(defaultValue = "Managed")
Kind kind;

/**
* Disk caching mode.
*/
@ConfigItem(defaultValue = "ReadWrite")
CachingMode cachingMode;

/**
* File system type.
*/
@ConfigItem(defaultValue = "ext4")
String fsType;

/**
* Wether the volumeName is read only or not.
*/
@ConfigItem(defaultValue = "false")
boolean readOnly;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

package io.quarkus.kubernetes.deployment;

import java.util.Map;

import io.dekorate.kubernetes.config.AzureDiskVolume;
import io.dekorate.kubernetes.config.AzureDiskVolumeBuilder;

public class AzureDiskVolumeConverter {

public static AzureDiskVolume convert(Map.Entry<String, AzureDiskVolumeConfig> e) {
return convert(e.getValue()).withVolumeName(e.getKey()).build();
}

private static AzureDiskVolumeBuilder convert(AzureDiskVolumeConfig c) {
AzureDiskVolumeBuilder b = new AzureDiskVolumeBuilder();
b.withNewDiskName(c.diskName);
b.withDiskURI(c.diskURI);
b.withKind(c.kind.name());
b.withCachingMode(c.cachingMode.name());
b.withFsType(c.fsType);
b.withReadOnly(c.readOnly);
return b;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

package io.quarkus.kubernetes.deployment;

import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.annotations.ConfigItem;

@ConfigGroup
public class AzureFileVolumeConfig {

/**
* The share name.
*/
@ConfigItem
String shareName;

/**
* The secret name.
*/
@ConfigItem
String secretName;

/**
* Wether the volumeName is read only or not.
*/
@ConfigItem(defaultValue = "false")
boolean readOnly;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

package io.quarkus.kubernetes.deployment;

import java.util.Map;

import io.dekorate.kubernetes.config.AzureFileVolume;
import io.dekorate.kubernetes.config.AzureFileVolumeBuilder;

public class AzureFileVolumeConverter {

public static AzureFileVolume convert(Map.Entry<String, AzureFileVolumeConfig> e) {
return convert(e.getValue()).withVolumeName(e.getKey()).build();
}

private static AzureFileVolumeBuilder convert(AzureFileVolumeConfig c) {
AzureFileVolumeBuilder b = new AzureFileVolumeBuilder();
b.withSecretName(c.secretName);
b.withShareName(c.shareName);
b.withReadOnly(c.readOnly);
return b;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package io.quarkus.kubernetes.deployment;

import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.annotations.ConfigItem;

@ConfigGroup
public class ConfigMapVolumeConfig {

/**
* The name of the ConfigMap to mount.
*/
@ConfigItem
String configMapName;

/**
* Default mode.
*
* @return The default mode.
*/
@ConfigItem(defaultValue = "0600")
Integer defaultMode;

/**
* Optional
*/
@ConfigItem(defaultValue = "false")
boolean optional;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

package io.quarkus.kubernetes.deployment;

import java.util.Map;

import io.dekorate.kubernetes.config.ConfigMapVolume;
import io.dekorate.kubernetes.config.ConfigMapVolumeBuilder;

public class ConfigMapVolumeConverter {

public static ConfigMapVolume convert(Map.Entry<String, ConfigMapVolumeConfig> e) {
return convert(e.getValue()).withVolumeName(e.getKey()).build();
}

public static ConfigMapVolumeBuilder convert(ConfigMapVolumeConfig cm) {
ConfigMapVolumeBuilder b = new ConfigMapVolumeBuilder();
b.withConfigMapName(cm.configMapName);
b.withDefaultMode(cm.defaultMode);
b.withOptional(cm.optional);
return b;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
public class Constants {

static final String KUBERNETES = "kubernetes";
static final String OPENSHIFT = "openshift";
static final String KNATIVE = "knative";

static final String DEPLOYMENT_TARGET = "kubernetes.deployment.target";
static final String DEPLOY = "quarkus.kubernetes.deploy";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@

package io.quarkus.kubernetes.deployment;

import java.util.List;
import java.util.Map;
import java.util.Optional;

import io.dekorate.kubernetes.annotation.ImagePullPolicy;
import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.annotations.ConfigItem;

@ConfigGroup
public class ContainerConfig {

/**
* The container image.
*/
@ConfigItem
Optional<String> image;

/**
* Environment variables to add to all containers.
*/
@ConfigItem
Map<String, EnvConfig> envVars;

/**
* Working directory.
*/
@ConfigItem
Optional<String> workingDir;

/**
* The commands
*/
@ConfigItem
Optional<List<String>> command;

/**
* The arguments
*
* @return The arguments.
*/
@ConfigItem
Optional<List<String>> arguments;

/**
* The service account.
*/
@ConfigItem
Optional<String> serviceAccount;

/**
* The host under which the application is going to be exposed.
*
*/
@ConfigItem
Optional<String> host;

/**
* The application ports.
*/
@ConfigItem
Map<String, PortConfig> ports;

/**
* Image pull policy.
*/
@ConfigItem(defaultValue = "IfNotPresent")
ImagePullPolicy imagePullPolicy;

/**
* The image pull secret
*/
@ConfigItem
Optional<List<String>> imagePullSecrets;

/**
* The liveness probe.
*/
@ConfigItem
Optional<ProbeConfig> livenessProbe;

/**
* The readiness probe.
*/
@ConfigItem
Optional<ProbeConfig> readinessProbe;

/**
* Volume mounts.
*/
@ConfigItem
Map<String, MountConfig> mounts;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

package io.quarkus.kubernetes.deployment;

import java.util.Map;

import io.dekorate.kubernetes.config.Container;
import io.dekorate.kubernetes.config.ContainerBuilder;

public class ContainerConverter {

public static Container convert(Map.Entry<String, ContainerConfig> e) {
return convert(e.getValue()).withName(e.getKey()).build();
}

private static ContainerBuilder convert(ContainerConfig c) {
ContainerBuilder b = new ContainerBuilder();
c.image.ifPresent(i -> b.withImage(i));
c.workingDir.ifPresent(w -> b.withWorkingDir(w));
c.readinessProbe.ifPresent(p -> b.withReadinessProbe(ProbeConverter.convert(p)));
c.livenessProbe.ifPresent(p -> b.withLivenessProbe(ProbeConverter.convert(p)));
c.envVars.entrySet().forEach(e -> b.addToEnvVars(EnvConverter.convert(e)));
c.ports.entrySet().forEach(e -> b.addToPorts(PortConverter.convert(e)));
c.mounts.entrySet().forEach(e -> b.addToMounts(MountConverter.convert(e)));
return b;
}
}
Loading

0 comments on commit 3699188

Please sign in to comment.