Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor nodes orchestration to rely on StatefulSets #1463

Merged
merged 43 commits into from
Aug 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
3b24cd3
Store transport keys and certificates in a single shared secret.
nkvoll Jul 5, 2019
b48109c
Merge pull request #1198 from nkvoll/no-pod-specific-transport-secret
nkvoll Jul 5, 2019
d495796
Replace Pod-based reconciliation by StatefulSet-based reconciliation …
sebgl Jul 10, 2019
a15245a
Handle StatefulSets scale up/down/replacement (#1218)
sebgl Jul 10, 2019
0546f81
Merge master branch into statefulset-refactoring (#1232)
sebgl Jul 12, 2019
bb7e511
Add sset upgrade expectations based on Generation
sebgl Jul 15, 2019
eda6051
Improve es client routing allocation settings calls
sebgl Jul 15, 2019
242411c
Add a helper struct to lazily call the ES cluster for upgrade needs
sebgl Jul 15, 2019
a08537c
Add StatefulSet helper functions
sebgl Jul 15, 2019
89c2078
Get rid of the previous expectations implementation
sebgl Jul 15, 2019
ee2974d
Handle StatefulSet rolling upgrades
sebgl Jul 15, 2019
b5e3a50
Merge pull request #1219 from sebgl/sset-rolling-upgrade
sebgl Jul 17, 2019
26936d7
Merge branch 'master' into statefulset-refactoring
sebgl Jul 17, 2019
443cde7
Fix linter warnings
sebgl Jul 17, 2019
39293d7
Merge pull request #1266 from sebgl/sset-branch-conflicts
sebgl Jul 17, 2019
2e405b2
Merge branch 'master' into statefulset-refactoring
sebgl Jul 19, 2019
67b4429
Merge pull request #1296 from sebgl/sset-master-merge
sebgl Jul 19, 2019
c0194f6
sset: small optimization/fix (#1322)
barkbay Jul 22, 2019
8b75c62
Merge master into statefulset-refactoring (#1358)
sebgl Jul 24, 2019
01585a3
Merge branch 'master' into statefulset-refactoring
sebgl Jul 31, 2019
b8ccff1
Merge pull request #1439 from sebgl/merge-master
sebgl Jul 31, 2019
622feed
Orchestrate zen1 and zen2 settings for StatefulSets (#1262)
sebgl Aug 1, 2019
403d2ac
Merge branch 'master' into statefulset-refactoring
sebgl Aug 1, 2019
1fce57a
Fix E2E tests to work with StatefulSets (#1459)
sebgl Aug 2, 2019
58b28fb
Refactor driver & pod creation logic (#1295)
sebgl Aug 2, 2019
1b89f47
Remove PVCs at the end of E2E tests (#1464)
sebgl Aug 5, 2019
612f3a6
Remove local-volume es sample
sebgl Aug 5, 2019
b29dd50
Improve log fields names
sebgl Aug 5, 2019
4294ca7
Fix min version comment
sebgl Aug 5, 2019
25d20f1
Merge branch 'master' into statefulset-refactoring
sebgl Aug 5, 2019
63e3664
Fix wrong keystore command from merge conflict
sebgl Aug 5, 2019
c7952b8
Fix missing dependency in Gopkg.lock
sebgl Aug 5, 2019
a85d067
Remove pod name creation helpers
sebgl Aug 5, 2019
57187c1
Remove useless services in transport certs generation
sebgl Aug 5, 2019
478e791
Minor fixes in transport secrets logs and comments
sebgl Aug 5, 2019
f87f4b4
Update scheduledUpgrades only once per iteration
sebgl Aug 5, 2019
8402c7b
Remove basename comparisons in E2E tests
sebgl Aug 5, 2019
b55bc08
Run make generate for missing comment
sebgl Aug 5, 2019
bef2867
Work with the list of filtered ssets to update
sebgl Aug 5, 2019
6dce278
Merge branch 'master' into statefulset-refactoring
sebgl Aug 5, 2019
7b8b2c1
Merge branch 'master' into statefulset-refactoring
sebgl Aug 6, 2019
ff405dc
Clarify expectations comment
sebgl Aug 7, 2019
f013f24
Fix unit test name to match function name
sebgl Aug 7, 2019
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: 0 additions & 4 deletions docs/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,3 @@ include::snapshots.asciidoc[]
include::elasticsearch-spec.asciidoc[]
include::apm.asciidoc[]
include::troubleshooting.asciidoc[]




11 changes: 7 additions & 4 deletions operators/config/crds/elasticsearch_v1alpha1_elasticsearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,11 @@ spec:
description: Config represents Elasticsearch configuration.
type: object
name:
description: Name is a logical name for this set of nodes. Used
as a part of the managed Elasticsearch node.name setting.
maxLength: 12
pattern: '[a-zA-Z0-9-]*'
description: 'Name is a logical name for this set of nodes. Used
as a part of the managed Elasticsearch node.name setting. TODO:
refactor and explain name length conventions'
maxLength: 19
pattern: '[a-zA-Z0-9-]+'
type: string
nodeCount:
description: NodeCount defines how many nodes have this topology
Expand All @@ -147,6 +148,8 @@ spec:
items:
type: object
type: array
required:
- name
type: object
type: array
podDisruptionBudget:
Expand Down
1 change: 1 addition & 0 deletions operators/config/e2e/global_operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ rules:
- apps
resources:
- deployments
- statefulsets
verbs:
- get
- list
Expand Down
1 change: 1 addition & 0 deletions operators/config/e2e/namespace_operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ rules:
- apps
resources:
- deployments
- statefulsets
verbs:
- get
- list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ rules:
- apps
resources:
- deployments
- statefulsets
verbs:
- get
- list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ rules:
- apps
resources:
- deployments
- statefulsets
verbs:
- get
- list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ rules:
- apps
resources:
- deployments
- statefulsets
verbs:
- get
- list
Expand Down
13 changes: 7 additions & 6 deletions operators/config/samples/apm/apm_es_kibana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,29 @@
apiVersion: elasticsearch.k8s.elastic.co/v1alpha1
kind: Elasticsearch
metadata:
name: elasticsearch-sample
name: es-apm-sample
spec:
version: 7.2.0
nodes:
- nodeCount: 3
- name: default
nodeCount: 3
---
apiVersion: apm.k8s.elastic.co/v1alpha1
kind: ApmServer
metadata:
name: apm-server-sample
name: apm-apm-sample
spec:
version: 7.2.0
nodeCount: 1
elasticsearchRef:
name: "elasticsearch-sample"
name: "es-apm-sample"
---
apiVersion: kibana.k8s.elastic.co/v1alpha1
kind: Kibana
metadata:
name: kibana-sample
name: kb-apm-sample
spec:
version: 7.2.0
nodeCount: 1
elasticsearchRef:
name: "elasticsearch-sample"
name: "es-apm-sample"
3 changes: 2 additions & 1 deletion operators/config/samples/elasticsearch/elasticsearch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ metadata:
spec:
version: 7.2.0
nodes:
- config:
- name: default
config:
# most Elasticsearch configuration parameters are possible to set, e.g:
node.attr.attr_name: attr_value
node.master: true
Expand Down
3 changes: 2 additions & 1 deletion operators/config/samples/kibana/kibana_es.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ metadata:
spec:
version: 7.2.0
nodes:
- nodeCount: 1
- name: default
nodeCount: 1
---
apiVersion: kibana.k8s.elastic.co/v1alpha1
kind: Kibana
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ func (es ElasticsearchSpec) NodeCount() int32 {
// NodeSpec defines a common topology for a set of Elasticsearch nodes
type NodeSpec struct {
// Name is a logical name for this set of nodes. Used as a part of the managed Elasticsearch node.name setting.
// +kubebuilder:validation:Pattern=[a-zA-Z0-9-]*
// +kubebuilder:validation:MaxLength=12
Name string `json:"name,omitempty"`
// +kubebuilder:validation:Pattern=[a-zA-Z0-9-]+
// +kubebuilder:validation:MaxLength=19
// TODO: refactor and explain name length conventions
Name string `json:"name"`

// Config represents Elasticsearch configuration.
Config *commonv1alpha1.Config `json:"config,omitempty"`
Expand Down
46 changes: 9 additions & 37 deletions operators/pkg/controller/apmserver/apmserver_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
apmv1alpha1 "github.com/elastic/cloud-on-k8s/operators/pkg/apis/apm/v1alpha1"
"github.com/elastic/cloud-on-k8s/operators/pkg/controller/common/certificates"
"github.com/elastic/cloud-on-k8s/operators/pkg/controller/common/certificates/http"
"github.com/elastic/cloud-on-k8s/operators/pkg/controller/common/defaults"
"github.com/elastic/cloud-on-k8s/operators/pkg/controller/common/keystore"
"github.com/elastic/cloud-on-k8s/operators/pkg/controller/common/watches"
"github.com/elastic/cloud-on-k8s/operators/pkg/utils/k8s"
Expand Down Expand Up @@ -69,25 +70,7 @@ func (tp testParams) withInitContainer() testParams {
},
Name: "",
Image: "docker.elastic.co/apm/apm-server:1.0",
Env: []corev1.EnvVar{{
Name: "POD_NAME",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
APIVersion: "v1",
FieldPath: "metadata.name",
},
},
},
{
Name: "POD_IP",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
APIVersion: "v1",
FieldPath: "status.podIP",
},
},
},
},
Env: defaults.PodDownwardEnvVars,
},
}
return tp
Expand Down Expand Up @@ -137,7 +120,6 @@ func expectedDeploymentParams() testParams {
},
Containers: []corev1.Container{{
VolumeMounts: []corev1.VolumeMount{

{
Name: "config",
ReadOnly: true,
Expand All @@ -163,27 +145,17 @@ func expectedDeploymentParams() testParams {
"-c",
"config/config-secret/apm-server.yml",
},
Env: []corev1.EnvVar{{
Name: "POD_NAME",
Env: append(defaults.PodDownwardEnvVars, corev1.EnvVar{
Name: "SECRET_TOKEN",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{
APIVersion: "v1",
FieldPath: "metadata.name",
},
},
},
{
Name: "SECRET_TOKEN",
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &corev1.SecretKeySelector{
LocalObjectReference: corev1.LocalObjectReference{
Name: "test-apm-server-apm-token",
},
Key: "secret-token",
SecretKeyRef: &corev1.SecretKeySelector{
LocalObjectReference: corev1.LocalObjectReference{
Name: "test-apm-server-apm-token",
},
Key: "secret-token",
},
},
},
}),
Ports: []corev1.ContainerPort{
{Name: "http", ContainerPort: int32(8200), Protocol: corev1.ProtocolTCP},
},
Expand Down
94 changes: 0 additions & 94 deletions operators/pkg/controller/apmserver/config/config_test.go

This file was deleted.

22 changes: 7 additions & 15 deletions operators/pkg/controller/apmserver/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,15 @@ func newPodSpec(as *v1alpha1.ApmServer, p PodSpecParams) corev1.PodTemplateSpec
filepath.Join(ConfigVolumePath, "config-secret"),
)

env := []corev1.EnvVar{
{
Name: "POD_NAME",
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{APIVersion: "v1", FieldPath: "metadata.name"},
env := append(defaults.PodDownwardEnvVars, corev1.EnvVar{
Name: "SECRET_TOKEN",
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &corev1.SecretKeySelector{
LocalObjectReference: corev1.LocalObjectReference{Name: p.ApmServerSecret.Name},
Key: SecretTokenKey,
},
},
{
Name: "SECRET_TOKEN",
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &corev1.SecretKeySelector{
LocalObjectReference: corev1.LocalObjectReference{Name: p.ApmServerSecret.Name},
Key: SecretTokenKey,
},
},
},
}
})

builder := defaults.NewPodTemplateBuilder(
p.PodTemplate, v1alpha1.APMServerContainerName).
Expand Down
12 changes: 10 additions & 2 deletions operators/pkg/controller/apmserver/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import (
"reflect"
"testing"

"github.com/elastic/cloud-on-k8s/operators/pkg/apis/apm/v1alpha1"
"github.com/elastic/cloud-on-k8s/operators/pkg/controller/common/volume"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/elastic/cloud-on-k8s/operators/pkg/apis/apm/v1alpha1"
"github.com/elastic/cloud-on-k8s/operators/pkg/controller/common/volume"
"github.com/elastic/cloud-on-k8s/operators/pkg/controller/elasticsearch/settings"
)

func TestNewPodSpec(t *testing.T) {
Expand Down Expand Up @@ -64,6 +66,12 @@ func TestNewPodSpec(t *testing.T) {
Name: v1alpha1.APMServerContainerName,
Image: imageWithVersion(defaultImageRepositoryAndName, "7.0.1"),
Env: []corev1.EnvVar{
{
Name: settings.EnvPodIP,
ValueFrom: &corev1.EnvVarSource{
FieldRef: &corev1.ObjectFieldSelector{APIVersion: "v1", FieldPath: "status.podIP"},
},
},
{
Name: "POD_NAME",
ValueFrom: &corev1.EnvVarSource{
Expand Down
Loading