use of io.fabric8.kubernetes.api.model.extensions.DeploymentSpec in project fabric8-maven-plugin by fabric8io.
the class DockerImageWatcher method updateImageName.
private void updateImageName(KubernetesClient kubernetes, String namespace, HasMetadata entity, String imagePrefix, String imageName) {
String name = KubernetesHelper.getName(entity);
if (entity instanceof Deployment) {
Deployment resource = (Deployment) entity;
DeploymentSpec spec = resource.getSpec();
if (spec != null) {
if (updateImageName(entity, spec.getTemplate(), imagePrefix, imageName)) {
kubernetes.extensions().deployments().inNamespace(namespace).withName(name).replace(resource);
}
}
} else if (entity instanceof ReplicaSet) {
ReplicaSet resource = (ReplicaSet) entity;
ReplicaSetSpec spec = resource.getSpec();
if (spec != null) {
if (updateImageName(entity, spec.getTemplate(), imagePrefix, imageName)) {
kubernetes.extensions().replicaSets().inNamespace(namespace).withName(name).replace(resource);
}
}
} else if (entity instanceof ReplicationController) {
ReplicationController resource = (ReplicationController) entity;
ReplicationControllerSpec spec = resource.getSpec();
if (spec != null) {
if (updateImageName(entity, spec.getTemplate(), imagePrefix, imageName)) {
kubernetes.replicationControllers().inNamespace(namespace).withName(name).replace(resource);
}
}
} else if (entity instanceof DeploymentConfig) {
DeploymentConfig resource = (DeploymentConfig) entity;
DeploymentConfigSpec spec = resource.getSpec();
if (spec != null) {
if (updateImageName(entity, spec.getTemplate(), imagePrefix, imageName)) {
OpenShiftClient openshiftClient = new Controller(kubernetes).getOpenShiftClientOrNull();
if (openshiftClient == null) {
log.warn("Ignoring DeploymentConfig %s as not connected to an OpenShift cluster", name);
}
openshiftClient.deploymentConfigs().inNamespace(namespace).withName(name).replace(resource);
}
}
}
}
use of io.fabric8.kubernetes.api.model.extensions.DeploymentSpec in project jointware by isdream.
the class PerfComparator method createByObject.
public static void createByObject() {
Deployment dm = new Deployment();
{
ObjectMeta md = new ObjectMeta();
;
md.setName("busybox-dm");
md.setNamespace("wuheng");
{
Map<String, String> labels = new HashMap<String, String>();
labels.put("app", "busybox-dm");
md.setLabels(labels);
}
dm.setMetadata(md);
}
{
DeploymentSpec spec = new DeploymentSpec();
spec.setReplicas(2);
{
PodTemplateSpec template = new PodTemplateSpec();
{
PodSpec pc = new PodSpec();
{
List<Container> containers = new ArrayList<Container>();
{
Container c = new Container();
{
c.setImage("dcr.io:5000/busybox:latest");
c.setImagePullPolicy("IfNotPresent");
c.setName("busybox-dm");
List<String> commands = new ArrayList<String>();
{
commands.add("sleep");
commands.add("3600");
}
c.setCommand(commands);
}
containers.add(c);
}
pc.setContainers(containers);
}
template.setSpec(pc);
}
spec.setTemplate(template);
}
dm.setSpec(spec);
}
}
use of io.fabric8.kubernetes.api.model.extensions.DeploymentSpec in project fabric8-maven-plugin by fabric8io.
the class KubernetesResourceUtil method getPodLabelSelector.
public static LabelSelector getPodLabelSelector(HasMetadata entity) {
LabelSelector selector = null;
if (entity instanceof Deployment) {
Deployment resource = (Deployment) entity;
DeploymentSpec spec = resource.getSpec();
if (spec != null) {
selector = spec.getSelector();
}
} else if (entity instanceof ReplicaSet) {
ReplicaSet resource = (ReplicaSet) entity;
ReplicaSetSpec spec = resource.getSpec();
if (spec != null) {
selector = spec.getSelector();
}
} else if (entity instanceof DeploymentConfig) {
DeploymentConfig resource = (DeploymentConfig) entity;
DeploymentConfigSpec spec = resource.getSpec();
if (spec != null) {
selector = toLabelSelector(spec.getSelector());
}
} else if (entity instanceof ReplicationController) {
ReplicationController resource = (ReplicationController) entity;
ReplicationControllerSpec spec = resource.getSpec();
if (spec != null) {
selector = toLabelSelector(spec.getSelector());
}
} else if (entity instanceof DaemonSet) {
DaemonSet resource = (DaemonSet) entity;
DaemonSetSpec spec = resource.getSpec();
if (spec != null) {
selector = spec.getSelector();
}
} else if (entity instanceof StatefulSet) {
StatefulSet resource = (StatefulSet) entity;
StatefulSetSpec spec = resource.getSpec();
if (spec != null) {
selector = spec.getSelector();
}
} else if (entity instanceof Job) {
Job resource = (Job) entity;
JobSpec spec = resource.getSpec();
if (spec != null) {
selector = spec.getSelector();
}
}
return selector;
}
use of io.fabric8.kubernetes.api.model.extensions.DeploymentSpec in project fabric8-maven-plugin by fabric8io.
the class DebugEnricher method enableDebug.
private boolean enableDebug(HasMetadata entity) {
if (entity instanceof Deployment) {
Deployment resource = (Deployment) entity;
DeploymentSpec spec = resource.getSpec();
if (spec != null) {
return enableDebugging(entity, spec.getTemplate());
}
} else if (entity instanceof ReplicaSet) {
ReplicaSet resource = (ReplicaSet) entity;
ReplicaSetSpec spec = resource.getSpec();
if (spec != null) {
return enableDebugging(entity, spec.getTemplate());
}
} else if (entity instanceof ReplicationController) {
ReplicationController resource = (ReplicationController) entity;
ReplicationControllerSpec spec = resource.getSpec();
if (spec != null) {
return enableDebugging(entity, spec.getTemplate());
}
} else if (entity instanceof DeploymentConfig) {
DeploymentConfig resource = (DeploymentConfig) entity;
DeploymentConfigSpec spec = resource.getSpec();
if (spec != null) {
return enableDebugging(entity, spec.getTemplate());
}
}
return false;
}
use of io.fabric8.kubernetes.api.model.extensions.DeploymentSpec in project fabric8 by fabric8io.
the class DeploymentPodsAssert method pods.
@Override
public PodSelectionAssert pods() {
spec().isNotNull().selector().isNotNull();
DeploymentSpec spec = this.actual.getSpec();
Integer replicas = spec.getReplicas();
LabelSelector selector = spec.getSelector();
Map<String, String> matchLabels = selector.getMatchLabels();
List<LabelSelectorRequirement> matchExpressions = selector.getMatchExpressions();
return new PodSelectionAssert(client, replicas, matchLabels, matchExpressions, "DeploymentConfig " + KubernetesHelper.getName(actual));
}
Aggregations