Skip to content
This repository was archived by the owner on May 28, 2021. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 55c0f09

Browse files
committedDec 14, 2018
Add option init container
Signed-off-by: Alan Tang <[email protected]>
1 parent c98210b commit 55c0f09

File tree

5 files changed

+46
-1
lines changed

5 files changed

+46
-1
lines changed
 

‎Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ ifdef WERCKER
1717
VERSION ?= ${WERCKER_GIT_COMMIT}
1818
TENANT := "oracle"
1919
else
20-
VERSION ?= ${USER}-$(shell git describe --always --dirty)
20+
# VERSION ?= ${USER}-$(shell git describe --always --dirty)
21+
VERSION ?= "0.3.0"
2122
TENANT ?= "spinnaker"
2223
endif
2324

‎docs/user/clusters.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,30 @@ spec:
5050
name: mysql-root-user-secret
5151
```
5252
53+
### Create a cluster with initContainers
54+
55+
The following example will create a MySQL Cluster with a containers.
56+
Format same as Kubernetes container.
57+
```yaml
58+
apiVersion: mysql.oracle.com/v1alpha1
59+
kind: Cluster
60+
metadata:
61+
name: mysql-cluster-with-init-container
62+
spec:
63+
members: 1
64+
initContainers:
65+
- name: sleep
66+
image: busybox
67+
command:
68+
- echo
69+
- "This is first init container"
70+
- name: sleep
71+
image: busybox
72+
command:
73+
- echo
74+
- "This is second init container"
75+
```
76+
5377
### Create a cluster with a persistent volume
5478
5579
The following example will create a MySQL Cluster with a persistent local volume.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
apiVersion: mysql.oracle.com/v1alpha1
2+
kind: Cluster
3+
metadata:
4+
name: mysql
5+
spec:
6+
members: 1
7+
initContainers:
8+
- name: sleep
9+
image: busybox
10+
command:
11+
- echo
12+
- "This is first init container"
13+
- name: sleep
14+
image: busybox
15+
command:
16+
- echo
17+
- "This is second init container"

‎pkg/apis/mysql/v1alpha1/types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ type ClusterSpec struct {
7676
Tolerations *[]corev1.Toleration `json:"tolerations,omitempty"`
7777
// Resources holds ResourceRequirements for the MySQL Agent & Server Containers
7878
Resources *Resources `json:"resources,omitempty"`
79+
// Init containers
80+
InitContainers []corev1.Container `json:"initContainers,omitempty"`
7981
}
8082

8183
// ClusterConditionType represents a valid condition of a Cluster.

‎pkg/resources/statefulsets/statefulset.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ func NewForCluster(cluster *v1alpha1.Cluster, images operatoropts.Images, servic
388388
ServiceAccountName: "mysql-agent",
389389
NodeSelector: cluster.Spec.NodeSelector,
390390
Affinity: cluster.Spec.Affinity,
391+
InitContainers: cluster.Spec.InitContainers,
391392
Containers: containers,
392393
Volumes: podVolumes,
393394
},

1 commit comments

Comments
 (1)

jonesmith518 commented on Nov 1, 2019

@jonesmith518

thanks for the idea and wish to be added in the nex release~
i'm facing the same problem, when mysql cannot start due to :
[ERROR] [MY-011735] [Repl] Plugin group_replication reported: '[GCS] Unable to translate hostname mysql-cluster-0.mysql-cluster to IP address!'
with init container, it's getting started when vm is shutting down accidently

This repository has been archived.