Java Code Examples for io.fabric8.kubernetes.api.model.PodSpec#setContainers()
The following examples show how to use
io.fabric8.kubernetes.api.model.PodSpec#setContainers() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EnvVarsConverterTest.java From che with Eclipse Public License 2.0 | 6 votes |
@BeforeMethod public void setUp() { testContainer = new Container(); PodSpec podSpec = new PodSpec(); podSpec.setContainers(singletonList(testContainer)); ObjectMeta podMeta = new ObjectMeta(); podMeta.setName("pod"); Pod pod = new Pod(); pod.setSpec(podSpec); pod.setMetadata(podMeta); Map<String, Pod> pods = new HashMap<>(); pods.put("pod", pod); environment = KubernetesEnvironment.builder().setPods(pods).build(); machine = new InternalMachineConfig(); environment.setMachines( Collections.singletonMap(Names.machineName(podMeta, testContainer), machine)); identity = new RuntimeIdentityImpl("wsId", "blah", "bleh", "infraNamespace"); }
Example 2
Source File: KubernetesIntegrationTest.java From wildfly-camel with Apache License 2.0 | 6 votes |
private PodSpec createPodSpec() throws IOException { PodSpec podSpec = new PodSpec(); podSpec.setHostname("localhost"); Container container = new Container(); container.setImage("docker.io/wildflyext/wildfly-camel:latest"); container.setName("wildfly-camel-test"); ContainerPort port = new ContainerPort(); port.setHostIP("0.0.0.0"); port.setContainerPort(8080); List<ContainerPort> ports = new ArrayList<>(); ports.add(port); container.setPorts(ports); List<Container> containers = new ArrayList<>(); containers.add(container); podSpec.setContainers(containers); return podSpec; }
Example 3
Source File: KubernetesResource.java From camel-quarkus with Apache License 2.0 | 5 votes |
private PodSpec createPodSpec(String containerName) { PodSpec podSpec = new PodSpec(); Container container = new Container(); container.setImage("docker.io/busybox:latest"); container.setName(containerName); List<Container> containers = new ArrayList<>(); containers.add(container); podSpec.setContainers(containers); return podSpec; }
Example 4
Source File: TillerInstaller.java From microbean-helm with Apache License 2.0 | 5 votes |
protected DeploymentSpec createDeploymentSpec(final int replicas, final Map<String, String> labels, final Map<String, String> nodeSelector, String serviceAccountName, final String imageName, final ImagePullPolicy imagePullPolicy, final int maxHistory, final String namespace, final boolean hostNetwork, final boolean tls, final boolean verifyTls) { final DeploymentSpec deploymentSpec = new DeploymentSpec(); deploymentSpec.setReplicas(Math.max(1, replicas)); final PodTemplateSpec podTemplateSpec = new PodTemplateSpec(); final ObjectMeta metadata = new ObjectMeta(); metadata.setLabels(normalizeLabels(labels)); podTemplateSpec.setMetadata(metadata); final PodSpec podSpec = new PodSpec(); serviceAccountName = normalizeServiceAccountName(serviceAccountName); podSpec.setServiceAccountName(serviceAccountName); podSpec.setContainers(Arrays.asList(this.createContainer(imageName, imagePullPolicy, maxHistory, namespace, tls, verifyTls))); podSpec.setHostNetwork(Boolean.valueOf(hostNetwork)); if (nodeSelector != null && !nodeSelector.isEmpty()) { podSpec.setNodeSelector(nodeSelector); } if (tls) { final Volume volume = new Volume(); volume.setName(DEFAULT_NAME + "-certs"); final SecretVolumeSource secretVolumeSource = new SecretVolumeSource(); secretVolumeSource.setSecretName(SECRET_NAME); volume.setSecret(secretVolumeSource); podSpec.setVolumes(Arrays.asList(volume)); } podTemplateSpec.setSpec(podSpec); deploymentSpec.setTemplate(podTemplateSpec); final LabelSelector selector = new LabelSelector(); selector.setMatchLabels(labels); deploymentSpec.setSelector(selector); return deploymentSpec; }
Example 5
Source File: KubernetesSchedulerTests.java From spring-cloud-deployer-kubernetes with Apache License 2.0 | 4 votes |
@Test public void listScheduleWithExternalCronJobs() { CronJobList cronJobList = new CronJobList(); CronJobSpec cronJobSpec = new CronJobSpec(); JobTemplateSpec jobTemplateSpec = new JobTemplateSpec(); JobSpec jobSpec = new JobSpec(); PodTemplateSpec podTemplateSpec = new PodTemplateSpec(); PodSpec podSpec = new PodSpec(); Container container = new Container(); container.setName("test"); container.setImage("busybox"); podSpec.setContainers(Arrays.asList(container)); podSpec.setRestartPolicy("OnFailure"); podTemplateSpec.setSpec(podSpec); jobSpec.setTemplate(podTemplateSpec); jobTemplateSpec.setSpec(jobSpec); cronJobSpec.setJobTemplate(jobTemplateSpec); cronJobSpec.setSchedule("0/10 * * * *"); CronJob cronJob1 = new CronJob(); ObjectMeta objectMeta1 = new ObjectMeta(); Map<String, String> labels = new HashMap<>(); labels.put("spring-cronjob-id", "test"); objectMeta1.setLabels(labels); objectMeta1.setName("job1"); cronJob1.setMetadata(objectMeta1); cronJob1.setSpec(cronJobSpec); ObjectMeta objectMeta2 = new ObjectMeta(); objectMeta2.setName("job2"); CronJob cronJob2 = new CronJob(); cronJob2.setSpec(cronJobSpec); cronJob2.setMetadata(objectMeta2); ObjectMeta objectMeta3 = new ObjectMeta(); objectMeta3.setName("job3"); CronJob cronJob3 = new CronJob(); cronJob3.setSpec(cronJobSpec); cronJob3.setMetadata(objectMeta3); cronJobList.setItems(Arrays.asList(cronJob1, cronJob2, cronJob3)); this.kubernetesClient.batch().cronjobs().create(cronJob1); this.kubernetesClient.batch().cronjobs().create(cronJob2); this.kubernetesClient.batch().cronjobs().create(cronJob3); List<ScheduleInfo> scheduleInfos = this.scheduler.list(); assertThat(scheduleInfos.size() == 1); assertThat(scheduleInfos.get(0).getScheduleName().equals("job1")); }