This repository was archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathservicestateful.yaml
More file actions
72 lines (72 loc) · 2.53 KB
/
servicestateful.yaml
File metadata and controls
72 lines (72 loc) · 2.53 KB
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
# For the full spec setting and usage, see ./pkg/apis/frameworkcontroller/v1/types.go
apiVersion: frameworkcontroller.microsoft.com/v1
kind: Framework
metadata:
name: servicestateful
spec:
executionType: Start
retryPolicy:
fancyRetryPolicy: false
maxRetryCount: -2
taskRoles:
- name: serverstateful
taskNumber: 3
frameworkAttemptCompletionPolicy:
minFailedTaskCount: 1
minSucceededTaskCount: -1
task:
retryPolicy:
fancyRetryPolicy: false
maxRetryCount: -2
# Never force delete Pod as it may break the stateful service.
podGracefulDeletionTimeoutSec: null
pod:
spec:
# By leveraging below Headless Service, the Pod can be discovered by its DNS FQDN:
# {FC_TASKROLE_NAME}-{FC_TASK_INDEX}.{FC_FRAMEWORK_NAME}.{FC_FRAMEWORK_NAMESPACE}.svc.cluster.local
hostname: "{{FC_TASKROLE_NAME}}-{{FC_TASK_INDEX}}"
subdomain: "{{FC_FRAMEWORK_NAME}}"
# Using Never restartPolicy, ActiveDeadlineSeconds and initContainers
# just to demonstrate consistent identities in this example.
restartPolicy: Never
ActiveDeadlineSeconds: 60
containers:
- name: nginx
image: nginx:stable
ports:
- containerPort: 80
initContainers:
- name: ubuntu
image: ubuntu:trusty
# See comments in batchstatefulfailed.yaml
command: [
"sh", "-c",
"printenv &&
getent ahosts &&
echo Local DNS FQDN Resolved: $(hostname -f) &&
PEER_FQDN=${FC_TASKROLE_NAME}-$((2-${FC_TASK_INDEX})).${FC_FRAMEWORK_NAME}.${FC_FRAMEWORK_NAMESPACE}.svc.cluster.local &&
until getent ahosts ${PEER_FQDN};
do echo Waiting Peer DNS FQDN Resolved: ${PEER_FQDN}; sleep 3;
done;
echo Peer DNS FQDN Resolved: ${PEER_FQDN}"]
---
# Post to {kubeApiServerAddress}/api/v1/namespaces/default/services/
# It is a Headless Service which does not create a load-balancer, but still
# creates DNS records for each Pod of above Framework, so that they can resolve
# each other's IP.
apiVersion: v1
kind: Service
metadata:
name: servicestateful
spec:
# Headless Service
clusterIP: None
# Create DNS records regardless of Pod readiness, to simply peer discovery.
publishNotReadyAddresses: true
selector:
# See comments in service.yaml
FC_FRAMEWORK_NAME: servicestateful
FC_TASKROLE_NAME: serverstateful
ports:
- targetPort: 80
port: 30180