io.javaoperatorsdk.operator.sample.ServiceDependentResource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sample-tomcat-operator Show documentation
Show all versions of sample-tomcat-operator Show documentation
Provisions Tomcat Pods and deploys Webapplications in them
package io.javaoperatorsdk.operator.sample;
import io.fabric8.kubernetes.api.model.ObjectMeta;
import io.fabric8.kubernetes.api.model.Service;
import io.fabric8.kubernetes.api.model.ServiceBuilder;
import io.javaoperatorsdk.operator.ReconcilerUtils;
import io.javaoperatorsdk.operator.api.reconciler.Context;
import io.javaoperatorsdk.operator.processing.dependent.kubernetes.CRUDKubernetesDependentResource;
import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDependent;
@KubernetesDependent(labelSelector = "app.kubernetes.io/managed-by=tomcat-operator")
public class ServiceDependentResource extends CRUDKubernetesDependentResource {
public ServiceDependentResource() {
super(Service.class);
}
@Override
protected Service desired(Tomcat tomcat, Context context) {
final ObjectMeta tomcatMetadata = tomcat.getMetadata();
return new ServiceBuilder(ReconcilerUtils.loadYaml(Service.class, getClass(), "service.yaml"))
.editMetadata()
.withName(tomcatMetadata.getName())
.withNamespace(tomcatMetadata.getNamespace())
.addToLabels("app.kubernetes.io/managed-by", "tomcat-operator")
.endMetadata()
.editSpec()
.addToSelector("app", tomcatMetadata.getName())
.endSpec()
.build();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy