kube-apiserver[4073]: Error: "kube-apiserver" does not take any arguments, got ["\\"]

when restarting kubernetes master node. I'm getting below error

Sep 13 21:32:22 master-1 kube-apiserver[4073]: Error: "kube-apiserver" does not take any arguments, got ["\\"]
Sep 13 21:32:22 master-1 systemd[1]: kube-apiserver.service: Main process exited, code=exited, status=1/FAILURE
Sep 13 21:32:22 master-1 systemd[1]: kube-apiserver.service: Failed with result 'exit-code'.

This is my kube-apiserver.service configuration

cat <<EOF | sudo tee /etc/systemd/system/kube-apiserver.service
[Unit]
Description=Kubernetes API Server
Documentation=https://github.com/kubernetes/kubernetes

[Service]
ExecStart=/usr/local/bin/kube-apiserver \\
  --advertise-address=${INTERNAL_IP} \\
  --allow-privileged=true \\
  --apiserver-count=3 \\
  --audit-log-maxage=30 \\
  --audit-log-maxbackup=3 \\
  --audit-log-maxsize=100 \\
  --audit-log-path=/var/log/audit.log \\
  --authorization-mode=Node,RBAC \\
  --bind-address=0.0.0.0 \\
  --client-ca-file=/var/lib/kubernetes/ca.crt \\
  --enable-admission-plugins=NodeRestriction,ServiceAccount,PodPreset \\
  --enable-swagger-ui=true \\
  --enable-bootstrap-token-auth=true \\
  --etcd-cafile=/var/lib/kubernetes/ca.crt \\
  --etcd-certfile=/var/lib/kubernetes/etcd-server.crt \\
  --etcd-keyfile=/var/lib/kubernetes/etcd-server.key \\
  --etcd-servers=https://192.168.111.246:2379,https://192.168.111.247:2379 \\
  --event-ttl=1h \\
  --encryption-provider-config=/var/lib/kubernetes/encryption-config.yaml \\
  --kubelet-certificate-authority=/var/lib/kubernetes/ca.crt \\
  --kubelet-client-certificate=/var/lib/kubernetes/kube-apiserver.crt \\
  --kubelet-client-key=/var/lib/kubernetes/kube-apiserver.key \\
  --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname \\
  --requestheader-client-ca-file=/var/lib/kubernetes/kube-proxy.crt \\
  --requestheader-allowed-names=front-proxy-client \\
  --requestheader-extra-headers-prefix=X-Remote-Extra- \\
  --requestheader-group-headers=X-Remote-Group \\
  --requestheader-username-headers=X-Remote-User \\ 
  --proxy-client-cert-file=/var/lib/kubernetes/kube-proxy.crt \\ 
  --proxy-client-key-file=/var/lib/kubernetes/kube-proxy.key \\
  --enable-aggregator-routing=true \\
  --kubelet-https=true \\
  --runtime-config=api/all=true \\
  --service-account-key-file=/var/lib/kubernetes/service-account.crt \\
  --service-cluster-ip-range=10.96.0.0/24 \\
  --service-node-port-range=30000-32767 \\
  --tls-cert-file=/var/lib/kubernetes/kube-apiserver.crt \\
  --tls-private-key-file=/var/lib/kubernetes/kube-apiserver.key \\
  --runtime-config=settings.k8s.io/v1alpha1=true \\
  --v=2
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
EOF

Whats wrong with above configuration ? VMware workstation used. I'm using kubernetes 1.19. Ubuntu 18.04 RAM 16GB CNI : Weave

Funny thing happened. I removed some parameters -> Then restated kube-apiserver -> Then pasted same above config file -> Then restated kube-apiserver again -> The kube-apiserver works niceley. So what was the problem happened when I started my vm ?

1 answer

  • answered 2020-09-14 13:22 AMendis

    Actually I had extra space added on two places

    --requestheader-username-headers=X-Remote-User \ <-- extra space here --proxy-client-cert-file=/var/lib/kubernetes/kube-proxy.crt \ <-- extra space here

    Thanks to the reply here https://github.com/kubernetes/kubernetes/issues/94758 found the issue