first commit
This commit is contained in:
22
autoscaling/components/application/app.go
Normal file
22
autoscaling/components/application/app.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
func main(){
|
||||
http.HandleFunc("/", useCPU)
|
||||
http.ListenAndServe(":80", nil)
|
||||
}
|
||||
|
||||
func useCPU(w http.ResponseWriter, r *http.Request) {
|
||||
count := 1
|
||||
|
||||
for i := 1; i <= 1000000; i++ {
|
||||
count = i
|
||||
}
|
||||
|
||||
fmt.Printf("count: %d", count)
|
||||
w.Write([]byte(string(count)))
|
||||
}
|
||||
50
autoscaling/components/application/deployment.yaml
Normal file
50
autoscaling/components/application/deployment.yaml
Normal file
@@ -0,0 +1,50 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: application-cpu
|
||||
labels:
|
||||
app: application-cpu
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: application-cpu
|
||||
ports:
|
||||
- protocol: TCP
|
||||
name: http
|
||||
port: 80
|
||||
targetPort: 80
|
||||
---
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: application-cpu
|
||||
labels:
|
||||
app: application-cpu
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: application-cpu
|
||||
replicas: 1
|
||||
strategy:
|
||||
type: RollingUpdate
|
||||
rollingUpdate:
|
||||
maxSurge: 1
|
||||
maxUnavailable: 0
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: application-cpu
|
||||
spec:
|
||||
containers:
|
||||
- name: application-cpu
|
||||
image: aimvector/application-cpu:v1.0.2
|
||||
imagePullPolicy: Always
|
||||
ports:
|
||||
- containerPort: 80
|
||||
resources:
|
||||
requests:
|
||||
memory: "50Mi"
|
||||
cpu: "500m"
|
||||
limits:
|
||||
memory: "500Mi"
|
||||
cpu: "2000m"
|
||||
15
autoscaling/components/application/dockerfile
Normal file
15
autoscaling/components/application/dockerfile
Normal file
@@ -0,0 +1,15 @@
|
||||
FROM golang:1.14-alpine as build
|
||||
|
||||
RUN apk add --no-cache git curl
|
||||
|
||||
WORKDIR /src
|
||||
|
||||
COPY app.go /src
|
||||
|
||||
RUN go build app.go
|
||||
|
||||
FROM alpine as runtime
|
||||
|
||||
COPY --from=build /src/app /app/app
|
||||
|
||||
CMD [ "/app/app" ]
|
||||
11
autoscaling/components/application/traffic-generator.yaml
Normal file
11
autoscaling/components/application/traffic-generator.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: traffic-generator
|
||||
spec:
|
||||
containers:
|
||||
- name: alpine
|
||||
image: alpine
|
||||
args:
|
||||
- sleep
|
||||
- "100000000"
|
||||
Reference in New Issue
Block a user