/
deployment-and-service.yaml
98 lines (86 loc) · 2.42 KB
/
deployment-and-service.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
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: spring-boot-with-docker-push
# allow for ns override: kubectl -n <ns> apply ...
#namespace: default
spec:
selector:
matchLabels:
app: spring-boot-with-docker-push
replicas: 1
template:
metadata:
labels:
app: spring-boot-with-docker-push
annotations:
sidecar.istio.io/inject: "false"
spec:
containers:
- name: spring-boot-with-docker-push
image: fabianlee/springbootwithdockerpush:<%=version%>
imagePullPolicy: Always
# resource limits
resources:
requests:
memory: "2048Mi"
cpu: "1000m" # one vcpu
limits:
memory: "4096Mi"
cpu: "2000m" # two vcpu
env:
# override 'dev' default profile in application.properties
#- name: spring.profiles.active
# value: prod
# pulling pod fields using Downward API
- name: K8S_node_name
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: K8S_namespace
valueFrom:
fieldRef:
fieldPath: metadata.namespace
# default message
- name: JAVA_MSG
value: "I wuz here"
# check for lifetime liveness, restarts if dead
livenessProbe:
httpGet:
path: /actuator/health
port: 8081
initialDelaySeconds: 20
periodSeconds: 10
# check for initial readiness
readinessProbe:
httpGet:
path: /actuator/health
port: 8081
initialDelaySeconds: 20
periodSeconds: 10
restartPolicy: Always
---
apiVersion: v1
kind: Service
metadata:
name: spring-boot-with-docker-push
#namespace: default
labels:
app: spring-boot-with-docker-push
annotations:
# set to true if you want our custom prometheus scraper job to gather custom metrics
prometheus.io/path: /actuator/prometheus
prometheus.io/scrape: "false"
spec:
ports:
- port: 8080 # available at this service
name: http
targetPort: 8080 # exposed from inside container
protocol: TCP
- port: 8081 # available at this service
name: http-actuator-metrics # ends with 'metrics' in case we want custom scraper to recognize
targetPort: 8081 # exposed from inside container
protocol: TCP
selector:
app: spring-boot-with-docker-push