Loaded: error (Reason: Invalid argument)
Closed this issue · 3 comments
环境
1m+2N
版本和配置信息
[Unit]
Description=Kubernetes API Server
Documentation=https://github.com/kubernetes/kubernetes
After=network.target
[Service]
ExecStart=/usr/local/bin/kube-apiserver
--v=2 \
--logtostderr=true \
--allow-privileged=true
--bind-address=0.0.0.0
--secure-port=6443
--insecure-port=0
--advertise-address=10.10.11.100
--service-cluster-ip-range=192.168.0.0/16
--service-node-port-range=30000-32767
--etcd-servers=https://10.10.11.100:2379
--etcd-cafile=/etc/etcd/ssl/etcd-ca.pem
--etcd-certfile=/etc/etcd/ssl/etcd.pem
--etcd-keyfile=/etc/etcd/ssl/etcd-key.pem
--client-ca-file=/etc/kubernetes/pki/ca.pem
--tls-cert-file=/etc/kubernetes/pki/apiserver.pem
--tls-private-key-file=/etc/kubernetes/pki/apiserver-key.pem
--kubelet-client-certificate=/etc/kubernetes/pki/apiserver.pem
--kubelet-client-key=/etc/kubernetes/pki/apiserver-key.pem
--service-account-key-file=/etc/kubernetes/pki/sa.pub
--service-account-signing-key-file=/etc/kubernetes/pki/sa.key
--service-account-issuer=https://kubernetes.default.svc.cluster.local
--kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
--enable-admission-plugins=NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultStorageClass,DefaultTolerationSeconds,NodeRestriction,ResourceQuota
--authorization-mode=Node,RBAC
--enable-bootstrap-token-auth=true
--requestheader-client-ca-file=/etc/kubernetes/pki/front-proxy-ca.pem
--proxy-client-cert-file=/etc/kubernetes/pki/front-proxy-client.pem
--proxy-client-key-file=/etc/kubernetes/pki/front-proxy-client-key.pem
--requestheader-allowed-names=aggregator
--requestheader-group-headers=X-Remote-Group
--requestheader-extra-headers-prefix=X-Remote-Extra-
--requestheader-username-headers=X-Remote-User
# --token-auth-file=/etc/kubernetes/token.csv
Restart=on-failure
RestartSec=10s
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
- kubernetes版本:
- V1.27.16
- docker版本:
- V26.1.2和V26.1.4
- 网络插件:
- 存储类型:
操作
[root@k8s-master01 pki]# systemctl daemon-reload
[root@k8s-master01 pki]# systemctl enable --now kube-apiserver
Failed to start kube-apiserver.service: Unit is not loaded properly: Invalid argument.
See system logs and 'systemctl status kube-apiserver.service' for details.
导致该问题的操作或现象
日志
日志或报错信息
[root@k8s-master01 pki]# systemctl status kube-apiserver.service
● kube-apiserver.service - Kubernetes API Server
Loaded: error (Reason: Invalid argument)
Active: inactive (dead)
Docs: https://github.com/kubernetes/kubernetes
10月 27 02:14:14 k8s-master01 systemd[1]: kube-apiserver.service lacks both ExecStart= and ExecStop= setting. Refusing.
10月 27 09:18:48 k8s-master01 systemd[1]: [/usr/lib/systemd/system/kube-apiserver.service:8] Trailing garbage, ignoring.
10月 27 09:18:48 k8s-master01 systemd[1]: [/usr/lib/systemd/system/kube-apiserver.service:10] Unknown lvalue '--allow-privileged' in section 'Service'
10月 27 09:18:48 k8s-master01 systemd[1]: kube-apiserver.service lacks both ExecStart= and ExecStop= setting. Refusing.
10月 27 09:18:57 k8s-master01 systemd[1]: [/usr/lib/systemd/system/kube-apiserver.service:8] Trailing garbage, ignoring.
10月 27 09:18:57 k8s-master01 systemd[1]: [/usr/lib/systemd/system/kube-apiserver.service:10] Unknown lvalue '--allow-privileged' in section 'Service'
10月 27 09:18:57 k8s-master01 systemd[1]: kube-apiserver.service lacks both ExecStart= and ExecStop= setting. Refusing.
10月 27 09:22:01 k8s-master01 systemd[1]: [/usr/lib/systemd/system/kube-apiserver.service:8] Trailing garbage, ignoring.
10月 27 09:22:01 k8s-master01 systemd[1]: [/usr/lib/systemd/system/kube-apiserver.service:10] Unknown lvalue '--allow-privileged' in section 'Service'
10月 27 09:22:01 k8s-master01 systemd[1]: kube-apiserver.service lacks both ExecStart= and ExecStop= setting. Refusing.
[root@k8s-master01 pki]# tail -f /var/log/messages
Oct 27 09:28:56 k8s-master01 systemd: [/usr/lib/systemd/system/kube-apiserver.service:10] Unknown lvalue '--allow-privileged' in section 'Service'
Oct 27 09:28:56 k8s-master01 systemd: kube-apiserver.service lacks both ExecStart= and ExecStop= setting. Refusing.
Oct 27 09:28:56 k8s-master01 systemd: [/usr/lib/systemd/system/bolt.service:11] Unknown lvalue 'MemoryDenyWriteExecute' in section 'Service'
Oct 27 09:28:56 k8s-master01 systemd: [/usr/lib/systemd/system/bolt.service:13] Unknown lvalue 'ProtectControlGroups' in section 'Service'
Oct 27 09:28:56 k8s-master01 systemd: [/usr/lib/systemd/system/bolt.service:15] Unknown lvalue 'ProtectKernelModules' in section 'Service'
Oct 27 09:28:56 k8s-master01 systemd: [/usr/lib/systemd/system/bolt.service:18] Unknown lvalue 'RestrictRealtime' in section 'Service'
Oct 27 09:28:56 k8s-master01 systemd: [/usr/lib/systemd/system/bolt.service:19] Unknown lvalue 'ReadWritePaths' in section 'Service'
Oct 27 09:30:01 k8s-master01 systemd: Started Session 146 of user root.
Oct 27 09:30:01 k8s-master01 systemd: Started Session 145 of user root.
Oct 27 09:35:01 k8s-master01 systemd: Started Session 147 of user root.
大神你好,就以上信息,如有缺失的,我再补充。启动APIserver报错,麻烦帮忙看下。
你的 Kubernetes API Server 服务配置文件报错主要是由于配置文件中存在格式问题,导致 systemd 无法正确解析。你的 ExecStart=/usr/local/bin/kube-apiserver
后面的参数格式写的不对,换行的时候需要在末尾加个 \
反斜杠。
你的 Kubernetes API Server 服务配置文件报错主要是由于配置文件中存在格式问题,导致 systemd 无法正确解析。你的
ExecStart=/usr/local/bin/kube-apiserver
后面的参数格式写的不对,换行的时候需要在末尾加个\
反斜杠。
收到,谢谢。