-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⚡ Update devcontainer & WIP on Startup CPU Boost
- Loading branch information
Showing
9 changed files
with
178 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
# syntax=docker/dockerfile:1 | ||
FROM mcr.microsoft.com/devcontainers/base:ubuntu | ||
|
||
## Install Taskfile | ||
## Install Tools | ||
RUN <<EOF | ||
set -e | ||
|
||
# Install Taskfile | ||
sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d | ||
|
||
# Install kubecolor | ||
mkdir -p /tmp/kubecolor | ||
wget https://github.com/kubecolor/kubecolor/releases/download/v0.5.0/kubecolor_0.5.0_linux_amd64.tar.gz -O /tmp/kubecolor/kubecolor.tar.gz | ||
tar -xvzf /tmp/kubecolor/kubecolor.tar.gz -C /tmp/kubecolor | ||
mv /tmp/kubecolor/kubecolor /usr/bin/local | ||
rm -Rf /tmp/kubecolor | ||
EOF |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# [In-Place Resource Resize - v1.27 [alpha]][in-place-resource-resize-blog] | ||
|
||
## Késako ? | ||
|
||
In-place resize allows operators to **dynamically modify** the CPU and memory resources of a **running pod** **without causing scheduling interruptions or downtime during the resizing process**. **This therefore allows a `kubectl patch ...` to be made on the `resources` of a deployment** | ||
|
||
Instead of manually patching (`kubectl patch ...`), we can use the Kubernetes operator [Kube Startup CPU Boost | ||
][kube-startup-cpu-boost-gh]. | ||
|
||
**Kube Startup CPU Boost** is a controller that increases CPU resource requests and limits during Kubernetes workload startup time. Once the workload is up and running, the resources are set back to their original values. | ||
|
||
![Kube Startup CPU Boost](../images/kube-startup-cpu-boost.png) | ||
|
||
## Install *Kube Startup CPU Boost* | ||
|
||
```bash | ||
task kube-startup-cpu-boost-install | ||
``` | ||
|
||
## Test with Java Application | ||
|
||
Java applications often require varying resources at different stages. During startup, the JVM typically demands more resources due to the heavy compute load involved in initial class loading and optimization. Once the application is running, resource requirements generally decrease. Since the JVM utilizes multi-threading, providing additional CPU resources can significantly speed up startup times. | ||
|
||
### Without *Kube Startup CPU Boost* | ||
|
||
```bash | ||
kubectl apply -f discovery/in-place-resource-resize-1.27-alpha/spring-demo.deploy.yml | ||
|
||
## Show Logs | ||
kubectl logs deploy/spring-demo-app | grep "Started DemoApplication" | ||
### ... Started DemoApplication in 90.322 seconds (process running for 100.79) | ||
``` | ||
|
||
### *Kube Startup CPU Boost* in Action | ||
|
||
```bash | ||
kubectl delete -f discovery/in-place-resource-resize-1.27-alpha/spring-demo.deploy.yml | ||
|
||
## Deploy Startup CPU Boost | ||
## Increase container CPU requests and limits by 100% (to 2 cores) until the Pod reaches Ready condition. | ||
kubectl apply -f discovery/in-place-resource-resize-1.27-alpha/startup-cpu-boost.yml | ||
|
||
kubectl apply -f discovery/in-place-resource-resize-1.27-alpha/spring-demo.deploy.yml | ||
|
||
## Show Logs | ||
kubectl logs deploy/spring-demo-app | grep "Started DemoApplication" | ||
### ... Started DemoApplication in 39.925 seconds (process running for 100.79) | ||
``` | ||
|
||
## Resources | ||
|
||
- [Faster startup times for Kubernetes workloads with Kube Startup CPU Boost][understanding-kubernetes-dynamic-resource-scaling-and-cpu-boost] | ||
- [Warm up the relationship between Java and Kubernetes][understanding-kubernetes-dynamic-resource-scaling-and-cpu-boost] | ||
|
||
<!-- Links --> | ||
[in-place-resource-resize-blog]: https://kubernetes.io/blog/2023/05/12/in-place-pod-resize-alpha/ | ||
[understanding-kubernetes-dynamic-resource-scaling-and-cpu-boost]: https://cloud.google.com/blog/products/containers-kubernetes/understanding-kubernetes-dynamic-resource-scaling-and-cpu-boost?hl=en | ||
[kube-startup-cpu-boost-gh]: https://github.com/google/kube-startup-cpu-boost |
78 changes: 78 additions & 0 deletions
78
discovery/in-place-resource-resize-1.27-alpha/spring-demo.deploy.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: spring-demo-app | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app.kubernetes.io/name: spring-demo-app | ||
template: | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: spring-demo-app | ||
spec: | ||
containers: | ||
- name: spring-demo-app | ||
image: ghcr.io/google/spring-demo-app:latest | ||
args: | ||
- --spring.config.location=file:/config/application.yaml | ||
env: | ||
- name: JAVA_OPTS | ||
value: -XX:MaxRAMPercentage=75 | ||
volumeMounts: | ||
- name: spring-demo-app-config | ||
mountPath: /config | ||
ports: | ||
- name: http | ||
containerPort: 8080 | ||
startupProbe: | ||
periodSeconds: 2 | ||
failureThreshold: 60 | ||
httpGet: | ||
path: /actuator/health | ||
port: http | ||
scheme: HTTP | ||
livenessProbe: | ||
httpGet: | ||
path: /actuator/health | ||
port: http | ||
scheme: HTTP | ||
resources: | ||
limits: | ||
cpu: "1" | ||
memory: 512Mi | ||
requests: | ||
cpu: 500m | ||
memory: 512Mi | ||
volumes: | ||
- name: spring-demo-app-config | ||
configMap: | ||
name: spring-demo-app-config | ||
|
||
--- | ||
|
||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: spring-demo-app-config | ||
data: | ||
application.yaml: | | ||
spring: | ||
datasource: | ||
url: jdbc:h2:mem:mydb | ||
username: sa | ||
password: password | ||
driverClassName: org.h2.Driver | ||
jpa: | ||
hibernate: | ||
ddl-auto: create | ||
database-platform: org.hibernate.dialect.H2Dialect | ||
defer-datasource-initialization: true | ||
management: | ||
endpoints: | ||
web: | ||
exposure: | ||
include: | ||
- health | ||
- prometheus |
20 changes: 20 additions & 0 deletions
20
discovery/in-place-resource-resize-1.27-alpha/startup-cpu-boost.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
apiVersion: autoscaling.x-k8s.io/v1alpha1 | ||
kind: StartupCPUBoost | ||
metadata: | ||
name: boost-001 | ||
selector: | ||
matchExpressions: | ||
- key: app.kubernetes.io/name | ||
operator: In | ||
values: ["spring-demo-app"] | ||
spec: | ||
resourcePolicy: | ||
containerPolicies: | ||
- containerName: spring-demo-app | ||
fixedResources: | ||
requests: "1" | ||
limits: "2" | ||
durationPolicy: | ||
fixedDuration: | ||
unit: Seconds | ||
value: 120 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters