From 486d5fcc038b5fab6a880966b6939793f0d305bf Mon Sep 17 00:00:00 2001 From: xyphr Date: Sun, 28 Apr 2019 20:15:23 +0530 Subject: [PATCH 1/2] Replaced daemonset with initContainers --- cmd/operator/main.go | 2 +- pkg/k8sutil/deployments.go | 10 ++++++++++ pkg/k8sutil/k8sutil.go | 13 ++++++++++++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/cmd/operator/main.go b/cmd/operator/main.go index b2f4cd809..dd85b05a3 100644 --- a/cmd/operator/main.go +++ b/cmd/operator/main.go @@ -61,7 +61,7 @@ func init() { flag.StringVar(&baseImage, "baseImage", "upmcenterprises/docker-elasticsearch-kubernetes:6.1.3_0", "Base image to use when spinning up the elasticsearch components.") flag.StringVar(&kubeCfgFile, "kubecfg-file", "", "Location of kubecfg file for access to kubernetes master service; --kube_master_url overrides the URL part of this; if neither this nor --kube_master_url are provided, defaults to service account tokens") flag.StringVar(&masterHost, "masterhost", "http://127.0.0.1:8001", "Full url to k8s api server") - flag.BoolVar(&enableInitDaemonset, "enableInitDaemonset", true, "Set to false to disable the sysctl init daemonset") + flag.BoolVar(&enableInitDaemonset, "enableInitDaemonset", false, "Set to false to disable the sysctl init daemonset") flag.StringVar(&initDaemonsetNamespace, "initDaemonsetNamespace", "default", "Namespace to deploy the sysctl init daemonset into") flag.StringVar(&busyboxImage, "busybox-image", "busybox:1.26.2", "Image to use for sysctl init daemonset") flag.Parse() diff --git a/pkg/k8sutil/deployments.go b/pkg/k8sutil/deployments.go index c5bcc9557..2b208d0a4 100644 --- a/pkg/k8sutil/deployments.go +++ b/pkg/k8sutil/deployments.go @@ -174,6 +174,16 @@ func (k *K8sutil) CreateClientDeployment(baseImage string, replicas *int32, java Containers: []v1.Container{ v1.Container{ Name: deploymentName, + InitContainers: []v1.Container{ + { + Name: "sysctl", + Image: "busybox", + Command: []string{ "sysctl", "-w", "vm.max_map_count=262144"}, + SecurityContext: &v1.SecurityContext{ + Privileged: &[]bool{true}[0], + }, + }, + }, SecurityContext: &v1.SecurityContext{ Privileged: &[]bool{true}[0], Capabilities: &v1.Capabilities{ diff --git a/pkg/k8sutil/k8sutil.go b/pkg/k8sutil/k8sutil.go index c1870d6ab..f2b66ad5a 100644 --- a/pkg/k8sutil/k8sutil.go +++ b/pkg/k8sutil/k8sutil.go @@ -506,7 +506,18 @@ func buildStatefulSet(statefulSetName, clusterName, deploymentType, baseImage, s }, }, }, - }}, + }, + }, + InitContainers: []v1.Container{ + { + Name: "sysctl", + Image: "busybox", + Command: []string{ "sysctl", "-w", "vm.max_map_count=262144"}, + SecurityContext: &v1.SecurityContext{ + Privileged: &[]bool{true}[0], + }, + }, + }, Containers: []v1.Container{ v1.Container{ Name: statefulSetName, From 078f6d6fafcbd57f82ed5d3788b5bc2ac11c4071 Mon Sep 17 00:00:00 2001 From: Abhisek Mishra Date: Sun, 28 Apr 2019 20:41:25 +0530 Subject: [PATCH 2/2] Update deployments.go --- pkg/k8sutil/deployments.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/k8sutil/deployments.go b/pkg/k8sutil/deployments.go index 2b208d0a4..438b52dda 100644 --- a/pkg/k8sutil/deployments.go +++ b/pkg/k8sutil/deployments.go @@ -171,19 +171,19 @@ func (k *K8sutil) CreateClientDeployment(baseImage string, replicas *int32, java }, Spec: v1.PodSpec{ Affinity: &affinity, + InitContainers: []v1.Container{ + { + Name: "sysctl", + Image: "busybox", + Command: []string{ "sysctl", "-w", "vm.max_map_count=262144"}, + SecurityContext: &v1.SecurityContext{ + Privileged: &[]bool{true}[0], + }, + }, + }, Containers: []v1.Container{ v1.Container{ Name: deploymentName, - InitContainers: []v1.Container{ - { - Name: "sysctl", - Image: "busybox", - Command: []string{ "sysctl", "-w", "vm.max_map_count=262144"}, - SecurityContext: &v1.SecurityContext{ - Privileged: &[]bool{true}[0], - }, - }, - }, SecurityContext: &v1.SecurityContext{ Privileged: &[]bool{true}[0], Capabilities: &v1.Capabilities{