Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move Antrea Windows log dir #3416

Merged
merged 1 commit into from Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion build/images/scripts/Install-WindowsCNI.ps1
Expand Up @@ -3,7 +3,6 @@ $ErrorActionPreference = "Stop";
mkdir -force /host/var/run/secrets/kubernetes.io/serviceaccount
cp -force /var/run/secrets/kubernetes.io/serviceaccount/* /host/var/run/secrets/kubernetes.io/serviceaccount/
mkdir -force /host/k/antrea/etc/
mkdir -force /host/k/antrea/logs/
cp /k/antrea/cni/* /host/opt/cni/bin/
cp /etc/antrea/antrea-agent.conf /host/k/antrea/etc/

Expand Down
25 changes: 15 additions & 10 deletions build/yamls/antrea-windows.yml
Expand Up @@ -5,12 +5,12 @@ data:
# wins will rename the binary when executing it. So we need to copy the binary everytime before running it.
mkdir -force /host/k/antrea/bin
cp /k/antrea/bin/* /host/k/antrea/bin/
C:/k/antrea/utils/wins.exe cli process run --path /k/antrea/bin/antrea-agent.exe --args "--config=/k/antrea/etc/antrea-agent.conf --logtostderr=false --log_dir=/k/antrea/logs/ --alsologtostderr --log_file_max_size=100 --log_file_max_num=4 --v=0" --envs "KUBERNETES_SERVICE_HOST=$env:KUBERNETES_SERVICE_HOST KUBERNETES_SERVICE_PORT=$env:KUBERNETES_SERVICE_PORT ANTREA_SERVICE_HOST=$env:ANTREA_SERVICE_HOST ANTREA_SERVICE_PORT=$env:ANTREA_SERVICE_PORT NODE_NAME=$env:NODE_NAME KUBE_DNS_SERVICE_HOST=$env:KUBE_DNS_SERVICE_HOST KUBE_DNS_SERVICE_PORT=$env:KUBE_DNS_SERVICE_PORT"
C:/k/antrea/utils/wins.exe cli process run --path /k/antrea/bin/antrea-agent.exe --args "--config=/k/antrea/etc/antrea-agent.conf --logtostderr=false --log_dir=/var/log/antrea/ --alsologtostderr --log_file_max_size=100 --log_file_max_num=4 --v=0" --envs "KUBERNETES_SERVICE_HOST=$env:KUBERNETES_SERVICE_HOST KUBERNETES_SERVICE_PORT=$env:KUBERNETES_SERVICE_PORT ANTREA_SERVICE_HOST=$env:ANTREA_SERVICE_HOST ANTREA_SERVICE_PORT=$env:ANTREA_SERVICE_PORT NODE_NAME=$env:NODE_NAME KUBE_DNS_SERVICE_HOST=$env:KUBE_DNS_SERVICE_HOST KUBE_DNS_SERVICE_PORT=$env:KUBE_DNS_SERVICE_PORT"
kind: ConfigMap
metadata:
labels:
app: antrea
name: antrea-agent-windows-d99k4g5264
name: antrea-agent-windows-kht6m7hthm
namespace: kube-system
---
apiVersion: v1
Expand Down Expand Up @@ -194,8 +194,6 @@ spec:
imagePullPolicy: IfNotPresent
name: antrea-agent
volumeMounts:
- mountPath: /host
name: host
- mountPath: \\.\pipe\rancher_wins
name: wins
- mountPath: /etc/antrea
Expand All @@ -204,6 +202,8 @@ spec:
name: antrea-agent-windows
- mountPath: /host/k/antrea/
name: host-antrea-home
- mountPath: /var/log/antrea/
name: var-log-antrea
hostNetwork: true
initContainers:
- args:
Expand All @@ -224,8 +224,8 @@ spec:
name: host-cni-bin
- mountPath: /host/k/antrea/
name: host-antrea-home
- mountPath: /host
name: host
- mountPath: /host/var/run/secrets/
name: host-secrets-path
nodeSelector:
kubernetes.io/os: windows
priorityClassName: system-node-critical
Expand All @@ -241,7 +241,7 @@ spec:
name: antrea-windows-config
- configMap:
defaultMode: 420
name: antrea-agent-windows-d99k4g5264
name: antrea-agent-windows-kht6m7hthm
name: antrea-agent-windows
- hostPath:
path: /etc/cni/net.d
Expand All @@ -255,11 +255,16 @@ spec:
path: /k/antrea
type: DirectoryOrCreate
name: host-antrea-home
- hostPath:
path: /
name: host
- hostPath:
path: \\.\pipe\rancher_wins
name: wins
- hostPath:
path: /var/log/antrea/
type: DirectoryOrCreate
name: var-log-antrea
Comment on lines +261 to +264
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this is just to ensure the directory is created, we don't actually use the mount?

Copy link
Contributor

@wenyingd wenyingd Mar 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For running Antrea Agent on Windows daemonset case, we don't access the log path inside the management containers. But we should ensure it exists on the host, and pass it to wins to run agent process on the host.

But if we want to access log files inside the management container manually, it should be accessible. I think that is why you also mount it in antrea-agent container, correct? @GraysonWu

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

- hostPath:
path: /var/run/secrets/
type: DirectoryOrCreate
name: host-secrets-path
updateStrategy:
type: RollingUpdate
19 changes: 12 additions & 7 deletions build/yamls/windows/base/agent.yml
Expand Up @@ -35,8 +35,6 @@ spec:
image: antrea-windows
name: antrea-agent
volumeMounts:
- mountPath: /host
name: host
- mountPath: \\.\pipe\rancher_wins
name: wins
- mountPath: /etc/antrea
Expand All @@ -45,6 +43,8 @@ spec:
name: antrea-agent-windows
- mountPath: /host/k/antrea/
name: host-antrea-home
- mountPath: /var/log/antrea/
name: var-log-antrea
hostNetwork: true
initContainers:
- command:
Expand All @@ -64,8 +64,8 @@ spec:
name: host-cni-bin
- mountPath: /host/k/antrea/
name: host-antrea-home
- mountPath: /host
name: host
- mountPath: /host/var/run/secrets/
name: host-secrets-path
nodeSelector:
kubernetes.io/os: windows
priorityClassName: system-node-critical
Expand Down Expand Up @@ -95,12 +95,17 @@ spec:
path: /k/antrea
type: DirectoryOrCreate
name: host-antrea-home
- hostPath:
path: /
name: host
- name: wins
hostPath:
path: \\.\pipe\rancher_wins
type: null
- name: var-log-antrea
hostPath:
path: /var/log/antrea/
type: DirectoryOrCreate
- name: host-secrets-path
hostPath:
path: /var/run/secrets/
type: DirectoryOrCreate
updateStrategy:
type: RollingUpdate
2 changes: 1 addition & 1 deletion build/yamls/windows/base/conf/Run-AntreaAgent.ps1
Expand Up @@ -2,4 +2,4 @@ $ErrorActionPreference = "Stop"
# wins will rename the binary when executing it. So we need to copy the binary everytime before running it.
mkdir -force /host/k/antrea/bin
cp /k/antrea/bin/* /host/k/antrea/bin/
C:/k/antrea/utils/wins.exe cli process run --path /k/antrea/bin/antrea-agent.exe --args "--config=/k/antrea/etc/antrea-agent.conf --logtostderr=false --log_dir=/k/antrea/logs/ --alsologtostderr --log_file_max_size=100 --log_file_max_num=4 --v=0" --envs "KUBERNETES_SERVICE_HOST=$env:KUBERNETES_SERVICE_HOST KUBERNETES_SERVICE_PORT=$env:KUBERNETES_SERVICE_PORT ANTREA_SERVICE_HOST=$env:ANTREA_SERVICE_HOST ANTREA_SERVICE_PORT=$env:ANTREA_SERVICE_PORT NODE_NAME=$env:NODE_NAME KUBE_DNS_SERVICE_HOST=$env:KUBE_DNS_SERVICE_HOST KUBE_DNS_SERVICE_PORT=$env:KUBE_DNS_SERVICE_PORT"
C:/k/antrea/utils/wins.exe cli process run --path /k/antrea/bin/antrea-agent.exe --args "--config=/k/antrea/etc/antrea-agent.conf --logtostderr=false --log_dir=/var/log/antrea/ --alsologtostderr --log_file_max_size=100 --log_file_max_num=4 --v=0" --envs "KUBERNETES_SERVICE_HOST=$env:KUBERNETES_SERVICE_HOST KUBERNETES_SERVICE_PORT=$env:KUBERNETES_SERVICE_PORT ANTREA_SERVICE_HOST=$env:ANTREA_SERVICE_HOST ANTREA_SERVICE_PORT=$env:ANTREA_SERVICE_PORT NODE_NAME=$env:NODE_NAME KUBE_DNS_SERVICE_HOST=$env:KUBE_DNS_SERVICE_HOST KUBE_DNS_SERVICE_PORT=$env:KUBE_DNS_SERVICE_PORT"
GraysonWu marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion hack/windows/Helper.psm1
Expand Up @@ -262,7 +262,7 @@ function Start-AntreaAgent {
$AntreaAgent = "$AntreaHome\bin\antrea-agent.exe"
$AntreaAgentConfigPath = "$AntreaHome\etc\antrea-agent.conf"
if ($LogDir -eq "") {
$LogDir = "$AntreaHome\logs"
$LogDir = "c:\var\log\antrea"
}
New-DirectoryIfNotExist $LogDir
[Environment]::SetEnvironmentVariable("NODE_NAME", (hostname).ToLower())
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/logdir/logdir_windows.go
Expand Up @@ -17,4 +17,4 @@

package logdir

const antreaWellKnownLogDir = `C:\k\antrea\logs`
const antreaWellKnownLogDir = `C:\var\log\antrea`