簡體   English   中英

在 VPN 外訪問 kubernetes 集群

[英]Access kubernetes cluster outside of VPN

我在本地配置了一個帶有rke的 kubernetes 集群(現在是單節點 - 控制平面、工作程序和 etcd)。

我啟動集群的虛擬機位於 VPN 內部。

成功初始化集群后,我設法從 VPN 內部使用kubectl訪問集群。

我試圖訪問 VPN 之外的集群,所以我更新了 kubeconfig 文件並更改了以下內容:
server: https://<the VM IP>作為server: https://<the external IP>
我還暴露了 6443 端口。

嘗試訪問集群時出現以下錯誤:

E0912 16:23:39 proxy_server.go:147] Error while proxying request: x509: certificate is valid for <the VM IP>, 127.0.0.1, 10.43.0.1, not <the external IP>

我的問題是,如何將外部 IP 添加到證書中,以便能夠在 VPN 之外使用kubectl訪問集群。

rke配置 yml。

# config.yml
nodes:
  - address: <VM IP>
    hostname_override: control-plane-telemesser
    role: [controlplane, etcd, worker]
    user: motti
    ssh_key_path: /home/<USR>/.ssh/id_rsa

ssh_key_path: /home/<USR>/.ssh/id_rsa

cluster_name: my-cluster

ignore_docker_version: false
    
kubernetes_version:

services:
  etcd:
    backup_config:
      interval_hours: 12
      retention: 6
    snapshot: true
    creation: 6h
    retention: 24h

  kube-api:
    service_cluster_ip_range: 10.43.0.0/16
    service_node_port_range: 30000-32767
    pod_security_policy: false

  kube-controller:
    cluster_cidr: 10.42.0.0/16
    service_cluster_ip_range: 10.43.0.0/16

  kubelet:
    cluster_domain: cluster.local
    cluster_dns_server: 10.43.0.10
    fail_swap_on: false
    extra_args:
      max-pods: 110

network:
  plugin: flannel
  options:
    flannel_backend_type: vxlan

dns:
  provider: coredns

authentication:
  strategy: x509

authorization:
  mode: rbac

ingress:
  provider: nginx
  options:
    use-forwarded-headers: "true"

monitoring:
  provider: metrics-server

謝謝,

所以我找到了RKE集群配置的解決方案。

您在身份驗證部分將sans添加到cluster.yml文件中:

authentication:
    strategy: x509
    sans:
      - "10.18.160.10"

保存文件后,只需再次運行rke up ,它將更新集群。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM