Skip to content

Commit

Permalink
Resolve kubernetes setup (#18)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
narph and v1v committed Mar 3, 2022
1 parent 44e5c22 commit 289d795
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 76 deletions.
48 changes: 47 additions & 1 deletion .ci/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env groovy

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

pipeline {
agent { label 'ubuntu-20.04 && immutable' }
Expand Down Expand Up @@ -99,6 +99,17 @@ pipeline {
}
}
}
stage('K8s') {
when {
// TODO: Run only if changes in
// - "^deploy/kubernetes/.*"
// - "^version/docs/version.asciidoc"
expression { return env.PLATFORM == 'ubuntu-20.04 && immutable' }
}
steps {
runK8s(k8sVersion: 'v1.23.0', kindVersion: 'v0.11.1', context: "K8s-${PLATFORM}")
}
}
}
}
}
Expand Down Expand Up @@ -141,6 +152,17 @@ pipeline {
}
}
}
stage('K8s') {
when {
// TODO: Run only if changes in
// - "^deploy/kubernetes/.*"
// - "^version/docs/version.asciidoc"
not { changeRequest() }
}
steps {
runAllK8s(["v1.23.0", "v1.22.0", "v1.21.1", "v1.20.7", "v1.19.11", "v1.18.19"])
}
}
stage('e2e tests') {
when {
beforeAgent true
Expand Down Expand Up @@ -245,3 +267,27 @@ def withPackageDarwinEnv(Closure body) {
body()
}
}

def runAllK8s(versions) {
def parallelTasks = [:]
versions.each { version ->
node('ubuntu-20.04 && immutable') {
deleteDir()
unstash 'source'
runK8s(k8sVersion: version, kindVersion: 'v0.11.1', context: "K8s-${version}")
}
}
parallel(parallelTasks)
}

def runK8s(Map args=[:]) {
withGithubNotify(context: args.context) {
withMageEnv(){
withKindEnv(args) {
dir("${BASE_DIR}"){
sh(label: "Deploy to kubernetes",script: "make -C deploy/kubernetes test")
}
}
}
}
}
22 changes: 0 additions & 22 deletions deploy/kubernetes/Jenkinsfile.yml

This file was deleted.

8 changes: 3 additions & 5 deletions deploy/kubernetes/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@

## Getting started

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

Beat | Description
---- | ----
[filebeat](filebeat) | Tails and ships logs
[metricbeat](metricbeat) | Fetches sets of metrics from the operating system and services
[auditbeat](auditbeat) | Collect Linux audit framework data and monitor files integrity
[heartbeat](heartbeat) | Monitor services for their availability with active probing
[Elastic Agent managed](elastic-agent-managed) | Elastic Agent managed by Fleet setup
[Elastic Agent standalone](elastic-agent-standalone) | Standalone Elastic Agent setup
48 changes: 24 additions & 24 deletions deploy/kubernetes/elastic-agent-standalone-kubernetes.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: agent-node-datastreams
namespace: kube-system
labels:
k8s-app: elastic-agent
k8s-app: elastic-agent-standalone
data:
agent.yml: |-
outputs:
Expand Down Expand Up @@ -544,27 +544,27 @@ data:
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: elastic-agent
name: elastic-agent-standalone
namespace: kube-system
labels:
app: elastic-agent
app: elastic-agent-standalone
spec:
selector:
matchLabels:
app: elastic-agent
app: elastic-agent-standalone
template:
metadata:
labels:
app: elastic-agent
app: elastic-agent-standalone
spec:
tolerations:
- key: node-role.kubernetes.io/master
effect: NoSchedule
serviceAccountName: elastic-agent
serviceAccountName: elastic-agent-standalone
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: elastic-agent
- name: elastic-agent-standalone
image: docker.elastic.co/beats/elastic-agent:8.2.0
args: [
"-c", "/etc/agent.yml",
Expand Down Expand Up @@ -631,50 +631,50 @@ spec:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: elastic-agent
name: elastic-agent-standalone
subjects:
- kind: ServiceAccount
name: elastic-agent
name: elastic-agent-standalone
namespace: kube-system
roleRef:
kind: ClusterRole
name: elastic-agent
name: elastic-agent-standalone
apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
namespace: kube-system
name: elastic-agent
name: elastic-agent-standalone
subjects:
- kind: ServiceAccount
name: elastic-agent
name: elastic-agent-standalone
namespace: kube-system
roleRef:
kind: Role
name: elastic-agent
name: elastic-agent-standalone
apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: elastic-agent-kubeadm-config
name: elastic-agent-standalone-kubeadm-config
namespace: kube-system
subjects:
- kind: ServiceAccount
name: elastic-agent
name: elastic-agent-standalone
namespace: kube-system
roleRef:
kind: Role
name: elastic-agent-kubeadm-config
name: elastic-agent-standalone-kubeadm-config
apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: elastic-agent
name: elastic-agent-standalone
labels:
k8s-app: elastic-agent
k8s-app: elastic-agent-standalone
rules:
- apiGroups: [""]
resources:
Expand Down Expand Up @@ -721,11 +721,11 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: elastic-agent
name: elastic-agent-standalone
# should be the namespace where elastic-agent is running
namespace: kube-system
labels:
k8s-app: elastic-agent
k8s-app: elastic-agent-standalone
rules:
- apiGroups:
- coordination.k8s.io
Expand All @@ -736,10 +736,10 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: elastic-agent-kubeadm-config
name: elastic-agent-standalone-kubeadm-config
namespace: kube-system
labels:
k8s-app: elastic-agent
k8s-app: elastic-agent-standalone
rules:
- apiGroups: [""]
resources:
Expand All @@ -751,8 +751,8 @@ rules:
apiVersion: v1
kind: ServiceAccount
metadata:
name: elastic-agent
name: elastic-agent-standalone
namespace: kube-system
labels:
k8s-app: elastic-agent
k8s-app: elastic-agent-standalone
---
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: agent-node-datastreams
namespace: kube-system
labels:
k8s-app: elastic-agent
k8s-app: elastic-agent-standalone
data:
agent.yml: |-
outputs:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: elastic-agent
name: elastic-agent-standalone
namespace: kube-system
labels:
app: elastic-agent
app: elastic-agent-standalone
spec:
selector:
matchLabels:
app: elastic-agent
app: elastic-agent-standalone
template:
metadata:
labels:
app: elastic-agent
app: elastic-agent-standalone
spec:
tolerations:
- key: node-role.kubernetes.io/master
effect: NoSchedule
serviceAccountName: elastic-agent
serviceAccountName: elastic-agent-standalone
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: elastic-agent
- name: elastic-agent-standalone
image: docker.elastic.co/beats/elastic-agent:%VERSION%
args: [
"-c", "/etc/agent.yml",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: elastic-agent
name: elastic-agent-standalone
subjects:
- kind: ServiceAccount
name: elastic-agent
name: elastic-agent-standalone
namespace: kube-system
roleRef:
kind: ClusterRole
name: elastic-agent
name: elastic-agent-standalone
apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
namespace: kube-system
name: elastic-agent
name: elastic-agent-standalone
subjects:
- kind: ServiceAccount
name: elastic-agent
name: elastic-agent-standalone
namespace: kube-system
roleRef:
kind: Role
name: elastic-agent
name: elastic-agent-standalone
apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: elastic-agent-kubeadm-config
name: elastic-agent-standalone-kubeadm-config
namespace: kube-system
subjects:
- kind: ServiceAccount
name: elastic-agent
name: elastic-agent-standalone
namespace: kube-system
roleRef:
kind: Role
name: elastic-agent-kubeadm-config
name: elastic-agent-standalone-kubeadm-config
apiGroup: rbac.authorization.k8s.io
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: elastic-agent
name: elastic-agent-standalone
labels:
k8s-app: elastic-agent
k8s-app: elastic-agent-standalone
rules:
- apiGroups: [""]
resources:
Expand Down Expand Up @@ -50,11 +50,11 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: elastic-agent
name: elastic-agent-standalone
# should be the namespace where elastic-agent is running
namespace: kube-system
labels:
k8s-app: elastic-agent
k8s-app: elastic-agent-standalone
rules:
- apiGroups:
- coordination.k8s.io
Expand All @@ -65,10 +65,10 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: elastic-agent-kubeadm-config
name: elastic-agent-standalone-kubeadm-config
namespace: kube-system
labels:
k8s-app: elastic-agent
k8s-app: elastic-agent-standalone
rules:
- apiGroups: [""]
resources:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: elastic-agent
name: elastic-agent-standalone
namespace: kube-system
labels:
k8s-app: elastic-agent
k8s-app: elastic-agent-standalone

0 comments on commit 289d795

Please sign in to comment.