Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
FROM mcr.microsoft.com/windows/servercore:ltsc2019

SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

RUN Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
RUN choco install python git -y

RUN python -m pip install --upgrade pip
RUN pip install --upgrade --no-cache-dir \
orjson==3.6.8 \
zstandard==0.17.0 \
lz4==4.0.0 \
requests==2.25.1 \
docker==4.1.0 \
psutil

WORKDIR /Scalyr
ADD . /Scalyr
ADD ./docker/k8s-config/ /Scalyr/config

RUN Get-Content /Scalyr/certs/*.pem | Set-Content /Scalyr/certs/ca_certs.crt
RUN "[Environment]::SetEnvironmentVariable('PYTHONUTF8', '1', 'Machine')"
ENV SCALYR_STDOUT_SEVERITY ERROR
ENV SCALYR_K8S_KUBELET_CA_CERT /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
ENV SCALYR_K8S_SERVICE_ACCOUNT_CERT /var/run/secrets/kubernetes.io/serviceaccount/ca.crt
CMD ["python", "-X", "utf8", "/Scalyr/scalyr_agent/agent_main.py", "--no-fork", "--no-change-user", "--verbose", "start"]
107 changes: 107 additions & 0 deletions k8s-windows/scalyr-windows-agent.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
apiVersion: v1
kind: ConfigMap
metadata:
labels:
app: windows-scalyr-agent
name: winscaler-config-agent-d
namespace: scalyr
data:
"kubernetes.json": |
{
"monitors":[
{
"module": "scalyr_agent.builtin_monitors.kubernetes_events_monitor"
},
{
"module": "scalyr_agent.builtin_monitors.kubernetes_monitor",
"report_container_metrics": true,
"report_k8s_metrics": true
}
]
}
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
labels:
app: windows-scalyr-agent
name: windows-scalyr-agent
namespace: scalyr
spec:
selector:
matchLabels:
app: windows-scalyr-agent
template:
metadata:
labels:
app: windows-scalyr-agent
spec:
containers:
- name: winscaler
image: winscaler:latest
env:
- name: SCALYR_SERVER
value: agent.scalyr.com
- name: SCALYR_API_KEY
value: <putyourapikeyhere>
- name: SCALYR_K8S_CLUSTER_NAME
value: winscaler-test
- name: SCALYR_K8S_VERIFY_KUBELET_QUERIES
value: "true"
- name: SCALYR_K8S_API_URL
value: https://kubernetes.default.svc.cluster.local
- name: "SCALYR_K8S_NODE_NAME"
valueFrom:
fieldRef:
fieldPath: "spec.nodeName"
apiVersion: "v1"
- name: "SCALYR_K8S_POD_NAME"
valueFrom:
fieldRef:
fieldPath: "metadata.name"
apiVersion: "v1"
- name: "SCALYR_K8S_POD_NAMESPACE"
valueFrom:
fieldRef:
fieldPath: "metadata.namespace"
apiVersion: "v1"
- name: "SCALYR_K8S_POD_UID"
valueFrom:
fieldRef:
fieldPath: "metadata.uid"
apiVersion: "v1"
- name: "SCALYR_K8S_KUBELET_HOST_IP"
valueFrom:
fieldRef:
fieldPath: "status.hostIP"
apiVersion: "v1"
volumeMounts:
- name: varlogpods
mountPath: "/var/log/pods"
readOnly: true
- name: varlogcontainers
mountPath: "/var/log/containers"
readOnly: true
- name: "scalyr-config-agent-d"
mountPath: "/etc/scalyr-agent-2/agent.d"
nodeSelector:
kubernetes.io/os: windows
tolerations:
- key: "kubernetes.azure.com/scalesetpriority"
operator: "Equal"
value: "spot"
effect: "NoSchedule"
volumes:
- name: "varlogpods"
hostPath:
path: "/var/log/pods"
- name: "varlogcontainers"
hostPath:
path: "/var/log/containers"
- name: "scalyr-config-agent-d"
configMap:
name: winscaler-config-agent-d
defaultMode: 0600
dnsPolicy: "ClusterFirst"
automountServiceAccountToken: true
serviceAccountName: scalyr-scalyr-agent-sa # use service account from default scalyr helm installation
5 changes: 4 additions & 1 deletion scalyr_agent/platform_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,10 @@ def is_agent_running(self, fail_if_running=False, fail_if_not_running=False):
win32service.SERVICE_RUNNING,
win32service.SERVICE_START_PENDING,
)

except:
# When running the script without a service on windows, this will fail
# If we return false here, we can use it without a service
return False
finally:
if hs is not None:
win32service.CloseServiceHandle(hs)
Expand Down