部署Daemonset
修改node-exporter-Daemonset.yaml
文件中的信息,然后应用YAML文件
cat > /opt/k8s/node-exporter/node-exporter-Daemonset.yaml <<EOF
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: node-exporter
labels:
app: node-exporter
spec:
selector:
matchLabels:
app: node-exporter
template:
metadata:
labels:
app: node-exporter
spec:
hostNetwork: true
hostPID: true
containers:
- name: node-exporter
image: prom/node-exporter:v1.7.0
args:
- '--path.rootfs=/host'
ports:
- containerPort: 9100
hostPort: 9100
name: http
volumeMounts:
- name: rootfs
mountPath: /host
readOnly: true
volumes:
- name: rootfs
hostPath:
path: /
EOF
kubectl apply -f node-exporter-Daemonset.yaml
kubectl get Daemonset
部署Service
修改node-exporter-Service.yaml
文件中的信息,然后应用YAML文件
cat > /opt/k8s/node-exporter/node-exporter-Service.yaml <<EOF
apiVersion: v1
kind: Service
metadata:
name: node-exporter-service
spec:
type: NodePort
ports:
- port: 9100
targetPort: 9100
nodePort: 30010
selector:
app: node-exporter
EOF
kubectl apply -f node-exporter-Service.yaml
kubectl get Service