mirror of
https://github.com/rancher/k3k.git
synced 2026-08-22 22:06:18 +00:00
29 lines
725 B
Go
29 lines
725 B
Go
package agent
|
|
|
|
import (
|
|
"github.com/rancher/k3k/pkg/apis/k3k.io/v1alpha1"
|
|
"github.com/rancher/k3k/pkg/controller"
|
|
ctrlruntimeclient "sigs.k8s.io/controller-runtime/pkg/client"
|
|
)
|
|
|
|
const (
|
|
configName = "agent-config"
|
|
)
|
|
|
|
type Agent interface {
|
|
Name() string
|
|
Config() (ctrlruntimeclient.Object, error)
|
|
Resources() []ctrlruntimeclient.Object
|
|
}
|
|
|
|
func New(cluster *v1alpha1.Cluster, serviceIP, sharedAgentImage, token string) Agent {
|
|
if cluster.Spec.Mode == VirtualNodeMode {
|
|
return NewVirtualAgent(cluster, serviceIP, token)
|
|
}
|
|
return NewSharedAgent(cluster, serviceIP, sharedAgentImage, token)
|
|
}
|
|
|
|
func configSecretName(clusterName string) string {
|
|
return controller.SafeConcatNameWithPrefix(clusterName, configName)
|
|
}
|