Skip to content

Commit

Permalink
Add agent's direcotry in k8s manifest generator (#24987)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrsMark authored Apr 12, 2021
1 parent 1636325 commit 8398f8b
Show file tree
Hide file tree
Showing 4 changed files with 123 additions and 108 deletions.
2 changes: 1 addition & 1 deletion deploy/kubernetes/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ALL=filebeat metricbeat auditbeat heartbeat
ALL=filebeat metricbeat auditbeat heartbeat elastic-agent-standalone elastic-agent
BEAT_VERSION=$(shell head -n 1 ../../libbeat/docs/version.asciidoc | cut -c 17- )

.PHONY: all $(ALL)
Expand Down
1 change: 0 additions & 1 deletion deploy/kubernetes/elastic-agent-kubernetes.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,88 +1,3 @@
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: elastic-agent
namespace: kube-system
labels:
app: elastic-agent
spec:
selector:
matchLabels:
app: elastic-agent
template:
metadata:
labels:
app: elastic-agent
spec:
tolerations:
- key: node-role.kubernetes.io/master
effect: NoSchedule
serviceAccountName: elastic-agent
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: elastic-agent
image: docker.elastic.co/beats/elastic-agent:8.0.0
args: ["-c", "/etc/agent.yml", "-e"]
env:
- name: ES_USERNAME
value: "elastic"
- name: ES_PASSWORD
value: ""
- name: ES_HOST
value: ""
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
securityContext:
runAsUser: 0
resources:
limits:
memory: 200Mi
requests:
cpu: 100m
memory: 100Mi
volumeMounts:
- name: datastreams
mountPath: /etc/agent.yml
readOnly: true
subPath: agent.yml
- name: proc
mountPath: /hostfs/proc
readOnly: true
- name: cgroup
mountPath: /hostfs/sys/fs/cgroup
readOnly: true
- name: varlibdockercontainers
mountPath: /var/lib/docker/containers
readOnly: true
- name: varlog
mountPath: /var/log
readOnly: true
volumes:
- name: datastreams
configMap:
defaultMode: 0640
name: agent-node-datastreams
- name: proc
hostPath:
path: /proc
- name: cgroup
hostPath:
path: /sys/fs/cgroup
- name: varlibdockercontainers
hostPath:
path: /var/lib/docker/containers
- name: varlog
hostPath:
path: /var/log
---
apiVersion: v1
kind: ConfigMap
metadata:
Expand Down Expand Up @@ -383,7 +298,7 @@ data:
# condition: ${kubernetes.pod.labels.app} == 'redis'
---
apiVersion: apps/v1
kind: Deployment
kind: DaemonSet
metadata:
name: elastic-agent
namespace: kube-system
Expand All @@ -398,11 +313,19 @@ spec:
labels:
app: elastic-agent
spec:
tolerations:
- key: node-role.kubernetes.io/master
effect: NoSchedule
serviceAccountName: elastic-agent
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: elastic-agent
image: docker.elastic.co/beats/elastic-agent:8.0.0
args: ["-c", "/etc/agent.yml", "-e"]
args: [
"-c", "/etc/agent.yml",
"-e",
]
env:
- name: ES_USERNAME
value: "elastic"
Expand All @@ -414,11 +337,10 @@ spec:
valueFrom:
fieldRef:
fieldPath: spec.nodeName
# this is needed because we cannot use hostNetwork
- name: HOSTNAME
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
fieldPath: metadata.name
securityContext:
runAsUser: 0
resources:
Expand All @@ -432,11 +354,35 @@ spec:
mountPath: /etc/agent.yml
readOnly: true
subPath: agent.yml
- name: proc
mountPath: /hostfs/proc
readOnly: true
- name: cgroup
mountPath: /hostfs/sys/fs/cgroup
readOnly: true
- name: varlibdockercontainers
mountPath: /var/lib/docker/containers
readOnly: true
- name: varlog
mountPath: /var/log
readOnly: true
volumes:
- name: datastreams
configMap:
defaultMode: 0640
name: agent-deployment-datastreams
name: agent-node-datastreams
- name: proc
hostPath:
path: /proc
- name: cgroup
hostPath:
path: /sys/fs/cgroup
- name: varlibdockercontainers
hostPath:
path: /var/lib/docker/containers
- name: varlog
hostPath:
path: /var/log
---
apiVersion: v1
kind: ConfigMap
Expand Down Expand Up @@ -600,6 +546,65 @@ data:
- 'kube-state-metrics:8080'
period: 10s
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: elastic-agent
namespace: kube-system
labels:
app: elastic-agent
spec:
selector:
matchLabels:
app: elastic-agent
template:
metadata:
labels:
app: elastic-agent
spec:
serviceAccountName: elastic-agent
containers:
- name: elastic-agent
image: docker.elastic.co/beats/elastic-agent:8.0.0
args: [
"-c", "/etc/agent.yml",
"-e",
]
env:
- name: ES_USERNAME
value: "elastic"
- name: ES_PASSWORD
value: ""
- name: ES_HOST
value: ""
- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
# this is needed because we cannot use hostNetwork
- name: HOSTNAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
securityContext:
runAsUser: 0
resources:
limits:
memory: 200Mi
requests:
cpu: 100m
memory: 100Mi
volumeMounts:
- name: datastreams
mountPath: /etc/agent.yml
readOnly: true
subPath: agent.yml
volumes:
- name: datastreams
configMap:
defaultMode: 0640
name: agent-deployment-datastreams
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
Expand All @@ -614,6 +619,20 @@ roleRef:
apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
namespace: kube-system
name: elastic-agent
subjects:
- kind: ServiceAccount
name: elastic-agent
namespace: kube-system
roleRef:
kind: Role
name: elastic-agent
apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: elastic-agent
Expand Down Expand Up @@ -655,20 +674,6 @@ rules:
- get
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
namespace: kube-system
name: elastic-agent
subjects:
- kind: ServiceAccount
name: elastic-agent
namespace: kube-system
roleRef:
kind: Role
name: elastic-agent
apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: elastic-agent
Expand All @@ -690,4 +695,3 @@ metadata:
labels:
k8s-app: elastic-agent
---

Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ spec:
- name: cgroup
mountPath: /hostfs/sys/fs/cgroup
readOnly: true
- name: varlibdockercontainers
mountPath: /var/lib/docker/containers
readOnly: true
- name: varlog
mountPath: /var/log
readOnly: true
volumes:
- name: datastreams
configMap:
Expand All @@ -72,3 +78,9 @@ spec:
- name: cgroup
hostPath:
path: /sys/fs/cgroup
- name: varlibdockercontainers
hostPath:
path: /var/lib/docker/containers
- name: varlog
hostPath:
path: /var/log

0 comments on commit 8398f8b

Please sign in to comment.