Skip to content

Commit

Permalink
feat: inject envs from config
Browse files Browse the repository at this point in the history
  • Loading branch information
maxsxu committed Feb 15, 2022
1 parent 69fc89a commit a6ecb99
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions controllers/zookeepercluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ func (r *ZookeeperClusterReconciler) createHeadlessService(zk *zookeeperv1alpha1
}

func (r *ZookeeperClusterReconciler) createStatefulSet(zk *zookeeperv1alpha1.ZookeeperCluster) *appsv1.StatefulSet {
podEnvs := []corev1.EnvVar{}
for k, v := range zk.Spec.Config {
podEnvs = append(podEnvs, corev1.EnvVar{
Name: k,
Value: fmt.Sprintf("%d", v),
})
}

return &appsv1.StatefulSet{
ObjectMeta: metav1.ObjectMeta{
Name: zk.Name,
Expand All @@ -218,15 +226,10 @@ func (r *ZookeeperClusterReconciler) createStatefulSet(zk *zookeeperv1alpha1.Zoo
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: "zookeeper",
Name: zk.Name,
Image: "zookeeper:latest",
Ports: nil,
Env: []corev1.EnvVar{
{
Name: "ZOO_ENV",
Value: "10",
},
},
Env: podEnvs,
},
},
},
Expand Down

0 comments on commit a6ecb99

Please sign in to comment.