Documentation
¶
Overview ¶
Package k8s_cross is a CoreDNS plugin that implements KEP-1645 Multi-Cluster Services API functionality using Headscale for cross-cluster connectivity.
The plugin provides DNS resolution for services across multiple Kubernetes clusters following the ServiceExport and ServiceImport patterns.
Index ¶
- type Client
- func (c *Client) CreateUser(ctx context.Context, req *CreateUserRequest) (*User, error)
- func (c *Client) GetNode(ctx context.Context, nodeId string) (*Node, error)
- func (c *Client) Health(ctx context.Context) (*HealthResponse, error)
- func (c *Client) ListNodes(ctx context.Context, userFilter string) ([]Node, error)
- type CreateUserRequest
- type CreateUserResponse
- type GetNodeResponse
- type HeadscaleClient
- type HealthResponse
- type K8sCross
- type ListNodesResponse
- type Node
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client represents a client for the Headscale API.
func (*Client) CreateUser ¶
CreateUser creates a new user in Headscale.
type CreateUserRequest ¶
type CreateUserRequest struct {
Name string `json:"name"`
DisplayName string `json:"displayName"`
Email string `json:"email"`
}
CreateUserRequest represents the request for creating a new user.
type CreateUserResponse ¶
type CreateUserResponse struct {
User User `json:"user"`
}
CreateUserResponse represents the response from the CreateUser API endpoint.
type GetNodeResponse ¶
type GetNodeResponse struct {
Node Node `json:"node"`
}
GetNodeResponse represents the response from the GetNode API endpoint.
type HeadscaleClient ¶
type HeadscaleClient interface {
GetNode(ctx context.Context, nodeId string) (*Node, error)
ListNodes(ctx context.Context, userFilter string) ([]Node, error)
Health(ctx context.Context) (*HealthResponse, error)
CreateUser(ctx context.Context, req *CreateUserRequest) (*User, error)
}
HeadscaleClient interface defines the methods that need to be implemented for interacting with Headscale.
type HealthResponse ¶
type HealthResponse struct {
DatabaseConnectivity bool `json:"databaseConnectivity"`
}
HealthResponse represents the response from the health API endpoint.
type K8sCross ¶
type K8sCross struct {
Next plugin.Handler
// Configuration for the plugin
HeadscaleClient HeadscaleClient
Zones []string
TTL uint32
ClusterName string
ClusterSet string
}
K8sCross is the main structure for the k8s_cross plugin, handling DNS requests for multi-cluster services.
func (K8sCross) Ready ¶
Ready 实现了 ready.Readiness 接口,用于报告插件是否已准备好处理查询。 当此方法返回 true 时,CoreDNS 认为插件已就绪,此后不再检查。 对于 k8s_cross 插件,由于不需要特殊初始化,始终返回 true。
func (K8sCross) ServeDNS ¶
ServeDNS implements the plugin.Handler interface. This is the entry point for the plugin to handle DNS requests. Parameters: - ctx: Request context containing request-related information - w: DNS response writer used to send responses to clients - r: DNS request message Returns: - int: DNS response code - error: Error during processing
type ListNodesResponse ¶
type ListNodesResponse struct {
Nodes []Node `json:"nodes"`
}
ListNodesResponse represents the response from the ListNodes API endpoint.
type Node ¶
type Node struct {
ID string `json:"id"`
MachineKey string `json:"machineKey"`
NodeKey string `json:"nodeKey"`
DiscoKey string `json:"discoKey"`
IPAddresses []string `json:"ipAddresses"`
Name string `json:"name"`
User User `json:"user"`
LastSeen time.Time `json:"lastSeen"`
Expiry time.Time `json:"expiry"`
CreatedAt time.Time `json:"createdAt"`
RegisterMethod string `json:"registerMethod"`
Online bool `json:"online"`
ApprovedRoutes []string `json:"approvedRoutes"`
AvailableRoutes []string `json:"availableRoutes"`
}
Node represents a node in the Headscale network.