Skip to content

Commit b2743e2

Browse files
committed
Put initContainers to PodSpec for some statefulset examples.
1 parent 02755dd commit b2743e2

File tree

1 file changed

+26
-39
lines changed

1 file changed

+26
-39
lines changed

cockroachdb/cockroachdb-statefulset.yaml

+26-39
Original file line numberDiff line numberDiff line change
@@ -77,46 +77,33 @@ spec:
7777
metadata:
7878
labels:
7979
app: cockroachdb
80-
annotations:
81-
# Init containers are run only once in the lifetime of a pod, before
82-
# it's started up for the first time. It has to exit successfully
83-
# before the pod's main containers are allowed to start.
84-
# This particular init container does a DNS lookup for other pods in
85-
# the set to help determine whether or not a cluster already exists.
86-
# If any other pods exist, it creates a file in the cockroach-data
87-
# directory to pass that information along to the primary container that
88-
# has to decide what command-line flags to use when starting CockroachDB.
89-
# This only matters when a pod's persistent volume is empty - if it has
90-
# data from a previous execution, that data will always be used.
91-
pod.alpha.kubernetes.io/init-containers: '[
92-
{
93-
"name": "bootstrap",
94-
"image": "cockroachdb/cockroach-k8s-init:0.1",
95-
"imagePullPolicy": "IfNotPresent",
96-
"args": [
97-
"-on-start=/on-start.sh",
98-
"-service=cockroachdb"
99-
],
100-
"env": [
101-
{
102-
"name": "POD_NAMESPACE",
103-
"valueFrom": {
104-
"fieldRef": {
105-
"apiVersion": "v1",
106-
"fieldPath": "metadata.namespace"
107-
}
108-
}
109-
}
110-
],
111-
"volumeMounts": [
112-
{
113-
"name": "datadir",
114-
"mountPath": "/cockroach/cockroach-data"
115-
}
116-
]
117-
}
118-
]'
11980
spec:
81+
# Init containers are run only once in the lifetime of a pod, before
82+
# it's started up for the first time. It has to exit successfully
83+
# before the pod's main containers are allowed to start.
84+
# This particular init container does a DNS lookup for other pods in
85+
# the set to help determine whether or not a cluster already exists.
86+
# If any other pods exist, it creates a file in the cockroach-data
87+
# directory to pass that information along to the primary container that
88+
# has to decide what command-line flags to use when starting CockroachDB.
89+
# This only matters when a pod's persistent volume is empty - if it has
90+
# data from a previous execution, that data will always be used.
91+
initContainers:
92+
- name: bootstrap
93+
image: cockroachdb/cockroach-k8s-init:0.1
94+
imagePullPolicy: IfNotPresent
95+
args:
96+
- "-on-start=/on-start.sh"
97+
- "-service=cockroachdb"
98+
env:
99+
- name: POD_NAMESPACE
100+
valueFrom:
101+
fieldRef:
102+
apiVersion: v1
103+
fieldPath: metadata.namespace
104+
volumeMounts:
105+
- name: datadir
106+
mountPath: "/cockroach/cockroach-data"
120107
affinity:
121108
podAntiAffinity:
122109
preferredDuringSchedulingIgnoredDuringExecution:

0 commit comments

Comments
 (0)