如何在 K8s 中启用 Feature Gates?

Gab*_*aby 12 kubernetes

我需要在我的裸机 K8s 集群(v1.13)上启用一些功能门。我尝试使用 kubelet 标志--config来启用它们,因为kubelet --feature-gates <feature gate>抛出一个错误,指出该功能已被弃用。

我创建了一个具有以下配置的 .yml 文件:

apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
feature-gates:
    VolumeSnapshotDataSource=true
Run Code Online (Sandbox Code Playgroud)

运行后:“kubelet --config ,我收到以下错误:

I0119 21:59:52.987945   29087 server.go:417] Version: v1.14.2
I0119 21:59:52.988165   29087 plugins.go:103] No cloud provider specified.
W0119 21:59:52.988188   29087 server.go:556] standalone mode, no API client
F0119 21:59:52.988203   29087 server.go:265] failed to run Kubelet: no client provided, cannot use webhook authentication
Run Code Online (Sandbox Code Playgroud)

有谁知道会发生什么以及如何解决这个问题?

sur*_*ren 7

您不适--feature-gates用于 kubelet。你对API-server. 根据您在裸机上安装 kubernetes 的方式,您需要停止API-server,编辑启动它的命令并添加以下参数:

--feature-gates=VolumeSnapshotDataSource=true
Run Code Online (Sandbox Code Playgroud)

或者,如果它在一个 pod 中,找到清单,编辑它并重新部署它(它应该自动发生,一旦你完成编辑)。它应该是这样的:

...
  labels:
    component: kube-apiserver
    tier: control-plane
  name: kube-apiserver
  namespace: kube-system
spec:
  containers:
  - command:
    - kube-apiserver
    - --advertise-address=10.132.0.48
    - --allow-privileged=true
    - --authorization-mode=Node,RBAC
    - --client-ca-file=/etc/kubernetes/pki/ca.crt
    - --enable-admission-plugins=NodeRestriction
    - --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
    - --feature-gates=VolumeSnapshotDataSource=true
    image: k8s.gcr.io/kube-apiserver:v1.16.4
    imagePullPolicy: IfNotPresent
    livenessProbe:
      failureThreshold: 8
      httpGet:
        host: 10.132.0.48
        path: /healthz
        port: 6443
        scheme: HTTPS
...
Run Code Online (Sandbox Code Playgroud)

  • 注意 - 对于基于 kubeadm 的系统,您可以编辑 /etc/kubernetes/manifests/kube-apiserver.yaml 并删除 kube-apiserver pod 以重新启动它 (2认同)