Skip to content

Commit ca6de09

Browse files
authored
Merge pull request #81 from antoniasymeonidou/master
Change Cpu Defaults
2 parents acf2191 + 232a151 commit ca6de09

File tree

4 files changed

+6
-81
lines changed

4 files changed

+6
-81
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ kubeyml:gen
4646
| command | Command for the container | empty |
4747
| args | arguments for the command | empty Seq |
4848
| envs | Map of environment variables, raw, field path or secret are supported| empty |
49-
| resourceRequests | Resource requests (cpu in the form of m, memory in the form of MiB | `Resource(Cpu(500), Memory(256))` |
49+
| resourceRequests | Resource requests (cpu in the form of m, memory in the form of MiB | `Resource(Cpu(100), Memory(256))` |
5050
| resourceLimits | Resource limits (cpu in the form of m, memory in the form of MiB | `Resource(Cpu(1000), Memory(512))` |
5151
| target | The directory to output the deployment.yml | target of this project |
5252
| deployment | The key to access the whole Deployment definition, exposed for further customisation | Instance with above defaults |

site/docs/deployment/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ spec:
7777
periodSeconds: 10
7878
resources:
7979
requests:
80-
cpu: 500m
80+
cpu: 100m
8181
memory: 256Mi
8282
limits:
8383
cpu: 1000m

src/main/scala/kubeyml/deployment/Protocol.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ case class Container(
220220
}
221221

222222
case class Resources(
223-
requests: Resource = Resource(Cpu(500), Memory(256)),
223+
requests: Resource = Resource(Cpu(100), Memory(256)),
224224
limits: Resource = Resource(Cpu(1000), Memory(512))
225225
) {
226226
require(requests.cpu.value <= limits.cpu.value)

src/test/scala/kubeyml/deployment/KubernetesStateYamlSpec.scala

+3-78
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class KubernetesStateYamlSpec extends AnyFlatSpec with Matchers with ScalaCheckP
126126
| resources:
127127
| requests:
128128
| memory: "256Mi"
129-
| cpu: "500m"
129+
| cpu: "100m"
130130
| limits:
131131
| memory: "512Mi"
132132
| cpu: "1000m"
@@ -204,7 +204,7 @@ class KubernetesStateYamlSpec extends AnyFlatSpec with Matchers with ScalaCheckP
204204
| resources:
205205
| requests:
206206
| memory: "256Mi"
207-
| cpu: "500m"
207+
| cpu: "100m"
208208
| limits:
209209
| memory: "512Mi"
210210
| cpu: "1000m"
@@ -280,7 +280,7 @@ class KubernetesStateYamlSpec extends AnyFlatSpec with Matchers with ScalaCheckP
280280
| resources:
281281
| requests:
282282
| memory: "256Mi"
283-
| cpu: "500m"
283+
| cpu: "100m"
284284
| limits:
285285
| memory: "512Mi"
286286
| cpu: "1000m"
@@ -295,81 +295,6 @@ class KubernetesStateYamlSpec extends AnyFlatSpec with Matchers with ScalaCheckP
295295
}
296296
}
297297

298-
"kubernetes sample" must "be generated from definition" in {
299-
300-
forAll(lowEmptyChance) { deploymentTestParts: DeploymentTestParts =>
301-
import deploymentTestParts._
302-
whenever(nonEmptyParts(deploymentTestParts)) {
303-
val deployment = deploy
304-
.namespace(namespace)
305-
.service(serviceName)
306-
.withImage(dockerImage)
307-
.withProbes(
308-
livenessProbe = HttpProbe(HttpGet("/health", 8080, List.empty), initialDelay = 3 seconds, period = 5 seconds),
309-
readinessProbe = NoProbe
310-
)
311-
.replicas(1)
312-
.addPorts(List(Port(Some("app"), 8080)))
313-
.annotateSpecTemplate(Map(metadataKey -> metadataValue))
314-
.env(envName, envValue)
315-
316-
val expectedYaml = parse(s"""
317-
|apiVersion: apps/v1
318-
|kind: Deployment
319-
|metadata:
320-
| name: &name "${serviceName}"
321-
| namespace: "${namespace}"
322-
|spec:
323-
| replicas: 1
324-
| selector:
325-
| matchLabels:
326-
| app: *name
327-
| strategy:
328-
| type: RollingUpdate
329-
| rollingUpdate:
330-
| maxSurge: 0
331-
| maxUnavailable: 1
332-
| template:
333-
| metadata:
334-
| labels:
335-
| app: *name
336-
| annotations:
337-
| ${metadataKey}: "${metadataValue}"
338-
| spec:
339-
| containers:
340-
| - image: "${dockerImage}"
341-
| imagePullPolicy: IfNotPresent
342-
| name: *name
343-
| ports:
344-
| - name: app
345-
| containerPort: 8080
346-
| livenessProbe:
347-
| httpGet:
348-
| path: /health
349-
| port: 8080
350-
| initialDelaySeconds: 3
351-
| periodSeconds : 5
352-
| successThreshold: 1
353-
| failureThreshold: 3
354-
| timeoutSeconds: 1
355-
| resources:
356-
| requests:
357-
| memory: "256Mi"
358-
| cpu: "500m"
359-
| limits:
360-
| memory: "512Mi"
361-
| cpu: "1000m"
362-
| env:
363-
| - name: "${envName}"
364-
| value: "${envValue}"
365-
|""".stripMargin)
366-
val actualJson = Right(deployment.asJson)
367-
368-
actualJson shouldBe expectedYaml
369-
}
370-
}
371-
}
372-
373298
"cpu and memory" must "be encoded as strings with m and MiB indicators" in {
374299
Cpu(500).asJson shouldBe "500m".asJson
375300
Memory(128).asJson shouldBe "128Mi".asJson

0 commit comments

Comments
 (0)