mirror of
https://github.com/siderolabs/talos.git
synced 2025-08-18 21:21:10 +02:00
Add sonobuoy runner code with log fetching on failure. Use hand-picked set of e2e tests to run: verify basic pod functionality, verify service connectivity. Add option `--run-e2e` to the `talosctl health` to run quick e2e test to verify cluster health. Add option to run provision tests with custom CNI, run one track of provision tests with Cilium. Bump Cilium to 1.8.2. Talos 0.6 won't uncordon node automatically after upgrade from 0.5, as 0.5 doesn't put annotation. Workaround that in upgrade tests. Bump upgrade test version to 0.6.0 release. Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
97 lines
2.1 KiB
Go
97 lines
2.1 KiB
Go
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
package cluster
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"time"
|
|
|
|
"k8s.io/client-go/kubernetes"
|
|
"k8s.io/client-go/rest"
|
|
"k8s.io/client-go/tools/clientcmd"
|
|
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
|
|
|
k8s "github.com/talos-systems/talos/pkg/kubernetes"
|
|
)
|
|
|
|
// KubernetesClient provides Kubernetes client built via Talos API Kubeconfig.
|
|
type KubernetesClient struct {
|
|
// Base Talos client provider.
|
|
ClientProvider
|
|
|
|
// ForceEndpoint overrides default Kubernetes API endpoint.
|
|
ForceEndpoint string
|
|
|
|
KubeHelper *k8s.Client
|
|
|
|
kubeconfig []byte
|
|
clientset *kubernetes.Clientset
|
|
}
|
|
|
|
// Kubeconfig returns raw kubeconfig.
|
|
//
|
|
// Kubeconfig is cached.
|
|
func (k *KubernetesClient) Kubeconfig(ctx context.Context) ([]byte, error) {
|
|
if k.kubeconfig != nil {
|
|
return k.kubeconfig, nil
|
|
}
|
|
|
|
client, err := k.Client()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
k.kubeconfig, err = client.Kubeconfig(ctx)
|
|
|
|
return k.kubeconfig, err
|
|
}
|
|
|
|
// K8sRestConfig returns *rest.Config (parsed kubeconfig).
|
|
func (k *KubernetesClient) K8sRestConfig(ctx context.Context) (*rest.Config, error) {
|
|
kubeconfig, err := k.Kubeconfig(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
config, err := clientcmd.BuildConfigFromKubeconfigGetter("", func() (*clientcmdapi.Config, error) {
|
|
return clientcmd.Load(kubeconfig)
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
// patch timeout
|
|
config.Timeout = time.Minute
|
|
|
|
if k.ForceEndpoint != "" {
|
|
config.Host = fmt.Sprintf("%s:%d", k.ForceEndpoint, 6443)
|
|
}
|
|
|
|
return config, nil
|
|
}
|
|
|
|
// K8sClient builds Kubernetes client via Talos Kubeconfig API.
|
|
//
|
|
// Kubernetes client instance is cached.
|
|
func (k *KubernetesClient) K8sClient(ctx context.Context) (*kubernetes.Clientset, error) {
|
|
if k.clientset != nil {
|
|
return k.clientset, nil
|
|
}
|
|
|
|
config, err := k.K8sRestConfig(ctx)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if k.KubeHelper, err = k8s.NewForConfig(config); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
k.clientset = k.KubeHelper.Clientset
|
|
|
|
return k.clientset, nil
|
|
}
|