Skip to content
This repository was archived by the owner on May 28, 2021. It is now read-only.

Commit 94b77d7

Browse files
committed
Add option init container
1 parent c98210b commit 94b77d7

File tree

4 files changed

+44
-0
lines changed

4 files changed

+44
-0
lines changed

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
},

0 commit comments

Comments
 (0)