3

I am trying to find a way to disable --basic-auth-file on my cluster.

Can someone help me?

Ivan Aracki
  • 4,861
  • 11
  • 59
  • 73
Danilo
  • 123
  • 7

2 Answers2

2

Based on your comments your are using kops to deploy a cluster. In kops case, you need to add the following lines to disable the --basic-auth-file flag.

kops edit cluster --name <clustername> --state <state_path>

spec:
  kubeAPIServer:
    disableBasicAuth: true

spec and kubeAPIServer is probably already present in your cluster config

To apply the change, you need to run

kops update cluster --name <clustername> --state <state_path> <--yes>

and do a rolling upgrade

kops update cluster --name <clustername> --state <state_path> <--yes>

If you run the commands without --yes, it will basically shows you what it is going to do, with --yes it will apply the changes/roll the cluster.

Sadly KOPS is a bit lacking documentation on what are the options you can use in the cluster config yaml, the best I could find is their API definition: https://github.com/kubernetes/kops/blob/master/pkg/apis/kops/componentconfig.go#L246

Lorant Fecske
  • 563
  • 5
  • 10
1

You can disable it directly from the /etc/kubernetes/manifests/kube-apiserver.yaml file. For example

apiVersion: v1
kind: Pod
metadata:
  annotations:
    scheduler.alpha.kubernetes.io/critical-pod: ""
  creationTimestamp: null
  labels:
    component: kube-apiserver
    tier: control-plane
  name: kube-apiserver
  namespace: kube-system
spec:
  containers:
  - command:
    - kube-apiserver
    - --basic-auth-file=xxxxx .  <===== Remove this line
    - --authorization-mode=Node,RBAC
    - --advertise-address=xxxxxx
    - --allow-privileged=true
    - --client-ca-file=/etc/kubernetes/pki/ca.crt
    - --cloud-provider=aws
    - --disable-admission-plugins=PersistentVolumeLabel
    - --enable-admission-plugins=NodeRestriction,DefaultStorageClass,NamespaceLifecycle,LimitRanger,ServiceAccount,DefaultTolerationSeconds,MutatingAdmissionWebhook,ValidatingAdmissionWebhook,ResourceQuota
    - --enable-bootstrap-token-auth=true
    - --etcd-cafile=/etc/kubernetes/pki/etcd/ca.crt
    - --etcd-certfile=/etc/kubernetes/pki/apiserver-etcd-client.crt
    - --etcd-keyfile=/etc/kubernetes/pki/apiserver-etcd-client.key
    - --etcd-servers=https://127.0.0.1:2379
    - --insecure-port=0
    - --kubelet-client-certificate=/etc/kubernetes/pki/apiserver-kubelet-client.crt
    - --kubelet-client-key=/etc/kubernetes/pki/apiserver-kubelet-client.key
    - --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname
    - --proxy-client-cert-file=/etc/kubernetes/pki/front-proxy-client.crt
    - --proxy-client-key-file=/etc/kubernetes/pki/front-proxy-client.key
    - --requestheader-allowed-names=front-proxy-client
    - --requestheader-client-ca-file=/etc/kubernetes/pki/front-proxy-ca.crt
    - --requestheader-extra-headers-prefix=X-Remote-Extra-
    - --requestheader-group-headers=X-Remote-Group
    - --requestheader-username-headers=X-Remote-User
    - --secure-port=6443
    - --service-account-key-file=/etc/kubernetes/pki/sa.pub
    - --service-cluster-ip-range=10.96.0.0/12
    - --tls-cert-file=/etc/kubernetes/pki/apiserver.crt
    - --tls-private-key-file=/etc/kubernetes/pki/apiserver.key
    image: k8s.gcr.io/kube-apiserver-amd64:v1.11.2
    imagePullPolicy: IfNotPresent
    livenessProbe:
      failureThreshold: 8
      httpGet:
        host: 172.31.1.118
        path: /healthz
        port: 6443
        scheme: HTTPS
      initialDelaySeconds: 15
      timeoutSeconds: 15
    name: kube-apiserver
    resources:
      requests:
        cpu: 250m
    volumeMounts:
    - mountPath: /etc/kubernetes/pki
      name: k8s-certs
      readOnly: true
    - mountPath: /etc/ssl/certs
      name: ca-certs
      readOnly: true
    - mountPath: /usr/share/ca-certificates
      name: usr-share-ca-certificates
      readOnly: true
    - mountPath: /usr/local/share/ca-certificates
      name: usr-local-share-ca-certificates
      readOnly: true
    - mountPath: /etc/ca-certificates
      name: etc-ca-certificates
      readOnly: true
  hostNetwork: true
  priorityClassName: system-cluster-critical
  volumes:
  - hostPath:
      path: /etc/kubernetes/pki
      type: DirectoryOrCreate
    name: k8s-certs
  - hostPath:
      path: /etc/ssl/certs
      type: DirectoryOrCreate
    name: ca-certs
  - hostPath:
      path: /usr/share/ca-certificates
      type: DirectoryOrCreate
    name: usr-share-ca-certificates
  - hostPath:
      path: /usr/local/share/ca-certificates
      type: DirectoryOrCreate
    name: usr-local-share-ca-certificates
  - hostPath:
      path: /etc/ca-certificates
      type: DirectoryOrCreate
    name: etc-ca-certificates
status: {}

Then restart your kube-apiserver containers on your master(s)

Rico
  • 58,485
  • 12
  • 111
  • 141
  • I am using kops. If I edit my master nodes as you said, when I need to create a new master, the will come with the old confs. I need a way to configure this line on kops to permanent edition. – Danilo Sep 12 '18 at 20:01
  • If I have a kubernetes installation from scratch a can do as you said. – Danilo Sep 12 '18 at 20:03
  • I believe kops has cookie cutter configs. i.e (specific AMIs) but I may be wrong. – Rico Sep 12 '18 at 20:08
  • I guess kops allows you the `--image string` option. So you can create your own AMI and somehow make it change the configs. Otherwise, you'll probably have to upstream a change to kops. – Rico Sep 12 '18 at 20:15
  • On my host where api server is running, there isn't a `kube-apiserver.yaml` file, instead, there's a `kube-apiserver.manifest`. I am not entirely sure if they only change the file extension since the content looks the same. I tried to edit the `kube-apiserver.manifest` file, but after the removal of `--basic-auth-file`, api server refused to start. – Yuhao Zhang Sep 19 '18 at 16:21
  • What errors do you see? My guess is that you need some sort of authentication. – Rico Sep 19 '18 at 16:30