-
Notifications
You must be signed in to change notification settings - Fork 3
/
singleton-service.yml
65 lines (65 loc) · 1.76 KB
/
singleton-service.yml
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
---
apiVersion: v1
kind: Service
metadata:
name: my-service
spec:
clusterIP: ""
ports:
- name: my-port
port: 1024
protocol: TCP
# NOTE: No selector here! A selector would automatically add all matching and ready pods to the endpoint
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-server-with-replicas
spec:
replicas: 5
selector:
matchLabels:
app: my-server
template:
metadata:
labels:
app: my-server
spec:
containers:
- name: my-server
image: my-server
args:
- my-singleton-server
ports:
- containerPort: 1024
name: my-port
env:
- name: K8S_AWAIT_ELECTION_ENABLED
value: "1"
- name: K8S_AWAIT_ELECTION_NAME
value: my-server
- name: K8S_AWAIT_ELECTION_LOCK_NAME
value: my-server
- name: K8S_AWAIT_ELECTION_LOCK_NAMESPACE
value: default
- name: K8S_AWAIT_ELECTION_IDENTITY
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: K8S_AWAIT_ELECTION_STATUS_ENDPOINT
value: :9999
- name: K8S_AWAIT_ELECTION_SERVICE_NAME
value: my-service
- name: K8S_AWAIT_ELECTION_SERVICE_NAMESPACE
value: default
- name: K8S_AWAIT_ELECTION_SERVICE_PORTS_JSON
value: '[{"name":"my-port","port":1024}]'
- name: K8S_AWAIT_ELECTION_POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: K8S_AWAIT_ELECTION_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
---