-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.yaml
145 lines (145 loc) · 3.83 KB
/
install.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# Copyright 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: dranet
rules:
- apiGroups:
- ""
resources:
- nodes
verbs:
- get
# TODO make it more granular
- apiGroups:
- "resource.k8s.io"
resources: ["*"]
verbs: ["*"]
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: dranet
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: dranet
subjects:
- kind: ServiceAccount
name: dranet
namespace: kube-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: dranet
namespace: kube-system
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: dranet
namespace: kube-system
labels:
tier: node
app: dranet
k8s-app: dranet
spec:
selector:
matchLabels:
app: dranet
template:
metadata:
labels:
tier: node
app: dranet
k8s-app: dranet
spec:
hostNetwork: true
tolerations:
- operator: Exists
effect: NoSchedule
serviceAccountName: dranet
hostPID: true
initContainers:
- name: enable-nri
image: busybox:stable
volumeMounts:
- mountPath: /etc
name: etc
securityContext:
privileged: true
command:
- /bin/sh
- -c
- |
set -o errexit
set -o pipefail
set -o nounset
set -x
if grep -q "io.containerd.nri.v1.nri" /etc/containerd/config.toml
then
echo "containerd config contains NRI reference already; taking no action"
else
echo "containerd config does not mention NRI, thus enabling it";
printf '%s\n' "[plugins.\"io.containerd.nri.v1.nri\"]" " disable = false" " disable_connections = false" " plugin_config_path = \"/etc/nri/conf.d\"" " plugin_path = \"/opt/nri/plugins\"" " plugin_registration_timeout = \"5s\"" " plugin_request_timeout = \"5s\"" " socket_path = \"/var/run/nri/nri.sock\"" >> /etc/containerd/config.toml
echo "restarting containerd"
nsenter -t 1 -m -u -i -n -p -- systemctl restart containerd
fi
containers:
- name: dranet
args:
- /dranet
- --v=4
image: ghcr.io/google/dranet:stable
resources:
requests:
cpu: "100m"
memory: "50Mi"
securityContext:
capabilities:
add: ["NET_ADMIN", "SYS_ADMIN"]
readinessProbe:
httpGet:
path: /healthz
port: 9177
volumeMounts:
- name: device-plugin
mountPath: /var/lib/kubelet/plugins
- name: plugin-registry
mountPath: /var/lib/kubelet/plugins_registry
- name: nri-plugin
mountPath: /var/run/nri
- name: netns
mountPath: /var/run/netns
mountPropagation: HostToContainer
volumes:
- name: device-plugin
hostPath:
path: /var/lib/kubelet/plugins
- name: plugin-registry
hostPath:
path: /var/lib/kubelet/plugins_registry
- name: nri-plugin
hostPath:
path: /var/run/nri
- name: netns
hostPath:
path: /var/run/netns
- name: etc
hostPath:
path: /etc
---