-
Notifications
You must be signed in to change notification settings - Fork 4
/
cpu-api-template.yaml
104 lines (104 loc) · 2.64 KB
/
cpu-api-template.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: cpu-api
namespace: default
annotations:
app: 'cpu-api'
spec:
replicas: 2
selector:
matchLabels:
app: cpu-api
template:
metadata:
labels:
app: cpu-api
spec:
containers:
- name: cpu-api
image: <account-id>.dkr.ecr.<region>.amazonaws.com/cpu-api:latest
imagePullPolicy: Always
ports:
- containerPort: 8000
resources:
requests:
cpu: 1
memory: "1024Mi"
limits:
cpu: 1
memory: "1024Mi"
env:
- name: env
value: "dev"
---
apiVersion: v1
kind: Service
metadata:
name: cpu-api
annotations:
app: 'cpu-api'
alb.ingress.kubernetes.io/healthcheck-path: "/ping"
spec:
selector:
app: cpu-api
type: NodePort
ports:
- port: 8000
targetPort: 8000
protocol: TCP
---
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
name: 'cpu-api-hpa'
namespace: default
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: 'cpu-api'
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 50
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: "cpu-api-ingress"
namespace: default
annotations:
app: 'cpu-api'
kubernetes.io/ingress.class: alb
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/target-type: ip
alb.ingress.kubernetes.io/load-balancer-name: cpu-api
alb.ingress.kubernetes.io/load-balancer-attributes: idle_timeout.timeout_seconds=30
alb.ingress.kubernetes.io/target-group-attributes: deregistration_delay.timeout_seconds=10
alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}]'
# alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS":443}]'
# alb.ingress.kubernetes.io/certificate-arn: arn:aws:acm:<region>:<account-id>:certificate/<certificate-id>
# alb.ingress.kubernetes.io/ssl-redirect: '443'
alb.ingress.kubernetes.io/tags: env=dev
alb.ingress.kubernetes.io/healthcheck-interval-seconds: '16'
alb.ingress.kubernetes.io/healthcheck-timeout-seconds: '15'
alb.ingress.kubernetes.io/healthy-threshold-count: '2'
alb.ingress.kubernetes.io/unhealthy-threshold-count: '5'
spec:
rules:
- http:
paths:
- path: /*
pathType: ImplementationSpecific
backend:
service:
name: "cpu-api"
port:
number: 8000