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

Add option init-container #245

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions docs/user/clusters.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,30 @@ spec:
name: mysql-root-user-secret
```

### Create a cluster with initContainers

The following example will create a MySQL Cluster with a containers.
Format same as Kubernetes container.
```yaml
apiVersion: mysql.oracle.com/v1alpha1
kind: Cluster
metadata:
name: mysql-cluster-with-init-container
spec:
members: 1
initContainers:
- name: sleep
image: busybox
command:
- echo
- "This is first init container"
- name: sleep
image: busybox
command:
- echo
- "This is second init container"
```

### Create a cluster with a persistent volume

The following example will create a MySQL Cluster with a persistent local volume.
Expand Down
17 changes: 17 additions & 0 deletions examples/cluster/cluster-with-init-container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: mysql.oracle.com/v1alpha1
kind: Cluster
metadata:
name: mysql
spec:
members: 1
initContainers:
- name: sleep
image: busybox
command:
- echo
- "This is first init container"
- name: sleep
image: busybox
command:
- echo
- "This is second init container"
2 changes: 2 additions & 0 deletions pkg/apis/mysql/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ type ClusterSpec struct {
Tolerations *[]corev1.Toleration `json:"tolerations,omitempty"`
// Resources holds ResourceRequirements for the MySQL Agent & Server Containers
Resources *Resources `json:"resources,omitempty"`
// Init containers
InitContainers []corev1.Container `json:"initContainers,omitempty"`
}

// ClusterConditionType represents a valid condition of a Cluster.
Expand Down
1 change: 1 addition & 0 deletions pkg/resources/statefulsets/statefulset.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ func NewForCluster(cluster *v1alpha1.Cluster, images operatoropts.Images, servic
ServiceAccountName: "mysql-agent",
NodeSelector: cluster.Spec.NodeSelector,
Affinity: cluster.Spec.Affinity,
InitContainers: cluster.Spec.InitContainers,
Containers: containers,
Volumes: podVolumes,
},
Expand Down