-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rpm: provide systemd and microshift defaults (#63)
* rpm: provide systemd and microshift defaults Signed-off-by: Benedikt Bongartz <[email protected]> * fix: wrong place of microshift manifests Signed-off-by: Benedikt Bongartz <[email protected]> * rpm: retrieve config files from source0 Signed-off-by: Benedikt Bongartz <[email protected]> * fix collector start script Signed-off-by: Benedikt Bongartz <[email protected]> * rename default config Signed-off-by: Benedikt Bongartz <[email protected]> * add readme entry * spec: install launch script more explicit Signed-off-by: Benedikt Bongartz <[email protected]> --------- Signed-off-by: Benedikt Bongartz <[email protected]>
- Loading branch information
Showing
9 changed files
with
294 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
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,32 @@ | ||
--- | ||
receivers: | ||
otlp/microshift: | ||
protocols: | ||
grpc: | ||
# TODO: Its not going to work if the default ip range in microshift got modified | ||
endpoint: "10.44.0.0:54317" | ||
journald: | ||
units: | ||
priority: info | ||
|
||
hostmetrics: | ||
root_path: / | ||
collection_interval: 10s | ||
scrapers: | ||
cpu: | ||
memory: | ||
hostmetrics/disk: | ||
root_path: / | ||
collection_interval: 30s | ||
scrapers: | ||
disk: | ||
filesystem: | ||
|
||
processors: | ||
batch: | ||
resourcedetection/system: | ||
detectors: ["system"] | ||
|
||
exporters: | ||
debug: | ||
|
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
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
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 |
---|---|---|
|
@@ -19,10 +19,14 @@ License: Apache-2.0 | |
|
||
Source0: %{name}-%{version}.tar.gz | ||
|
||
BuildRequires: systemd | ||
BuildRequires: %{?go_compiler:compiler(go-compiler)}%{!?go_compiler:golang} | ||
BuildRequires: binutils | ||
BuildRequires: git | ||
|
||
Requires(pre): /usr/sbin/useradd, /usr/bin/getent | ||
Requires(postun): /usr/sbin/userdel | ||
|
||
%description | ||
%{common_description} | ||
|
||
|
@@ -33,22 +37,68 @@ mkdir -p _build/bin | |
%setup -q -n %{name}-%{version} | ||
|
||
%build | ||
|
||
go build -v -buildmode pie -mod vendor -o %{gobuilddir}/bin/opentelemetry-collector | ||
|
||
%define debug_package %{nil} | ||
|
||
%install | ||
# create expected directory layout | ||
mkdir -p %{buildroot}%{_sysconfdir}/opentelemetry-collector | ||
mkdir -p %{buildroot}%{_sysconfdir}/opentelemetry-collector/configs | ||
mkdir -p %{buildroot}%{_sysconfdir}/microshift/manifests/opentelemetry-collector/ | ||
mkdir -p %{buildroot}%{_unitdir} | ||
|
||
# install files | ||
install -p -m 0644 ./00-default-receivers.yaml %{buildroot}%{_sysconfdir}/opentelemetry-collector/configs/00-default-receivers.yaml | ||
install -p -m 0644 ./opentelemetry-collector.service %{buildroot}%{_unitdir}/%{name}.service | ||
install -p -m 0644 ./microshift-opentelemetry-gateway.yaml %{buildroot}%{_sysconfdir}/microshift/manifests/opentelemetry-collector/manifest.yaml | ||
install -p -m 0644 ./kustomization.yaml %{buildroot}%{_sysconfdir}/microshift/manifests/opentelemetry-collector/kustomization.yaml | ||
|
||
install -m 0755 -vd %{buildroot}%{_bindir} | ||
install -m 0755 -vp %{gobuilddir}/bin/* %{buildroot}%{_bindir}/ | ||
install -m 0755 -p ./opentelemetry-collector-with-options %{buildroot}%{_bindir}/ | ||
|
||
%pre | ||
/usr/bin/getent group observability > /dev/null || /usr/sbin/groupadd -r observability | ||
/usr/bin/getent passwd observability > /dev/null || /usr/sbin/useradd -r -M -s /sbin/nologin -g observability -G systemd-journal observability | ||
|
||
%postun | ||
/usr/sbin/userdel observability | ||
|
||
%post | ||
/bin/systemctl --system daemon-reload 2>&1 | ||
|
||
%preun | ||
if [ $1 -eq 0 ]; then | ||
/bin/systemctl --quiet stop %{name}.service | ||
/bin/systemctl --quiet disable %{name}.service | ||
fi | ||
|
||
%posttrans | ||
/bin/systemctl is-enabled %{name}.service >/dev/null 2>&1 | ||
if [ $? -eq 0 ]; then | ||
/bin/systemctl restart %{name}.service >/dev/null | ||
fi | ||
|
||
%check | ||
%gocheck | ||
|
||
%files | ||
%{_unitdir}/%{name}.service | ||
%{_sysconfdir}/opentelemetry-collector/configs/00-default-receivers.yaml | ||
%{_sysconfdir}/microshift/manifests/opentelemetry-collector/manifest.yaml | ||
%{_sysconfdir}/microshift/manifests/opentelemetry-collector/kustomization.yaml | ||
|
||
%license %{golicenses} | ||
%doc %{godocs} | ||
%{_bindir}/* | ||
|
||
%changelog | ||
* Fri Apr 12 2024 Benedikt Bongartz <[email protected]> - 0.95.0 | ||
- add observability user that is part of the systemd-journal group | ||
- add opentelemetry collector config folder (`/etc/opentelemetry-collector/configs`) | ||
- add opentelemetry collector default config | ||
- add microshift manifests | ||
* Thu Feb 1 21:59:10 CET 2024 Nina Olear <[email protected]> - 0.93.4 | ||
- First package for Copr |
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,6 @@ | ||
--- | ||
apiVersion: kustomize.config.k8s.io/v1beta1 | ||
kind: Kustomization | ||
|
||
resources: | ||
- manifest.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,141 @@ | ||
--- | ||
apiVersion: v1 | ||
kind: Namespace | ||
metadata: | ||
name: observability | ||
--- | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: opentelemetry-gateway-config | ||
namespace: observability | ||
data: | ||
# TODO: remove hostnetwork-v2 scc and flip exporter config fromlocalhost to ${env:K8S_HOST_IP}. | ||
config.yaml: | | ||
receivers: | ||
kubeletstats: | ||
collection_interval: 20s | ||
auth_type: "serviceAccount" | ||
endpoint: "https://${env:K8S_HOST_IP}:10250" | ||
insecure_skip_verify: true | ||
otlp: | ||
protocols: | ||
grpc: | ||
http: | ||
processors: | ||
batch: | ||
send_batch_size: 10000 | ||
timeout: 10s | ||
exporters: | ||
otlp/host: | ||
endpoint: ${env:K8S_HOST_IP}:54317 | ||
tls: | ||
insecure: true | ||
insecure_skip_verify: true | ||
service: | ||
pipelines: | ||
traces: | ||
receivers: [otlp] | ||
processors: [batch] | ||
exporters: [otlp/host] | ||
metrics: | ||
receivers: [otlp, kubeletstats] | ||
processors: [batch] | ||
exporters: [otlp/host] | ||
logs: | ||
receivers: [otlp] | ||
processors: [batch] | ||
exporters: [otlp/host] | ||
--- | ||
apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: opentelemetry-gateway | ||
namespace: observability | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRole | ||
metadata: | ||
name: otel-apiserver | ||
rules: | ||
- apiGroups: [''] | ||
resources: ['nodes/stats'] | ||
verbs: ['get', 'watch', 'list'] | ||
--- | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: otel-collector | ||
roleRef: | ||
apiGroup: rbac.authorization.k8s.io | ||
kind: ClusterRole | ||
name: otel-apiserver | ||
subjects: | ||
- kind: ServiceAccount | ||
name: opentelemetry-gateway | ||
namespace: observability | ||
--- | ||
apiVersion: apps/v1 | ||
kind: DaemonSet | ||
metadata: | ||
name: opentelemetry-gateway | ||
namespace: observability | ||
labels: | ||
app: opentelemetry-gateway | ||
spec: | ||
selector: | ||
matchLabels: | ||
app: opentelemetry-gateway | ||
template: | ||
metadata: | ||
labels: | ||
app: opentelemetry-gateway | ||
spec: | ||
serviceAccountName: opentelemetry-gateway | ||
nodeSelector: | ||
kubernetes.io/os: linux | ||
containers: | ||
- name: opentelemetry-collector | ||
image: ghcr.io/os-observability/redhat-opentelemetry-collector/redhat-opentelemetry-collector:main | ||
command: ["/otelcol", "--config=/etc/opentelemetry/config.yaml"] | ||
# TODO: enable after 3.1 release | ||
# image: registry.redhat.io/rhosdt/opentelemetry-collector-rhel8:0.93.0 | ||
# command: ["/go/bin/otelcol-linux", "--config=/etc/opentelemetry/config.yaml"] | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
runAsNonRoot: true | ||
capabilities: | ||
drop: | ||
- ALL | ||
seccompProfile: | ||
type: RuntimeDefault | ||
volumeMounts: | ||
- name: config-volume | ||
mountPath: /etc/opentelemetry | ||
env: | ||
- name: K8S_HOST_IP | ||
valueFrom: | ||
fieldRef: | ||
fieldPath: status.hostIP | ||
volumes: | ||
- name: config-volume | ||
configMap: | ||
name: opentelemetry-gateway-config | ||
--- | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: gateway | ||
namespace: observability | ||
spec: | ||
ports: | ||
- name: http-otlp | ||
port: 4318 | ||
targetPort: 54318 | ||
protocol: TCP | ||
- name: grpc-otlp | ||
port: 4317 | ||
targetPort: 54317 | ||
protocol: TCP | ||
selector: | ||
app: opentelemetry-gateway |
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,16 @@ | ||
#!/bin/bash | ||
|
||
PATCH_DIR="/etc/opentelemetry-collector/configs" | ||
|
||
if [ -d "$PATCH_DIR" ]; then | ||
PATCH_FILES=$(ls "$PATCH_DIR"/*.yaml 2>/dev/null | sort) | ||
if [ -n "$PATCH_FILES" ]; then | ||
CONFIG_OPTIONS="" | ||
|
||
for PATCH_FILE in $PATCH_FILES; do | ||
CONFIG_OPTIONS+=" --config file:$PATCH_FILE" | ||
done | ||
fi | ||
fi | ||
|
||
/usr/bin/opentelemetry-collector $CONFIG_OPTIONS |
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,14 @@ | ||
[Unit] | ||
Description=RHDE Observability Agent | ||
After=network.target | ||
|
||
[Service] | ||
Type=simple | ||
ExecStart=/usr/bin/opentelemetry-collector-with-options | ||
User=observability | ||
Group=observability | ||
Restart=on-failure | ||
RestartSec=30 | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
ab5d0c3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We were not able to find or create Copr project
packit/os-observability-redhat-opentelemetry-collector-main
specified in the config with the following error:Please check your configuration for:
@
)