Skip to content

Commit a5b4011

Browse files
authored
Merge pull request #2 from gianlucam76/documentation
Modify README
2 parents 4f843ea + e293e73 commit a5b4011

File tree

5 files changed

+90
-12
lines changed

5 files changed

+90
-12
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,11 @@ create-cluster: $(KIND) $(KUBECTL) ## Create a new kind cluster designed for dev
147147
@echo "apply PersistentVolumeClaim"
148148
$(KUBECTL) apply -f test/pvc.yaml
149149

150-
$(KUBECTL) apply -f test/fv/configmap.yaml
150+
$(KUBECTL) apply -f test/configmap.yaml
151151

152152
@echo 'Load k8s-collector image into cluster'
153153
$(MAKE) load-image
154-
$(KUBECTL) apply -f k8s/collector.yaml
154+
$(KUBECTL) apply -f test/collector.yaml
155155

156156
.PHONY: delete-cluster
157157
delete-cluster: $(KIND) ## Deletes the kind cluster $(CONTROL_CLUSTER_NAME)

README.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,14 @@
22
A Kubernetes Job to collect resources, logs and events from a Kubernetes cluster.
33
k8s-collector is a Job that can collect both resources (YAMLs) and logs when created.
44

5-
`k8s/collector.yaml` contains the YAML to run it. Please be aware you will have to modify Job volume mounts.
6-
It expects two argurments:
5+
[k8s/collector.yaml](https://raw.githubusercontent.com/gianlucam76/k8s_collector/main/k8s/collector.yaml) contains the YAML to run it. Please be aware you will have to modify Job volume mounts (as it will store logs and resources in tmp directory).
6+
If you want to try it out on [Kind](https://kind.sigs.k8s.io) cluster, then you can use this YAML which uses a persistent volume provided by KinD
7+
[test/fv/collector.yaml](https://raw.githubusercontent.com/gianlucam76/k8s_collector/main/test/fv/collector.yaml)
78

8-
1. config-map => this is the name of the ConfigMap that contain the configuration on which logs/resources to collect. This README contains an example for such ConfigMap. ConfigMap must be in the same namespae of the Job.
9-
2. dir => this is the directory when all collected resources and logs will be stored
9+
```k8s-collector``` expects two argurments:
10+
11+
1. dir => this is the directory when all collected resources and logs will be stored
12+
2. config-map => this is the name of the ConfigMap that contain the configuration on which logs/resources to collect. This README contains an example for such ConfigMap. ConfigMap must be in the same namespae of the Job.
1013

1114
```yaml
1215
apiVersion: batch/v1

k8s/collector.yaml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,13 @@ spec:
3232
- /k8s-collector
3333
args:
3434
- --config-map=k8s-collector
35-
- --dir=/collection
35+
- --dir=/tmp
3636
volumeMounts:
37-
- mountPath: /collection
38-
name: collection
3937
- mountPath: /tmp
4038
name: tmp
4139
volumes:
4240
- emptyDir: {}
4341
name: tmp
44-
- name: collection
45-
persistentVolumeClaim:
46-
claimName: standard
4742
---
4843
kind: ClusterRole
4944
apiVersion: rbac.authorization.k8s.io/v1

test/collector.yaml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
apiVersion: v1
2+
kind: Namespace
3+
metadata:
4+
name: default
5+
---
6+
apiVersion: v1
7+
kind: ServiceAccount
8+
metadata:
9+
name: k8s-collector
10+
namespace: default
11+
---
12+
apiVersion: batch/v1
13+
kind: Job
14+
metadata:
15+
name: k8s-collector
16+
namespace: default
17+
spec:
18+
template:
19+
spec:
20+
restartPolicy: Never
21+
serviceAccountName: k8s-collector
22+
containers:
23+
- name: k8s-collector
24+
image: projectsveltos/k8s-collector-amd64:main
25+
imagePullPolicy: IfNotPresent
26+
env:
27+
- name: COLLECTOR_NAMESPACE
28+
valueFrom:
29+
fieldRef:
30+
fieldPath: metadata.namespace
31+
command:
32+
- /k8s-collector
33+
args:
34+
- --config-map=k8s-collector
35+
- --dir=/collection
36+
volumeMounts:
37+
- mountPath: /collection
38+
name: collection
39+
- mountPath: /tmp
40+
name: tmp
41+
volumes:
42+
- emptyDir: {}
43+
name: tmp
44+
- name: collection
45+
persistentVolumeClaim:
46+
claimName: standard
47+
---
48+
kind: ClusterRole
49+
apiVersion: rbac.authorization.k8s.io/v1
50+
metadata:
51+
name: k8s-collector
52+
rules:
53+
- apiGroups:
54+
- "*"
55+
resources:
56+
- "*"
57+
verbs:
58+
- get
59+
- list
60+
- apiGroups:
61+
- "batch/v1"
62+
verbs:
63+
- "get"
64+
- "list"
65+
- "watch"
66+
resources:
67+
- "pods/logs"
68+
---
69+
apiVersion: rbac.authorization.k8s.io/v1
70+
kind: ClusterRoleBinding
71+
metadata:
72+
name: k8s-collector
73+
roleRef:
74+
apiGroup: rbac.authorization.k8s.io
75+
kind: ClusterRole
76+
name: k8s-collector
77+
subjects:
78+
- kind: ServiceAccount
79+
name: k8s-collector
80+
namespace: default

0 commit comments

Comments
 (0)