azure - 在 Azure Kubernetes 服务上部署时出现 Demonset 错误
问题描述
我是 Kubernetes 世界的新手,我正在尝试在 Azure Kubernetes 服务(AKS)上部署“Filebeat”演示,但遇到以下错误,请帮助我:
我的代码是从https://github.com/elastic/beats/tree/master/deploy/kubernetes/filebeat
下面是试图执行的代码。
filebeat-configmap.yaml
---
apiVersion: v1
kind: ConfigMap
metadata:
name: filebeat-config
namespace: kube-system
labels:
k8s-app: filebeat
data:
filebeat.yml: |-
filebeat.inputs:
- type: container
paths:
- /var/log/containers/*.log
processors:
- add_kubernetes_metadata:
host: ${NODE_NAME}
matchers:
- logs_path:
logs_path: "/var/log/containers/"
# To enable hints based autodiscover, remove `filebeat.inputs` configuration and uncomment this:
#filebeat.autodiscover:
# providers:
# - type: kubernetes
# node: ${NODE_NAME}
# hints.enabled: true
# hints.default_config:
# type: container
# paths:
# - /var/log/containers/*${data.kubernetes.container.id}.log
processors:
- add_cloud_metadata:
- add_host_metadata:
#cloud.id: ${ELASTIC_CLOUD_ID}
#cloud.auth: ${ELASTIC_CLOUD_AUTH}
output.elasticsearch:
hosts: ['${ELASTICSEARCH_HOST:10.x.x.x}:${ELASTICSEARCH_PORT:9200}']
#username: ${ELASTICSEARCH_USERNAME}
#password: ${ELASTICSEARCH_PASSWORD}
filebeat-daemonset.yaml
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: filebeat
namespace: kube-system
labels:
k8s-app: filebeat
spec:
selector:
matchLabels:
k8s-app: filebeat
template:
metadata:
labels:
k8s-app: filebeat
spec:
serviceAccountName: filebeat
terminationGracePeriodSeconds: 30
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: filebeat
image: docker.elastic.co/beats/filebeat:%VERSION%
args: [
"-c", "/etc/filebeat.yml",
"-e",
]
env:
- name: ELASTICSEARCH_HOST
value: "10.x.x.x"
- name: ELASTICSEARCH_PORT
value: "9200"
#- name: ELASTICSEARCH_USERNAME
# value: elastic
#- name: ELASTICSEARCH_PASSWORD
# value: changeme
#- name: ELASTIC_CLOUD_ID
# value:
#- name: ELASTIC_CLOUD_AUTH
# value:
#- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
securityContext:
runAsUser: 0
# If using Red Hat OpenShift uncomment this:
#privileged: true
resources:
limits:
memory: 200Mi
requests:
cpu: 100m
memory: 100Mi
volumeMounts:
- name: config
mountPath: /etc/filebeat.yml
readOnly: true
subPath: filebeat.yml
- name: data
mountPath: /usr/share/filebeat/data
- name: varlibdockercontainers
mountPath: /var/lib/docker/containers
readOnly: true
- name: varlog
mountPath: /var/log
readOnly: true
volumes:
- name: config
configMap:
defaultMode: 0640
name: filebeat-config
- name: varlibdockercontainers
hostPath:
path: /var/lib/docker/containers
- name: varlog
hostPath:
path: /var/log
# data folder stores a registry of read status for all files, so we don't send everything again on a Filebeat pod restart
- name: data
hostPath:
# When filebeat runs as non-root user, this directory needs to be writable by group (g+w).
path: /var/lib/filebeat-data
type: DirectoryOrCreate
文件节拍角色.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: filebeat
labels:
k8s-app: filebeat
rules:
- apiGroups: [""] # "" indicates the core API group
resources:
- namespaces
- pods
- nodes
verbs:
- get
- watch
- list
- apiGroups: ["apps"]
resources:
- replicasets
verbs: ["get", "list", "watch"]
文件节拍角色绑定.yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: filebeat
subjects:
- kind: ServiceAccount
name: filebeat
namespace: kube-system
roleRef:
kind: ClusterRole
name: filebeat
apiGroup: rbac.authorization.k8s.io
filebeat-service-account.yaml
apiVersion: v1
kind: ServiceAccount
metadata:
name: filebeat
namespace: kube-system
labels:
k8s-app: filebeat
解决方案
#- name: NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
name:
当你不想这样做时,你注释掉了这条线。
推荐阅读
- r - 在 R 中的多个文件中重复相同的操作
- sql - 如何选择在过去 30 天内登录的客户,current_date - 30 在 Oracle SQL、HiveQL 中不起作用?
- sql - SQL创建不同团队之间的胜率表?
- c# - 为什么当搜索词具有“-A”后缀时,DtSearch 找不到任何匹配项?
- python - psycopg2 不使用 Python 3.8.8 连接到 Greenplum PostgreSQL DB。OperationalError:收到对 GSSAPI 协商的无效响应:
- powershell - 在 .txt 中搜索字符串的 PowerShell 脚本,如果找到,则查找包含另一个字符串的下一行并对其进行处理
- pool - Toloka 任务页面是如何创建的
- react-native - 'C:\Users\jansen' 不是内部或外部命令、可运行程序或批处理文件
- android - 如何将特定的 youtube 播放列表加载到 android 电视应用程序中
- flutter - Flutter:Listview 在 iOS 上滚动,但在 Android 上不滚动