-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add agent fleet enrolment k8s manifest (#26566)
* Add manifests for agent automatic enrolment to fleet Signed-off-by: MichaelKatsoulis <[email protected]>
- Loading branch information
1 parent
6b0c391
commit caecb83
Showing
6 changed files
with
415 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
209 changes: 209 additions & 0 deletions
209
deploy/kubernetes/elastic-agent-managed-kubernetes.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,209 @@ | ||
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 | ||
env: | ||
- name: FLEET_ENROLL | ||
value: "1" | ||
# Set to true in case of insecure or unverified HTTP | ||
- name: FLEET_INSECURE | ||
value: false | ||
# The ip:port pair of fleet server | ||
- name: FLEET_URL | ||
value: "https://fleet-server:8220" | ||
- name: KIBANA_HOST | ||
value: "http://kibana:5601" | ||
- name: KIBANA_FLEET_USERNAME | ||
value: "elastic" | ||
- name: KIBANA_FLEET_PASSWORD | ||
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: 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: 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: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: elastic-agent | ||
subjects: | ||
- kind: ServiceAccount | ||
name: elastic-agent | ||
namespace: kube-system | ||
roleRef: | ||
kind: ClusterRole | ||
name: elastic-agent | ||
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: RoleBinding | ||
metadata: | ||
name: elastic-agent-kubeadm-config | ||
namespace: kube-system | ||
subjects: | ||
- kind: ServiceAccount | ||
name: elastic-agent | ||
namespace: kube-system | ||
roleRef: | ||
kind: Role | ||
name: elastic-agent-kubeadm-config | ||
apiGroup: rbac.authorization.k8s.io | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: elastic-agent | ||
labels: | ||
k8s-app: elastic-agent | ||
rules: | ||
- apiGroups: [""] | ||
resources: | ||
- nodes | ||
- namespaces | ||
- events | ||
- pods | ||
- services | ||
- configmaps | ||
verbs: ["get", "list", "watch"] | ||
# Enable this rule only if planing to use kubernetes_secrets provider | ||
#- apiGroups: [""] | ||
# resources: | ||
# - secrets | ||
# verbs: ["get"] | ||
- apiGroups: ["extensions"] | ||
resources: | ||
- replicasets | ||
verbs: ["get", "list", "watch"] | ||
- apiGroups: ["apps"] | ||
resources: | ||
- statefulsets | ||
- deployments | ||
- replicasets | ||
verbs: ["get", "list", "watch"] | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- nodes/stats | ||
verbs: | ||
- get | ||
- apiGroups: [ "batch" ] | ||
resources: | ||
- jobs | ||
verbs: [ "get", "list", "watch" ] | ||
# required for apiserver | ||
- nonResourceURLs: | ||
- "/metrics" | ||
verbs: | ||
- get | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: elastic-agent | ||
# should be the namespace where elastic-agent is running | ||
namespace: kube-system | ||
labels: | ||
k8s-app: elastic-agent | ||
rules: | ||
- apiGroups: | ||
- coordination.k8s.io | ||
resources: | ||
- leases | ||
verbs: ["get", "create", "update"] | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: Role | ||
metadata: | ||
name: elastic-agent-kubeadm-config | ||
namespace: kube-system | ||
labels: | ||
k8s-app: elastic-agent | ||
rules: | ||
- apiGroups: [""] | ||
resources: | ||
- configmaps | ||
resourceNames: | ||
- kubeadm-config | ||
verbs: ["get"] | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: elastic-agent | ||
namespace: kube-system | ||
labels: | ||
k8s-app: elastic-agent | ||
--- |
82 changes: 82 additions & 0 deletions
82
deploy/kubernetes/elastic-agent-managed/elastic-agent-managed-daemonset.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
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 | ||
env: | ||
- name: FLEET_ENROLL | ||
value: "1" | ||
# Set to true in case of insecure or unverified HTTP | ||
- name: FLEET_INSECURE | ||
value: false | ||
# The ip:port pair of fleet server | ||
- name: FLEET_URL | ||
value: "https://fleet-server:8220" | ||
- name: KIBANA_HOST | ||
value: "http://kibana:5601" | ||
- name: KIBANA_FLEET_USERNAME | ||
value: "elastic" | ||
- name: KIBANA_FLEET_PASSWORD | ||
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: 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: 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 |
40 changes: 40 additions & 0 deletions
40
deploy/kubernetes/elastic-agent-managed/elastic-agent-managed-role-binding.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: elastic-agent | ||
subjects: | ||
- kind: ServiceAccount | ||
name: elastic-agent | ||
namespace: kube-system | ||
roleRef: | ||
kind: ClusterRole | ||
name: elastic-agent | ||
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: RoleBinding | ||
metadata: | ||
name: elastic-agent-kubeadm-config | ||
namespace: kube-system | ||
subjects: | ||
- kind: ServiceAccount | ||
name: elastic-agent | ||
namespace: kube-system | ||
roleRef: | ||
kind: Role | ||
name: elastic-agent-kubeadm-config | ||
apiGroup: rbac.authorization.k8s.io |
Oops, something went wrong.