Ssl

Calicoctl 在新的 k3s 安裝上拒絕證書

  • November 25, 2021

我有全新安裝的 Ubuntu、全新安裝的 k3s 和全新下載的 calicoctl。我已經按照以下方式安裝了它。

curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE="644"\
       INSTALL_K3S_EXEC="--flannel-backend=none --cluster-cidr=192.168.0.0/16\
       --disable-network-policy --disable=traefik" sh -

kubectl create -f https://docs.projectcalico.org/manifests/tigera-operator.yaml
kubectl create -f https://docs.projectcalico.org/manifests/custom-resources.yaml

curl -o calicoctl -O -L  "https://github.com/projectcalico/calicoctl/releases/download/v3.20.2/calicoctl"

當我執行 kubectl 時,一切正常。當我執行 calicoctl 時,出現證書錯誤。

# calicoctl apply -f V000_000-host-policy.yaml 
Unable to get Cluster Information to verify version mismatch: Get "https://127.0.0.1:6443/apis/crd.projectcalico.org/v1/clusterinformations/default": x509: certificate signed by unknown authority
Use --allow-version-mismatch to override.

我已經從to複製request-header-ca.crt和證書client-ca.crt並將它們應用於。我可以確認證書列在.server-ca.crt``/var/lib/rancher/k3s/server/tls``/usr/local/share/ca-certificates``update-ca-certificates``/etc/ssl/certs/ca-certificates.crt

此外,我的~/.kube/config文件具有以下內容(我會定期重新安裝,我希望這些都不是機密的 - 如果我錯了,請糾正我)

apiVersion: v1
clusters:
- cluster:
   certificate-authority-data: LS0t...LS0K
   server: https://127.0.0.1:6443
 name: default
contexts:
- context:
   cluster: default
   user: default
 name: default
current-context: default
kind: Config
preferences: {}
users:
- name: default
 user:
   client-certificate-data: LS0t...LS0K
   client-key-data: LS0t...LQo=

我有以下配置/etc/cni/net.d/calico-kubeconfig

# Kubeconfig file for Calico CNI plugin. Installed by calico/node.
apiVersion: v1
kind: Config
clusters:
- name: local
 cluster:
   server: https://10.43.0.1:443
   certificate-authority-data: "LS0t...tLS0K"
users:
- name: calico
 user:
   token: eyJhb...tk4Q
contexts:
- name: calico-context
 context:
   cluster: local
   user: calico
current-context: calico-context

我已將 calico-kubeconfig 中的地址從 更改為10.43.0.1:443127.0.0.1:6443但這沒有任何區別。

有誰知道如何解決這個問題?我看到的證書錯誤是 CA 或令牌的結果嗎?捲曲到同一個地址也抱怨 CA,所以這讓我認為這與令牌無關。

我有一個類似的設置(除了k3s在非特權的 Ubuntu LXD 容器中執行),k3s.service開始使用:

ExecStart=/usr/local/bin/k3s \
   server --snapshotter=native \
   --kubelet-arg=feature-gates=KubeletInUserNamespace=true \
   --kube-controller-manager-arg=feature-gates=KubeletInUserNamespace=true \
   --kube-apiserver-arg=feature-gates=KubeletInUserNamespace=true,RemoveSelfLink=false \
   --disable=servicelb --disable=traefik --flannel-backend=none --disable-network-policy \
   --cluster-cidr=192.168.0.0/16 --cluster-init

我不需要複製任何證書 - 只需:

ln -s /etc/rancher/k3s/k3s.yaml ~/.kube/config

在此處輸入圖像描述

引用自:https://serverfault.com/questions/1079913