use of io.dekorate.kubernetes.decorator.ApplyImageDecorator in project quarkus by quarkusio.
the class MinikubeManifestGenerator method generate.
public void generate(KubernetesConfig config) {
ImageConfiguration imageConfig = getImageConfiguration(getProject(), config, configurationRegistry);
Optional<Deployment> existingDeployment = resourceRegistry.groups().getOrDefault(MINIKUBE, new KubernetesListBuilder()).buildItems().stream().filter(i -> i instanceof Deployment).map(i -> (Deployment) i).filter(i -> i.getMetadata().getName().equals(config.getName())).findAny();
if (!existingDeployment.isPresent()) {
resourceRegistry.add(MINIKUBE, createDeployment(config, imageConfig));
}
addDecorators(MINIKUBE, config);
if (config.isHeadless()) {
resourceRegistry.decorate(MINIKUBE, new ApplyHeadlessDecorator(config.getName()));
}
if (config.getReplicas() != 1) {
resourceRegistry.decorate(MINIKUBE, new ApplyReplicasToDeploymentDecorator(config.getName(), config.getReplicas()));
resourceRegistry.decorate(MINIKUBE, new ApplyReplicasToStatefulSetDecorator(config.getName(), config.getReplicas()));
}
String image = Strings.isNotNullOrEmpty(imageConfig.getImage()) ? imageConfig.getImage() : Images.getImage(imageConfig.isAutoPushEnabled() ? (Strings.isNullOrEmpty(imageConfig.getRegistry()) ? DEFAULT_REGISTRY : imageConfig.getRegistry()) : imageConfig.getRegistry(), imageConfig.getGroup(), imageConfig.getName(), imageConfig.getVersion());
resourceRegistry.decorate(MINIKUBE, new ApplyImageDecorator(config.getName(), image));
}
use of io.dekorate.kubernetes.decorator.ApplyImageDecorator in project dekorate by dekorateio.
the class KubernetesManifestGenerator method addDecorators.
@Override
protected void addDecorators(String group, KubernetesConfig config) {
super.addDecorators(group, config);
ImageConfiguration imageConfig = getImageConfiguration(getProject(), config, configurationRegistry);
String image = Strings.isNotNullOrEmpty(imageConfig.getImage()) ? imageConfig.getImage() : Images.getImage(imageConfig.isAutoPushEnabled() ? (Strings.isNullOrEmpty(imageConfig.getRegistry()) ? DEFAULT_REGISTRY : imageConfig.getRegistry()) : imageConfig.getRegistry(), imageConfig.getGroup(), imageConfig.getName(), imageConfig.getVersion());
Container appContainer = new ContainerBuilder().withName(config.getName()).withImage(image).withImagePullPolicy(ImagePullPolicy.IfNotPresent).addNewEnvVar().withName(KUBERNETES_NAMESPACE).withField(METADATA_NAMESPACE).endEnvVar().build();
Project project = getProject();
Optional<VcsConfig> vcsConfig = configurationRegistry.get(VcsConfig.class);
String remote = vcsConfig.map(VcsConfig::getRemote).orElse(Git.ORIGIN);
boolean httpsPrefered = vcsConfig.map(VcsConfig::isHttpsPreferred).orElse(false);
String vcsUrl = project.getScmInfo() != null && Strings.isNotNullOrEmpty(project.getScmInfo().getRemote().get(Git.ORIGIN)) ? Git.getRemoteUrl(project.getRoot(), remote, httpsPrefered).orElse(Labels.UNKNOWN) : Labels.UNKNOWN;
resourceRegistry.decorate(group, new AddVcsUrlAnnotationDecorator(config.getName(), Annotations.VCS_URL, vcsUrl));
resourceRegistry.decorate(group, new AddCommitIdAnnotationDecorator());
resourceRegistry.decorate(group, new ApplyApplicationContainerDecorator(config.getName(), appContainer));
resourceRegistry.decorate(group, new ApplyImageDecorator(config.getName(), image));
for (Container container : config.getInitContainers()) {
resourceRegistry.decorate(group, new AddInitContainerDecorator(config.getName(), container));
}
if (config.getPorts().length > 0) {
resourceRegistry.decorate(group, new AddServiceResourceDecorator(config));
}
Ports.getHttpPort(config).ifPresent(p -> {
resourceRegistry.decorate(group, new AddIngressDecorator(config, Labels.createLabelsAsMap(config, "Ingress")));
resourceRegistry.decorate(group, new AddIngressRuleDecorator(config.getName(), config.getHost(), p));
});
if (config.isHeadless()) {
resourceRegistry.decorate(KUBERNETES, new ApplyHeadlessDecorator(config.getName()));
}
if (config.getReplicas() != null && config.getReplicas() != 1) {
resourceRegistry.decorate(KUBERNETES, new ApplyReplicasDecorator(config.getName(), config.getReplicas()));
}
resourceRegistry.decorate(KUBERNETES, new ApplyDeploymentStrategyDecorator(config.getName(), config.getDeploymentStrategy(), config.getRollingUpdate()));
}
Aggregations