Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Use cgroup for jvm memory limit #337

Merged
merged 3 commits into from
Apr 24, 2018
Merged
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
4 changes: 3 additions & 1 deletion pkg/controllers/cassandra/nodepool/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/jetstack/navigator/pkg/apis/navigator/v1alpha1"
"github.com/jetstack/navigator/pkg/controllers/cassandra/util"
"github.com/jetstack/navigator/pkg/controllers/common"
"github.com/jetstack/navigator/pkg/util/ptr"
)

Expand Down Expand Up @@ -218,7 +219,8 @@ func StatefulSetForCluster(
Name: "JVM_OPTS",
Value: fmt.Sprintf(
"-javaagent:%s/jolokia.jar=host=%s,port=%d,agentContext=%s "+
"-javaagent:%s/jmx_prometheus_javaagent.jar=8080:%s/jmx_prometheus_javaagent.yaml",
"-javaagent:%s/jmx_prometheus_javaagent.jar=8080:%s/jmx_prometheus_javaagent.yaml "+
common.JVMCgroupOpts,
sharedVolumeMountPath,
jolokiaHost,
jolokiaPort,
Expand Down
13 changes: 13 additions & 0 deletions pkg/controllers/common/common.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package common

const (
JVMCgroupOpts =
// allow using cgroup flags
"-XX:+UnlockExperimentalVMOptions " +

// use cgroup limit instead of host
"-XX:+UseCGroupMemoryLimitForHeap " +

// use 100% of the available memory
"-XX:MaxRAMFraction=1 "
)
5 changes: 5 additions & 0 deletions pkg/controllers/elasticsearch/actions/create_nodepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/jetstack/navigator/pkg/apis/navigator/v1alpha1"
"github.com/jetstack/navigator/pkg/controllers"
"github.com/jetstack/navigator/pkg/controllers/common"
"github.com/jetstack/navigator/pkg/controllers/elasticsearch/util"
"github.com/jetstack/navigator/pkg/util/ptr"
)
Expand Down Expand Up @@ -200,6 +201,10 @@ func elasticsearchPodTemplateSpec(controllerName string, c *v1alpha1.Elasticsear
Name: "PLUGINS",
Value: plugins,
},
{
Name: "ES_JAVA_OPTS",
Value: common.JVMCgroupOpts,
},
{
Name: "LEADER_ELECTION_CONFIG_MAP",
// TODO: trim the length of this string
Expand Down