infra: direct kube-API access via kube-vip VIP + NAT (retire SSH tunnel)
Controller now reaches the kube-API directly through the pfSense NAT (192.168.2.50:6443 -> kube-vip VIP 192.168.1.49:6443), validating TLS against the VIP via tls-server-name. Removes the dev.sh SSH-tunnel scaffolding and updates the ansible source-of-truth so a rebuild regenerates a direct-access kubeconfig. Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
1 parent
60a58f01ad
commit
81ef78295a
3 files changed
+43
-27
No files matched your search
@@ -19,8 +19,10 @@ k3s_api_port: 6443
|
||||
# fails to validate).
|
||||
kube_vip_address: "192.168.1.49"
|
||||
|
||||
# Controller (dev container) reaches the kube-API through an SSH tunnel
|
||||
# (local 127.0.0.1:16443 -> primary 127.0.0.1:6443), because the API port is not
|
||||
# NAT-forwarded and 192.168.1.50:6443 is unroutable from the dev host. Only the
|
||||
# controller kubeconfig uses this; k8sServiceHost (in-cluster) stays the real node IP.
|
||||
cluster_controller_api_server: "https://127.0.0.1:16443"
|
||||
# Controller (dev container) reaches the kube-API DIRECTLY via the pfSense NAT
|
||||
# (192.168.2.50:6443 -> kube-vip VIP 192.168.1.49:6443) — no SSH tunnel. TLS is
|
||||
# validated against the VIP via tls-server-name (the VIP IP is in the serving cert's
|
||||
# tls-san list, so TLS through the NAT validates). Only the controller kubeconfig uses
|
||||
# these; k8sServiceHost (in-cluster) stays the real node IP.
|
||||
cluster_controller_api_server: "https://192.168.2.50:6443"
|
||||
cluster_controller_tls_server_name: "{{ kube_vip_address }}"
|
||||
@@ -20,7 +20,7 @@
|
||||
become: false
|
||||
run_once: true
|
||||
|
||||
- name: Write kubeconfig locally (server rewritten to the primary IP)
|
||||
- name: Write kubeconfig locally (server rewritten to the direct NAT endpoint)
|
||||
ansible.builtin.copy:
|
||||
content: >-
|
||||
{{ k3s_kubeconfig_raw.content | b64decode
|
||||
@@ -31,6 +31,30 @@
|
||||
become: false
|
||||
run_once: true
|
||||
|
||||
- name: Read the cluster name from the written kubeconfig
|
||||
ansible.builtin.command:
|
||||
cmd: "kubectl config view -o jsonpath={.clusters[0].name}"
|
||||
environment:
|
||||
KUBECONFIG: "{{ cilium_kubeconfig }}"
|
||||
register: cilium_kubeconfig_cluster
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
run_once: true
|
||||
changed_when: false
|
||||
|
||||
- name: Pin tls-server-name to the kube-vip VIP so TLS validates through the NAT
|
||||
ansible.builtin.command:
|
||||
cmd: >-
|
||||
kubectl config set
|
||||
clusters.{{ cilium_kubeconfig_cluster.stdout }}.tls-server-name
|
||||
{{ cluster_controller_tls_server_name }}
|
||||
environment:
|
||||
KUBECONFIG: "{{ cilium_kubeconfig }}"
|
||||
delegate_to: localhost
|
||||
become: false
|
||||
run_once: true
|
||||
changed_when: true
|
||||
|
||||
- name: Install Gateway API CRDs (must precede Cilium gatewayAPI.enabled)
|
||||
ansible.builtin.command:
|
||||
cmd: "kubectl apply -f {{ item }}"
|
||||
|
||||
Reference in new issue
Block a user