Skip to content

Commit

Permalink
Add old readiness probe related ENVs (elastic#8009)
Browse files Browse the repository at this point in the history
* add readiness probe credentials unconditionally

(cherry picked from commit 41cae15)
  • Loading branch information
kvalliyurnatt committed Oct 25, 2024
1 parent f32e756 commit d96a4b9
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 41 deletions.
104 changes: 84 additions & 20 deletions pkg/controller/elasticsearch/nodespec/__snapshots__/podspec_test.snap
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@
}
}
},
{
"name": "HEADLESS_SERVICE_NAME",
"value": "name-es-nodeset-1"
},
{
"name": "PROBE_PASSWORD_PATH",
"value": "/mnt/elastic-internal/pod-mounted-users/elastic-internal-probe"
Expand All @@ -105,10 +109,6 @@
"name": "READINESS_PROBE_PROTOCOL",
"value": "https"
},
{
"name": "HEADLESS_SERVICE_NAME",
"value": "name-es-nodeset-1"
},
{
"name": "NSS_SDB_USE_CACHE",
"value": "no"
Expand Down Expand Up @@ -288,6 +288,10 @@
"name": "my-env",
"value": "my-value"
},
{
"name": "HEADLESS_SERVICE_NAME",
"value": "name-es-nodeset-1"
},
{
"name": "PROBE_PASSWORD_PATH",
"value": "/mnt/elastic-internal/pod-mounted-users/elastic-internal-probe"
Expand All @@ -300,10 +304,6 @@
"name": "READINESS_PROBE_PROTOCOL",
"value": "https"
},
{
"name": "HEADLESS_SERVICE_NAME",
"value": "name-es-nodeset-1"
},
{
"name": "NSS_SDB_USE_CACHE",
"value": "no"
Expand Down Expand Up @@ -442,6 +442,10 @@
"name": "my-env",
"value": "my-value"
},
{
"name": "HEADLESS_SERVICE_NAME",
"value": "name-es-nodeset-1"
},
{
"name": "PROBE_PASSWORD_PATH",
"value": "/mnt/elastic-internal/pod-mounted-users/elastic-internal-probe"
Expand All @@ -454,10 +458,6 @@
"name": "READINESS_PROBE_PROTOCOL",
"value": "https"
},
{
"name": "HEADLESS_SERVICE_NAME",
"value": "name-es-nodeset-1"
},
{
"name": "NSS_SDB_USE_CACHE",
"value": "no"
Expand Down Expand Up @@ -598,6 +598,10 @@
"name": "my-env",
"value": "my-value"
},
{
"name": "HEADLESS_SERVICE_NAME",
"value": "name-es-nodeset-1"
},
{
"name": "PROBE_PASSWORD_PATH",
"value": "/mnt/elastic-internal/pod-mounted-users/elastic-internal-probe"
Expand All @@ -610,10 +614,6 @@
"name": "READINESS_PROBE_PROTOCOL",
"value": "https"
},
{
"name": "HEADLESS_SERVICE_NAME",
"value": "name-es-nodeset-1"
},
{
"name": "NSS_SDB_USE_CACHE",
"value": "no"
Expand Down Expand Up @@ -750,6 +750,10 @@
"name": "my-env",
"value": "my-value"
},
{
"name": "HEADLESS_SERVICE_NAME",
"value": "name-es-nodeset-1"
},
{
"name": "PROBE_PASSWORD_PATH",
"value": "/mnt/elastic-internal/pod-mounted-users/elastic-internal-probe"
Expand All @@ -762,10 +766,6 @@
"name": "READINESS_PROBE_PROTOCOL",
"value": "https"
},
{
"name": "HEADLESS_SERVICE_NAME",
"value": "name-es-nodeset-1"
},
{
"name": "NSS_SDB_USE_CACHE",
"value": "no"
Expand Down Expand Up @@ -1088,6 +1088,22 @@
{
"name": "HEADLESS_SERVICE_NAME",
"value": "name-es-nodeset-1"
},
{
"name": "PROBE_PASSWORD_PATH",
"value": "/mnt/elastic-internal/pod-mounted-users/elastic-internal-probe"
},
{
"name": "PROBE_USERNAME",
"value": "elastic-internal-probe"
},
{
"name": "READINESS_PROBE_PROTOCOL",
"value": "https"
},
{
"name": "NSS_SDB_USE_CACHE",
"value": "no"
}
],
"image": "docker.elastic.co/elasticsearch/elasticsearch:8.14.0",
Expand Down Expand Up @@ -1273,6 +1289,22 @@
{
"name": "HEADLESS_SERVICE_NAME",
"value": "name-es-nodeset-1"
},
{
"name": "PROBE_PASSWORD_PATH",
"value": "/mnt/elastic-internal/pod-mounted-users/elastic-internal-probe"
},
{
"name": "PROBE_USERNAME",
"value": "elastic-internal-probe"
},
{
"name": "READINESS_PROBE_PROTOCOL",
"value": "https"
},
{
"name": "NSS_SDB_USE_CACHE",
"value": "no"
}
],
"image": "docker.elastic.co/elasticsearch/elasticsearch:8.14.0",
Expand Down Expand Up @@ -1422,6 +1454,22 @@
{
"name": "HEADLESS_SERVICE_NAME",
"value": "name-es-nodeset-1"
},
{
"name": "PROBE_PASSWORD_PATH",
"value": "/mnt/elastic-internal/pod-mounted-users/elastic-internal-probe"
},
{
"name": "PROBE_USERNAME",
"value": "elastic-internal-probe"
},
{
"name": "READINESS_PROBE_PROTOCOL",
"value": "https"
},
{
"name": "NSS_SDB_USE_CACHE",
"value": "no"
}
],
"image": "docker.elastic.co/elasticsearch/elasticsearch:8.14.0",
Expand Down Expand Up @@ -1564,6 +1612,22 @@
{
"name": "HEADLESS_SERVICE_NAME",
"value": "name-es-nodeset-1"
},
{
"name": "PROBE_PASSWORD_PATH",
"value": "/mnt/elastic-internal/pod-mounted-users/elastic-internal-probe"
},
{
"name": "PROBE_USERNAME",
"value": "elastic-internal-probe"
},
{
"name": "READINESS_PROBE_PROTOCOL",
"value": "https"
},
{
"name": "NSS_SDB_USE_CACHE",
"value": "no"
}
],
"image": "docker.elastic.co/elasticsearch/elasticsearch:8.14.0",
Expand Down
39 changes: 18 additions & 21 deletions pkg/controller/elasticsearch/nodespec/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

commonv1 "github.com/elastic/cloud-on-k8s/v2/pkg/apis/common/v1"
esv1 "github.com/elastic/cloud-on-k8s/v2/pkg/apis/elasticsearch/v1"
"github.com/elastic/cloud-on-k8s/v2/pkg/controller/common/defaults"
"github.com/elastic/cloud-on-k8s/v2/pkg/controller/common/version"
"github.com/elastic/cloud-on-k8s/v2/pkg/controller/elasticsearch/label"
Expand Down Expand Up @@ -47,28 +46,26 @@ var (
func DefaultEnvVars(v version.Version, httpCfg commonv1.HTTPConfig, headlessServiceName string) []corev1.EnvVar {
vars := []corev1.EnvVar{
// needed in elasticsearch.yml
// We do not recommend overriding the default readiness probe on Elasticsearch 8.2.0 and later.
// ECK configures a socket based readiness probe using the Elasticsearch which is not influenced by the load on the Elasticsearch cluster.
// These settings are added only for backwards compatibility and will be removed in a future release.
{Name: settings.HeadlessServiceName, Value: headlessServiceName},
}
if v.LT(esv1.MinReadinessPortVersion) {
vars = []corev1.EnvVar{
{Name: settings.EnvProbePasswordPath, Value: path.Join(esvolume.PodMountedUsersSecretMountPath, user.ProbeUserName)},
{Name: settings.EnvProbeUsername, Value: user.ProbeUserName},
{Name: settings.EnvReadinessProbeProtocol, Value: httpCfg.Protocol()},
{Name: settings.HeadlessServiceName, Value: headlessServiceName},
{Name: settings.EnvProbePasswordPath, Value: path.Join(esvolume.PodMountedUsersSecretMountPath, user.ProbeUserName)},
{Name: settings.EnvProbeUsername, Value: user.ProbeUserName},
{Name: settings.EnvReadinessProbeProtocol, Value: httpCfg.Protocol()},

// Disable curl/libnss use of sqlite caching to avoid triggering an issue in linux/kubernetes
// where the kernel's dentry cache grows by 5mb every time curl is invoked. This cache usage
// is charged against the pod which created it. In our case, the elasticsearch nodes trigger
// this problem with the readinessProbe invoking curl.
//
// In production testing, no negative impact on curl's behavior is observed from this setting.
// This setting is primarily targeted at curl invocation in the readinessProbe.
// References:
// https://github.com/elastic/cloud-on-k8s/issues/1581#issuecomment-525527334
// https://github.com/elastic/cloud-on-k8s/issues/1635
// https://issuetracker.google.com/issues/140577001
{Name: "NSS_SDB_USE_CACHE", Value: "no"},
}
// Disable curl/libnss use of sqlite caching to avoid triggering an issue in linux/kubernetes
// where the kernel's dentry cache grows by 5mb every time curl is invoked. This cache usage
// is charged against the pod which created it. In our case, the elasticsearch nodes trigger
// this problem with the readinessProbe invoking curl.
//
// In production testing, no negative impact on curl's behavior is observed from this setting.
// This setting is primarily targeted at curl invocation in the readinessProbe.
// References:
// https://github.com/elastic/cloud-on-k8s/issues/1581#issuecomment-525527334
// https://github.com/elastic/cloud-on-k8s/issues/1635
// https://issuetracker.google.com/issues/140577001
{Name: "NSS_SDB_USE_CACHE", Value: "no"},
}
return defaults.ExtendPodDownwardEnvVars(vars...)
}
Expand Down

0 comments on commit d96a4b9

Please sign in to comment.