github.com/openshift/installer@v1.4.17/pkg/infrastructure/clusterapi/types.go (about)

     1  package clusterapi
     2  
     3  import (
     4  	"context"
     5  	"time"
     6  
     7  	"sigs.k8s.io/controller-runtime/pkg/client"
     8  
     9  	"github.com/openshift/installer/pkg/asset/cluster/tfvars"
    10  	"github.com/openshift/installer/pkg/asset/installconfig"
    11  	"github.com/openshift/installer/pkg/asset/machines"
    12  	"github.com/openshift/installer/pkg/asset/manifests"
    13  	"github.com/openshift/installer/pkg/asset/rhcos"
    14  	"github.com/openshift/installer/pkg/types"
    15  )
    16  
    17  // Provider is the base interface that cloud platforms
    18  // should implement for the CAPI infrastructure provider.
    19  type Provider interface {
    20  	// Name provides the name for the cloud platform.
    21  	Name() string
    22  
    23  	// PublicGatherEndpoint returns how the cloud platform expects the installer
    24  	// to connect to the bootstrap node for log gathering. CAPI providers are not
    25  	// consistent in how public IP addresses are represented in the machine status.
    26  	// Furthermore, Azure cannot attach a public IP to the bootstrap node, so SSH
    27  	// must be performed through the API load balancer.
    28  	// When a platform returns ExternalIP, the installer will require an ExternalIP
    29  	// to be present in the status, before it declares the machine ready.
    30  	PublicGatherEndpoint() GatherEndpoint
    31  }
    32  
    33  // PreProvider defines the PreProvision hook, which is called prior to
    34  // CAPI infrastructure provisioning.
    35  type PreProvider interface {
    36  	// PreProvision is called before provisioning using CAPI controllers has begun
    37  	// and should be used to create dependencies needed for CAPI provisioning,
    38  	// such as IAM roles or policies.
    39  	PreProvision(ctx context.Context, in PreProvisionInput) error
    40  }
    41  
    42  // PreProvisionInput collects the args passed to the PreProvision call.
    43  type PreProvisionInput struct {
    44  	InfraID          string
    45  	InstallConfig    *installconfig.InstallConfig
    46  	RhcosImage       *rhcos.Image
    47  	ManifestsAsset   *manifests.Manifests
    48  	MachineManifests []client.Object
    49  	WorkersAsset     *machines.Worker
    50  }
    51  
    52  // IgnitionProvider handles preconditions for bootstrap ignition and
    53  // generates ignition data for the CAPI bootstrap ignition secret.
    54  //
    55  // WARNING! Low-level primitive. Use only if absolutely necessary.
    56  type IgnitionProvider interface {
    57  	Ignition(ctx context.Context, in IgnitionInput) ([]byte, error)
    58  }
    59  
    60  // IgnitionInput collects the args passed to the IgnitionProvider call.
    61  type IgnitionInput struct {
    62  	Client           client.Client
    63  	BootstrapIgnData []byte
    64  	InfraID          string
    65  	InstallConfig    *installconfig.InstallConfig
    66  	TFVarsAsset      *tfvars.TerraformVariables
    67  }
    68  
    69  // InfraReadyProvider defines the InfraReady hook, which is
    70  // called after the initial infrastructure manifests have been created
    71  // and InfrastructureReady == true on the cluster status, and before
    72  // IgnitionProvider hook and creation of the control-plane machines.
    73  type InfraReadyProvider interface {
    74  	// InfraReady is called once cluster.Status.InfrastructureReady
    75  	// is true, typically after load balancers have been provisioned. It can be used
    76  	// to create DNS records.
    77  	InfraReady(ctx context.Context, in InfraReadyInput) error
    78  }
    79  
    80  // InfraReadyInput collects the args passed to the InfraReady call.
    81  type InfraReadyInput struct {
    82  	// Client is the client for kube-apiserver running locally on the installer host.
    83  	// It can be used to read the status of the cluster object on the local control plane.
    84  	Client        client.Client
    85  	InstallConfig *installconfig.InstallConfig
    86  	InfraID       string
    87  }
    88  
    89  // PostProvider defines the PostProvision hook, which is called after
    90  // machine provisioning has completed.
    91  type PostProvider interface {
    92  	PostProvision(ctx context.Context, in PostProvisionInput) error
    93  }
    94  
    95  // PostProvisionInput collects the args passed to the PostProvision hook.
    96  type PostProvisionInput struct {
    97  	Client        client.Client
    98  	InstallConfig *installconfig.InstallConfig
    99  	InfraID       string
   100  }
   101  
   102  // BootstrapDestroyer allows platform-specific behavior when
   103  // destroying bootstrap resources.
   104  type BootstrapDestroyer interface {
   105  	DestroyBootstrap(ctx context.Context, in BootstrapDestroyInput) error
   106  }
   107  
   108  // BootstrapDestroyInput collects args passed to the DestroyBootstrap hook.
   109  type BootstrapDestroyInput struct {
   110  	Client   client.Client
   111  	Metadata types.ClusterMetadata
   112  }
   113  
   114  // PostDestroyer allows platform-specific behavior after bootstrap has been destroyed and
   115  // ClusterAPI has stopped running.
   116  type PostDestroyer interface {
   117  	PostDestroy(ctx context.Context, in PostDestroyerInput) error
   118  }
   119  
   120  // PostDestroyerInput collects args passed to the PostDestroyer hook.
   121  type PostDestroyerInput struct {
   122  	Metadata types.ClusterMetadata
   123  }
   124  
   125  // Timeouts allows platform provider to override the timeouts for certain phases.
   126  type Timeouts interface {
   127  	// When waiting for the network infrastructure to become ready.
   128  	NetworkTimeout() time.Duration
   129  	// When waiting for the machines to provision.
   130  	ProvisionTimeout() time.Duration
   131  }
   132  
   133  // GatherEndpoint represents the valid values for connecting to the bootstrap nude
   134  // in a public cluster to gather logs.
   135  type GatherEndpoint string
   136  
   137  const (
   138  	// ExternalIP indicates that the machine status will include an ExternalIP that can be used for gather.
   139  	ExternalIP GatherEndpoint = "ExternalIP"
   140  
   141  	// InternalIP indicates that the machine status will only include InternalIPs.
   142  	InternalIP GatherEndpoint = "InternalIP"
   143  
   144  	// APILoadBalancer indicates that gather bootstrap should connect to the API load balancer.
   145  	APILoadBalancer GatherEndpoint = "APILoadBalancer"
   146  )