Connect K3s workloads to the Infra console
Click 接入 K3s (Connect K3s) in the Infra header, pick a saved Kubernetes or K3s connection, enter a namespace, click 读取负载 (Read workloads), choose a workload and click 接入应用 (Connect application). DevOpsPad reads the workload’s real label selector and writes an environment and application entry into your local project.
Nothing is written to the cluster. Connection credentials stay on your machine; the project only records the connection name, namespace and selector.
Before you start
You need a saved Kubernetes or K3s connection. Add one under 集群资源 (Cluster resources) — for example named local-k3s — or click 新建 K3s 连接 (New K3s connection) inside the wizard. The usual kubeconfig, SSH tunnel, keychain and authentication rules apply; see kubeconfig contexts and SSH tunnels.
For K3s, the kubeconfig usually comes from /etc/rancher/k3s/k3s.yaml on the server. The K3s cluster access guide explains how to copy it and point it at a reachable address.
Steps
- In Infra, click 接入 K3s. The dialog is titled 接入 K3s 应用 (Connect a K3s application).
- Under 集群连接 (Cluster connection), choose the saved connection. The dialog shows the context and whether it connects directly to the Kubernetes API or through the saved SSH tunnel.
- Enter a concrete namespace under 命名空间 (Namespace), for example
default. - Click 读取负载. DevOpsPad lists the namespace’s workloads and Pod count.
- Pick the workload under 工作负载 (Workload).
- Check 环境名称 (Environment name) and 应用名称 (Application name). Both must be lowercase letters, digits and hyphens, up to 63 characters.
- Click 接入应用. The message “K3s 应用已接入,连接凭据保留在本机” confirms the mapping was saved and credentials stayed local.
If the namespace has no workloads, the dialog says so (“此命名空间暂无可接入负载”). Results are truncated at 500 resources.
Do it from the command line
devopspadctl does the same thing:
devopspadctl cluster inspect --connection local-k3s --namespace default
devopspadctl cluster attach --connection local-k3s --namespace default --environment pro
To register an application that has no workload yet (for example before its first deployment), pass the selector explicitly. This mode does not contact the cluster:
devopspadctl cluster attach --connection local-k3s --namespace default \
--environment pro --application svc-api --selector app=svc-api
Registering the same mapping twice is fine; a conflicting mapping is rejected. See devopspadctl.
Sharing with teammates
Connection names in the project must match a connection each teammate has saved locally. Credentials can differ per person. If two saved connections have the same name, Infra asks you to rename one under 集群资源 before it can resolve the environment.
Troubleshooting
- “未找到环境对应的集群连接” (no cluster connection found for this environment): add a connection with the name used in
project.yaml, then refresh the project. - Empty Pod list after connecting: check the namespace and selector in project.yaml. The selector must match the Pod labels.
- Permission errors: see RBAC permissions for the verbs each Infra page needs.
Frequently asked questions
Does connecting a K3s workload change anything in the cluster?
No. The wizard only reads workloads and saves an environment and application mapping in your local project.yaml. It does not create or label anything in the cluster.