mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-11-13 17:11:08 -05:00
Wait for kube api during init (#440)
* kubernetes: wait for KubeAPI to be reachable
This commit is contained in:
parent
b89fae8062
commit
9ad377284d
9 changed files with 190 additions and 10 deletions
|
|
@ -55,6 +55,7 @@ type Client interface {
|
|||
AddTolerationsToDeployment(ctx context.Context, tolerations []corev1.Toleration, name string, namespace string) error
|
||||
AddNodeSelectorsToDeployment(ctx context.Context, selectors map[string]string, name string, namespace string) error
|
||||
WaitForCRDs(ctx context.Context, crds []string) error
|
||||
ListAllNamespaces(ctx context.Context) (*corev1.NamespaceList, error)
|
||||
}
|
||||
|
||||
type installer interface {
|
||||
|
|
|
|||
|
|
@ -116,6 +116,11 @@ func (c *Client) CreateConfigMap(ctx context.Context, configMap corev1.ConfigMap
|
|||
return nil
|
||||
}
|
||||
|
||||
// ListAllNamespaces returns a list of all namespaces.
|
||||
func (c *Client) ListAllNamespaces(ctx context.Context) (*corev1.NamespaceList, error) {
|
||||
return c.clientset.CoreV1().Namespaces().List(ctx, metav1.ListOptions{})
|
||||
}
|
||||
|
||||
func (c *Client) AddTolerationsToDeployment(ctx context.Context, tolerations []corev1.Toleration, name string, namespace string) error {
|
||||
deployments := c.clientset.AppsV1().Deployments(namespace)
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ type Client interface {
|
|||
AddNodeSelectorsToDeployment(ctx context.Context, selectors map[string]string, name string, namespace string) error
|
||||
// WaitForCRD waits for the given CRD to be established.
|
||||
WaitForCRD(ctx context.Context, crd string) error
|
||||
ListAllNamespaces(ctx context.Context) (*corev1.NamespaceList, error)
|
||||
}
|
||||
|
||||
// clientGenerator can generate new clients from a kubeconfig.
|
||||
|
|
@ -86,12 +87,17 @@ func (k *Kubectl) CreateConfigMap(ctx context.Context, configMap corev1.ConfigMa
|
|||
return err
|
||||
}
|
||||
|
||||
err = client.CreateConfigMap(ctx, configMap)
|
||||
return client.CreateConfigMap(ctx, configMap)
|
||||
}
|
||||
|
||||
// ListAllNamespaces returns all namespaces in the cluster.
|
||||
func (k *Kubectl) ListAllNamespaces(ctx context.Context) (*corev1.NamespaceList, error) {
|
||||
client, err := k.clientGenerator.NewClient(k.kubeconfig)
|
||||
if err != nil {
|
||||
return err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return nil
|
||||
return client.ListAllNamespaces(ctx)
|
||||
}
|
||||
|
||||
func (k *Kubectl) AddTolerationsToDeployment(ctx context.Context, tolerations []corev1.Toleration, name string, namespace string) error {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ type stubClient struct {
|
|||
addTolerationsToDeploymentErr error
|
||||
addNodeSelectorToDeploymentErr error
|
||||
waitForCRDErr error
|
||||
listAllNamespacesResp *corev1.NamespaceList
|
||||
listAllNamespacesErr error
|
||||
}
|
||||
|
||||
func (s *stubClient) ApplyOneObject(info *resource.Info, forceConflicts bool) error {
|
||||
|
|
@ -52,6 +54,10 @@ func (s *stubClient) AddNodeSelectorsToDeployment(ctx context.Context, selectors
|
|||
return s.addNodeSelectorToDeploymentErr
|
||||
}
|
||||
|
||||
func (s *stubClient) ListAllNamespaces(ctx context.Context) (*corev1.NamespaceList, error) {
|
||||
return s.listAllNamespacesResp, s.listAllNamespacesErr
|
||||
}
|
||||
|
||||
type stubClientGenerator struct {
|
||||
applyOneObjectErr error
|
||||
getObjectsInfos []*resource.Info
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue