Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,13 @@ message Matcher {
// empty value is ignored. The match result is logically ANDed with DBLabels,
// if both are non-empty.
string db_labels_expression = 2;
// KubernetesLabels matches Kubernetes labels. An empty value is ignored. The match
// result is logically ANDed with KubernetesLabelsExpression, if both are non-empty.
repeated teleport.label.v1.Label kubernetes_labels = 3;
// KubernetesLabelsExpression is a label predicate expression to match Kubernetes. An
// empty value is ignored. The match result is logically ANDed with KubernetesLabels,
// if both are non-empty.
string kubernetes_labels_expression = 4;
// Disabled disables matches for all labels and expressions.
bool disabled = 5;
}
10 changes: 10 additions & 0 deletions api/proto/teleport/legacy/types/types.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5167,6 +5167,7 @@ message KubernetesClusterV3List {
message KubernetesServerV3 {
option (gogoproto.goproto_stringer) = false;
option (gogoproto.stringer) = false;

// Kind is the Kubernetes server resource kind. Always "kube_server".
string Kind = 1 [(gogoproto.jsontag) = "kind"];
// SubKind is an optional resource subkind.
Expand All @@ -5183,6 +5184,8 @@ message KubernetesServerV3 {
(gogoproto.nullable) = false,
(gogoproto.jsontag) = "spec"
];
// Status is the Kubernetes server status.
KubernetesServerStatusV3 status = 6;
}

// KubernetesServerSpecV3 is the Kubernetes server spec.
Expand All @@ -5209,6 +5212,13 @@ message KubernetesServerSpecV3 {
repeated string relay_ids = 8;
}

// KubernetesServerStatusV3 is the Kubernetes cluster status.
message KubernetesServerStatusV3 {
// TargetHealth is the health status of between the Teleport agent
// and Kubernetes cluster.
TargetHealth target_health = 1;
}

// WebTokenV3 describes a web token. Web tokens are used as a transport to relay bearer tokens
// to the client.
// Initially bound to a web session, these have been factored out into a separate resource to
Expand Down
57 changes: 57 additions & 0 deletions api/types/kubernetes_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ type KubeServer interface {
SetCluster(KubeCluster) error
// ProxiedService provides common methods for a proxied service.
ProxiedService
// GetTargetHealth gets health details for a target Kubernetes cluster.
GetTargetHealth() *TargetHealth
// SetTargetHealth sets health details for a target Kubernetes cluster.
SetTargetHealth(h *TargetHealth)
// GetTargetHealthStatus gets the health status of a target Kubernetes cluster.
GetTargetHealthStatus() TargetHealthStatus
// SetTargetHealthStatus sets the health status of a target Kubernetes cluster.
SetTargetHealthStatus(status TargetHealthStatus)
// GetRelayGroup returns the name of the Relay group that the kube server is
// connected to.
GetRelayGroup() string
Expand Down Expand Up @@ -331,6 +339,55 @@ func (k *KubernetesServerV3) IsEqual(i KubeServer) bool {
return false
}

// GetTargetHealth gets health details for a target Kubernetes cluster.
func (s *KubernetesServerV3) GetTargetHealth() *TargetHealth {
return s.GetStatus().GetTargetHealth()
}

// SetTargetHealth sets health details for a target Kubernetes cluster.
func (s *KubernetesServerV3) SetTargetHealth(h *TargetHealth) {
if s.Status == nil {
s.Status = &KubernetesServerStatusV3{}
}
s.Status.TargetHealth = h
}

// GetTargetHealthStatus gets the health status of a target Kubernetes cluster.
func (s *KubernetesServerV3) GetTargetHealthStatus() TargetHealthStatus {
health := s.GetStatus().GetTargetHealth()
if health == nil {
return TargetHealthStatusUnknown
}
return TargetHealthStatus(health.Status)
}

// SetTargetHealthStatus sets the health status of a target Kubernetes cluster.
func (s *KubernetesServerV3) SetTargetHealthStatus(status TargetHealthStatus) {
if s.Status == nil {
s.Status = &KubernetesServerStatusV3{}
}
if s.Status.TargetHealth == nil {
s.Status.TargetHealth = &TargetHealth{}
}
s.Status.TargetHealth.Status = string(status)
}

// GetStatus gets the Kubernetes server status.
func (s *KubernetesServerV3) GetStatus() *KubernetesServerStatusV3 {
if s == nil {
return nil
}
return s.Status
}

// GetTargetHealth gets the health of a Kubernetes cluster.
func (s *KubernetesServerStatusV3) GetTargetHealth() *TargetHealth {
if s == nil {
return nil
}
return s.TargetHealth
}

// KubeServers represents a list of kube servers.
type KubeServers []KubeServer

Expand Down
6 changes: 4 additions & 2 deletions api/types/target_health.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@ import (
type TargetHealthProtocol string

const (
// TargetHealthProtocolTCP is a target health check protocol.
TargetHealthProtocolTCP TargetHealthProtocol = "TCP"
// TargetHealthProtocolTCP is the TCP target health check protocol.
TargetHealthProtocolTCP TargetHealthProtocol = "tcp"
// TargetHealthProtocolHTTP is the HTTP target health check protocol.
TargetHealthProtocolHTTP TargetHealthProtocol = "http"
)

// TargetHealthStatus is a target resource's health status.
Expand Down
Loading
Loading