Skip to content

Commit

Permalink
feat: Container resource requirements and HPA (#390)
Browse files Browse the repository at this point in the history
Allow setting compute resources (CPU and memory requests and limits) required by the container.

Signed-off-by: Mac Atre <mac.atre@gmail.com>

Fixes #27
  • Loading branch information
mac-atre committed Mar 8, 2022
1 parent d9e3342 commit 34621b1
Show file tree
Hide file tree
Showing 5 changed files with 751 additions and 0 deletions.
195 changes: 195 additions & 0 deletions docs/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -2535,6 +2535,7 @@ ContainerProps.builder()
// .name(java.lang.String)
// .port(java.lang.Number)
// .readiness(Probe)
// .resources(Resources)
// .startup(Probe)
// .volumeMounts(java.util.List<VolumeMount>)
// .workingDir(java.lang.String)
Expand Down Expand Up @@ -2680,6 +2681,20 @@ Determines when the container is ready to serve traffic.

---

##### `resources`<sup>Optional</sup> <a name="org.cdk8s.plus22.ContainerProps.property.resources"></a>

```java
public Resources getResources();
```

- *Type:* [`org.cdk8s.plus22.Resources`](#org.cdk8s.plus22.Resources)

Compute resources (CPU and memory requests and limits) required by the container.

> https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
---

##### `startup`<sup>Optional</sup> <a name="org.cdk8s.plus22.ContainerProps.property.startup"></a>

```java
Expand Down Expand Up @@ -2724,6 +2739,41 @@ If not specified, the container runtime's default will be used, which might be c

---

### CpuResources <a name="org.cdk8s.plus22.CpuResources"></a>

CPU request and limit.

#### Initializer <a name="[object Object].Initializer"></a>

```java
import org.cdk8s.plus22.CpuResources;

CpuResources.builder()
.limit(Cpu)
.request(Cpu)
.build();
```

##### `limit`<sup>Required</sup> <a name="org.cdk8s.plus22.CpuResources.property.limit"></a>

```java
public Cpu getLimit();
```

- *Type:* [`org.cdk8s.plus22.Cpu`](#org.cdk8s.plus22.Cpu)

---

##### `request`<sup>Required</sup> <a name="org.cdk8s.plus22.CpuResources.property.request"></a>

```java
public Cpu getRequest();
```

- *Type:* [`org.cdk8s.plus22.Cpu`](#org.cdk8s.plus22.Cpu)

---

### DeploymentProps <a name="org.cdk8s.plus22.DeploymentProps"></a>

Properties for initialization of `Deployment`.
Expand Down Expand Up @@ -3814,6 +3864,41 @@ field is alpha-level and is only honored by servers that enable the

---

### MemoryResources <a name="org.cdk8s.plus22.MemoryResources"></a>

Memory request and limit.

#### Initializer <a name="[object Object].Initializer"></a>

```java
import org.cdk8s.plus22.MemoryResources;

MemoryResources.builder()
.limit(Size)
.request(Size)
.build();
```

##### `limit`<sup>Required</sup> <a name="org.cdk8s.plus22.MemoryResources.property.limit"></a>

```java
public Size getLimit();
```

- *Type:* [`org.cdk8s.Size`](#org.cdk8s.Size)

---

##### `request`<sup>Required</sup> <a name="org.cdk8s.plus22.MemoryResources.property.request"></a>

```java
public Size getRequest();
```

- *Type:* [`org.cdk8s.Size`](#org.cdk8s.Size)

---

### MountOptions <a name="org.cdk8s.plus22.MountOptions"></a>

Options for mounts.
Expand Down Expand Up @@ -4359,6 +4444,41 @@ Metadata that all persisted resources must have, which includes all objects user

---

### Resources <a name="org.cdk8s.plus22.Resources"></a>

CPU and memory compute resources.

#### Initializer <a name="[object Object].Initializer"></a>

```java
import org.cdk8s.plus22.Resources;

Resources.builder()
.cpu(CpuResources)
.memory(MemoryResources)
.build();
```

##### `cpu`<sup>Required</sup> <a name="org.cdk8s.plus22.Resources.property.cpu"></a>

```java
public CpuResources getCpu();
```

- *Type:* [`org.cdk8s.plus22.CpuResources`](#org.cdk8s.plus22.CpuResources)

---

##### `memory`<sup>Required</sup> <a name="org.cdk8s.plus22.Resources.property.memory"></a>

```java
public MemoryResources getMemory();
```

- *Type:* [`org.cdk8s.plus22.MemoryResources`](#org.cdk8s.plus22.MemoryResources)

---

### SecretProps <a name="org.cdk8s.plus22.SecretProps"></a>

#### Initializer <a name="[object Object].Initializer"></a>
Expand Down Expand Up @@ -5345,6 +5465,7 @@ Container.Builder.create()
// .name(java.lang.String)
// .port(java.lang.Number)
// .readiness(Probe)
// .resources(Resources)
// .startup(Probe)
// .volumeMounts(java.util.List<VolumeMount>)
// .workingDir(java.lang.String)
Expand Down Expand Up @@ -5454,6 +5575,16 @@ Determines when the container is ready to serve traffic.

---

##### `resources`<sup>Optional</sup> <a name="org.cdk8s.plus22.ContainerProps.parameter.resources"></a>

- *Type:* [`org.cdk8s.plus22.Resources`](#org.cdk8s.plus22.Resources)

Compute resources (CPU and memory requests and limits) required by the container.

> https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
---

##### `startup`<sup>Optional</sup> <a name="org.cdk8s.plus22.ContainerProps.parameter.startup"></a>

- *Type:* [`org.cdk8s.plus22.Probe`](#org.cdk8s.plus22.Probe)
Expand Down Expand Up @@ -5640,6 +5771,20 @@ The port this container exposes.

---

##### `resources`<sup>Optional</sup> <a name="org.cdk8s.plus22.Container.property.resources"></a>

```java
public Resources getResources();
```

- *Type:* [`org.cdk8s.plus22.Resources`](#org.cdk8s.plus22.Resources)

Compute resources (CPU and memory requests and limits) required by the container.

> https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
---

##### `workingDir`<sup>Optional</sup> <a name="org.cdk8s.plus22.Container.property.workingDir"></a>

```java
Expand All @@ -5653,6 +5798,56 @@ The working directory inside the container.
---


### Cpu <a name="org.cdk8s.plus22.Cpu"></a>

Represents the amount of CPU.

The amount can be passed as millis or units.


#### Static Functions <a name="Static Functions"></a>

##### `millis` <a name="org.cdk8s.plus22.Cpu.millis"></a>

```java
import org.cdk8s.plus22.Cpu;

Cpu.millis(java.lang.Number amount)
```

###### `amount`<sup>Required</sup> <a name="org.cdk8s.plus22.Cpu.parameter.amount"></a>

- *Type:* `java.lang.Number`

---

##### `units` <a name="org.cdk8s.plus22.Cpu.units"></a>

```java
import org.cdk8s.plus22.Cpu;

Cpu.units(java.lang.Number amount)
```

###### `amount`<sup>Required</sup> <a name="org.cdk8s.plus22.Cpu.parameter.amount"></a>

- *Type:* `java.lang.Number`

---

#### Properties <a name="Properties"></a>

##### `amount`<sup>Required</sup> <a name="org.cdk8s.plus22.Cpu.property.amount"></a>

```java
public java.lang.String getAmount();
```

- *Type:* `java.lang.String`

---


### EnvValue <a name="org.cdk8s.plus22.EnvValue"></a>

Utility class for creating reading env values from various sources.
Expand Down

0 comments on commit 34621b1

Please sign in to comment.