Skip to content

Commit 6da15a7

Browse files
narphv1v
andauthored
Resolve kubernetes setup (#18)
* fix docs * add scripts * script: enable execution permissions * ci: enable k8s specific validations (#19) * ci: enable k8s specific validations * add scripts * ci: use the rigth when * ci: enable k8s specific validations * ci: use the rigth when * script: enable execution permissions * script: enable execution permissions * ci: enable k8s specific validations * ci: use the rigth when * Update .ci/Jenkinsfile Co-authored-by: narph <[email protected]> * delete cluster * test * add delete * ci: more resilience when installing kind See elastic/beats#21857 * ci: argument in the signature is not needed * remove duplicate * ci: simplify kind/kubectl environment (#22) * revert aarch64 changes (#21) * revert aarch64 * fmt * rename * rename * rename * ci: run k8s validation for different versions (#25) Co-authored-by: Victor Martinez <[email protected]>
1 parent 52b0795 commit 6da15a7

9 files changed

+98
-76
lines changed

.ci/Jenkinsfile

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env groovy
22

3-
@Library('apm@feature/use-internal-ci') _
3+
@Library('apm@current') _
44

55
pipeline {
66
agent { label 'ubuntu-20.04 && immutable' }
@@ -99,6 +99,17 @@ pipeline {
9999
}
100100
}
101101
}
102+
stage('K8s') {
103+
when {
104+
// TODO: Run only if changes in
105+
// - "^deploy/kubernetes/.*"
106+
// - "^version/docs/version.asciidoc"
107+
expression { return env.PLATFORM == 'ubuntu-20.04 && immutable' }
108+
}
109+
steps {
110+
runK8s(k8sVersion: 'v1.23.0', kindVersion: 'v0.11.1', context: "K8s-${PLATFORM}")
111+
}
112+
}
102113
}
103114
}
104115
}
@@ -141,6 +152,17 @@ pipeline {
141152
}
142153
}
143154
}
155+
stage('K8s') {
156+
when {
157+
// TODO: Run only if changes in
158+
// - "^deploy/kubernetes/.*"
159+
// - "^version/docs/version.asciidoc"
160+
not { changeRequest() }
161+
}
162+
steps {
163+
runAllK8s(["v1.23.0", "v1.22.0", "v1.21.1", "v1.20.7", "v1.19.11", "v1.18.19"])
164+
}
165+
}
144166
stage('e2e tests') {
145167
when {
146168
beforeAgent true
@@ -245,3 +267,27 @@ def withPackageDarwinEnv(Closure body) {
245267
body()
246268
}
247269
}
270+
271+
def runAllK8s(versions) {
272+
def parallelTasks = [:]
273+
versions.each { version ->
274+
node('ubuntu-20.04 && immutable') {
275+
deleteDir()
276+
unstash 'source'
277+
runK8s(k8sVersion: version, kindVersion: 'v0.11.1', context: "K8s-${version}")
278+
}
279+
}
280+
parallel(parallelTasks)
281+
}
282+
283+
def runK8s(Map args=[:]) {
284+
withGithubNotify(context: args.context) {
285+
withMageEnv(){
286+
withKindEnv(args) {
287+
dir("${BASE_DIR}"){
288+
sh(label: "Deploy to kubernetes",script: "make -C deploy/kubernetes test")
289+
}
290+
}
291+
}
292+
}
293+
}

deploy/kubernetes/Jenkinsfile.yml

Lines changed: 0 additions & 22 deletions
This file was deleted.

deploy/kubernetes/README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22

33
## Getting started
44

5-
This is the list of officially supported Beats, with example manifests to run
5+
This is the list of officially supported Elastic Agents, with example manifests to run
66
them in Kubernetes:
77

88
Beat | Description
99
---- | ----
10-
[filebeat](filebeat) | Tails and ships logs
11-
[metricbeat](metricbeat) | Fetches sets of metrics from the operating system and services
12-
[auditbeat](auditbeat) | Collect Linux audit framework data and monitor files integrity
13-
[heartbeat](heartbeat) | Monitor services for their availability with active probing
10+
[Elastic Agent managed](elastic-agent-managed) | Elastic Agent managed by Fleet setup
11+
[Elastic Agent standalone](elastic-agent-standalone) | Standalone Elastic Agent setup

deploy/kubernetes/elastic-agent-standalone-kubernetes.yaml

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ metadata:
44
name: agent-node-datastreams
55
namespace: kube-system
66
labels:
7-
k8s-app: elastic-agent
7+
k8s-app: elastic-agent-standalone
88
data:
99
agent.yml: |-
1010
outputs:
@@ -512,27 +512,27 @@ data:
512512
apiVersion: apps/v1
513513
kind: DaemonSet
514514
metadata:
515-
name: elastic-agent
515+
name: elastic-agent-standalone
516516
namespace: kube-system
517517
labels:
518-
app: elastic-agent
518+
app: elastic-agent-standalone
519519
spec:
520520
selector:
521521
matchLabels:
522-
app: elastic-agent
522+
app: elastic-agent-standalone
523523
template:
524524
metadata:
525525
labels:
526-
app: elastic-agent
526+
app: elastic-agent-standalone
527527
spec:
528528
tolerations:
529529
- key: node-role.kubernetes.io/master
530530
effect: NoSchedule
531-
serviceAccountName: elastic-agent
531+
serviceAccountName: elastic-agent-standalona
532532
hostNetwork: true
533533
dnsPolicy: ClusterFirstWithHostNet
534534
containers:
535-
- name: elastic-agent
535+
- name: elastic-agent-standalone
536536
image: docker.elastic.co/beats/elastic-agent:8.0.0
537537
args: [
538538
"-c", "/etc/agent.yml",
@@ -599,50 +599,50 @@ spec:
599599
apiVersion: rbac.authorization.k8s.io/v1
600600
kind: ClusterRoleBinding
601601
metadata:
602-
name: elastic-agent
602+
name: elastic-agent-standalone
603603
subjects:
604604
- kind: ServiceAccount
605-
name: elastic-agent
605+
name: elastic-agent-standalone
606606
namespace: kube-system
607607
roleRef:
608608
kind: ClusterRole
609-
name: elastic-agent
609+
name: elastic-agent-standalone
610610
apiGroup: rbac.authorization.k8s.io
611611
---
612612
apiVersion: rbac.authorization.k8s.io/v1
613613
kind: RoleBinding
614614
metadata:
615615
namespace: kube-system
616-
name: elastic-agent
616+
name: elastic-agent-standalone
617617
subjects:
618618
- kind: ServiceAccount
619-
name: elastic-agent
619+
name: elastic-agent-standalone
620620
namespace: kube-system
621621
roleRef:
622622
kind: Role
623-
name: elastic-agent
623+
name: elastic-agent-standalone
624624
apiGroup: rbac.authorization.k8s.io
625625
---
626626
apiVersion: rbac.authorization.k8s.io/v1
627627
kind: RoleBinding
628628
metadata:
629-
name: elastic-agent-kubeadm-config
629+
name: elastic-agent-standalone-kubeadm-config
630630
namespace: kube-system
631631
subjects:
632632
- kind: ServiceAccount
633-
name: elastic-agent
633+
name: elastic-agent-standalone
634634
namespace: kube-system
635635
roleRef:
636636
kind: Role
637-
name: elastic-agent-kubeadm-config
637+
name: elastic-agent-standalone-kubeadm-config
638638
apiGroup: rbac.authorization.k8s.io
639639
---
640640
apiVersion: rbac.authorization.k8s.io/v1
641641
kind: ClusterRole
642642
metadata:
643-
name: elastic-agent
643+
name: elastic-agent-standalone
644644
labels:
645-
k8s-app: elastic-agent
645+
k8s-app: elastic-agent-standalone
646646
rules:
647647
- apiGroups: [""]
648648
resources:
@@ -689,11 +689,11 @@ rules:
689689
apiVersion: rbac.authorization.k8s.io/v1
690690
kind: Role
691691
metadata:
692-
name: elastic-agent
692+
name: elastic-agent-standalone
693693
# should be the namespace where elastic-agent is running
694694
namespace: kube-system
695695
labels:
696-
k8s-app: elastic-agent
696+
k8s-app: elastic-agent-standalone
697697
rules:
698698
- apiGroups:
699699
- coordination.k8s.io
@@ -704,10 +704,10 @@ rules:
704704
apiVersion: rbac.authorization.k8s.io/v1
705705
kind: Role
706706
metadata:
707-
name: elastic-agent-kubeadm-config
707+
name: elastic-agent-standalone-kubeadm-config
708708
namespace: kube-system
709709
labels:
710-
k8s-app: elastic-agent
710+
k8s-app: elastic-agent-standalone
711711
rules:
712712
- apiGroups: [""]
713713
resources:
@@ -719,8 +719,8 @@ rules:
719719
apiVersion: v1
720720
kind: ServiceAccount
721721
metadata:
722-
name: elastic-agent
722+
name: elastic-agent-standalone
723723
namespace: kube-system
724724
labels:
725-
k8s-app: elastic-agent
725+
k8s-app: elastic-agent-standalone
726726
---

deploy/kubernetes/elastic-agent-standalone/elastic-agent-standalone-daemonset-configmap.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ metadata:
44
name: agent-node-datastreams
55
namespace: kube-system
66
labels:
7-
k8s-app: elastic-agent
7+
k8s-app: elastic-agent-standalone
88
data:
99
agent.yml: |-
1010
outputs:

deploy/kubernetes/elastic-agent-standalone/elastic-agent-standalone-daemonset.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
apiVersion: apps/v1
22
kind: DaemonSet
33
metadata:
4-
name: elastic-agent
4+
name: elastic-agent-standalone
55
namespace: kube-system
66
labels:
7-
app: elastic-agent
7+
app: elastic-agent-standalone
88
spec:
99
selector:
1010
matchLabels:
11-
app: elastic-agent
11+
app: elastic-agent-standalone
1212
template:
1313
metadata:
1414
labels:
15-
app: elastic-agent
15+
app: elastic-agent-standalone
1616
spec:
1717
tolerations:
1818
- key: node-role.kubernetes.io/master
1919
effect: NoSchedule
20-
serviceAccountName: elastic-agent
20+
serviceAccountName: elastic-agent-standalone
2121
hostNetwork: true
2222
dnsPolicy: ClusterFirstWithHostNet
2323
containers:
24-
- name: elastic-agent
24+
- name: elastic-agent-standalone
2525
image: docker.elastic.co/beats/elastic-agent:%VERSION%
2626
args: [
2727
"-c", "/etc/agent.yml",
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
apiVersion: rbac.authorization.k8s.io/v1
22
kind: ClusterRoleBinding
33
metadata:
4-
name: elastic-agent
4+
name: elastic-agent-standalone
55
subjects:
66
- kind: ServiceAccount
7-
name: elastic-agent
7+
name: elastic-agent-standalone
88
namespace: kube-system
99
roleRef:
1010
kind: ClusterRole
11-
name: elastic-agent
11+
name: elastic-agent-standalone
1212
apiGroup: rbac.authorization.k8s.io
1313
---
1414
apiVersion: rbac.authorization.k8s.io/v1
1515
kind: RoleBinding
1616
metadata:
1717
namespace: kube-system
18-
name: elastic-agent
18+
name: elastic-agent-standalone
1919
subjects:
2020
- kind: ServiceAccount
21-
name: elastic-agent
21+
name: elastic-agent-standalone
2222
namespace: kube-system
2323
roleRef:
2424
kind: Role
25-
name: elastic-agent
25+
name: elastic-agent-standalone
2626
apiGroup: rbac.authorization.k8s.io
2727
---
2828
apiVersion: rbac.authorization.k8s.io/v1
2929
kind: RoleBinding
3030
metadata:
31-
name: elastic-agent-kubeadm-config
31+
name: elastic-agent-standalone-kubeadm-config
3232
namespace: kube-system
3333
subjects:
3434
- kind: ServiceAccount
35-
name: elastic-agent
35+
name: elastic-agent-standalone
3636
namespace: kube-system
3737
roleRef:
3838
kind: Role
39-
name: elastic-agent-kubeadm-config
39+
name: elastic-agent-standalone-kubeadm-config
4040
apiGroup: rbac.authorization.k8s.io

deploy/kubernetes/elastic-agent-standalone/elastic-agent-standalone-role.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
apiVersion: rbac.authorization.k8s.io/v1
22
kind: ClusterRole
33
metadata:
4-
name: elastic-agent
4+
name: elastic-agent-standalone
55
labels:
6-
k8s-app: elastic-agent
6+
k8s-app: elastic-agent-standalone
77
rules:
88
- apiGroups: [""]
99
resources:
@@ -50,11 +50,11 @@ rules:
5050
apiVersion: rbac.authorization.k8s.io/v1
5151
kind: Role
5252
metadata:
53-
name: elastic-agent
53+
name: elastic-agent-standalone
5454
# should be the namespace where elastic-agent is running
5555
namespace: kube-system
5656
labels:
57-
k8s-app: elastic-agent
57+
k8s-app: elastic-agent-standalone
5858
rules:
5959
- apiGroups:
6060
- coordination.k8s.io
@@ -65,10 +65,10 @@ rules:
6565
apiVersion: rbac.authorization.k8s.io/v1
6666
kind: Role
6767
metadata:
68-
name: elastic-agent-kubeadm-config
68+
name: elastic-agent-standalone-kubeadm-config
6969
namespace: kube-system
7070
labels:
71-
k8s-app: elastic-agent
71+
k8s-app: elastic-agent-standalone
7272
rules:
7373
- apiGroups: [""]
7474
resources:
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v1
22
kind: ServiceAccount
33
metadata:
4-
name: elastic-agent
4+
name: elastic-agent-standalone
55
namespace: kube-system
66
labels:
7-
k8s-app: elastic-agent
7+
k8s-app: elastic-agent-standalone

0 commit comments

Comments
 (0)