util

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 18, 2017 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package util contains code shared between the subcommands of crinit.

Index

Constants

View Source
const (
	// DefaultClusterRegistryNamespace is the default namespace in which
	// cluster registry components are hosted.
	DefaultClusterRegistryNamespace = "clusterregistry"

	// APIServerCN is the Common Name used in the clusterregistry TLS cert.
	APIServerCN = "clusterregistry"

	// AdminCN is the Common Name used in the cluster registry client cert.
	AdminCN = "admin"

	// HostClusterLocalDNSZoneName is the DNS zone name of cluster local
	// DNS names.
	HostClusterLocalDNSZoneName = "cluster.local."

	// APIServerNameSuffix is the suffix appended to the provided cluster registry
	// name to derive the API server Deployment name.
	APIServerNameSuffix = "apiserver"

	// CredentialSuffix is the string appended to the provided cluste registry
	// name to derive the name of the Secret that contains the API server
	// certificates and keys.
	CredentialSuffix = "credentials"

	// APIServerServiceTypeFlag is the name of the flag used to set the service
	// type used for the k8s Service that exposes the cluster registry.
	APIServerServiceTypeFlag = "api-server-service-type"
)

Variables

View Source
var (

	// ComponentLabel is the label applied to resources created in the host
	// cluster.
	ComponentLabel = map[string]string{
		"app": "clusterregistry",
	}
)

Functions

func CreateNamespace

func CreateNamespace(clientset client.Interface, namespace string,
	dryRun bool) (*v1.Namespace, error)

CreateNamespace helper to create the cluster registry namespace object and return the object.

func CreateService

func CreateService(cmdOut io.Writer, clientset client.Interface, namespace,
	svcName, apiserverAdvertiseAddress string, apiserverPort *int32,
	apiserverServiceType v1.ServiceType,
	dryRun bool) (*v1.Service, []string, []string, error)

CreateService helper to create the cluster registry apiserver service object and return the object. If service type is load balancer, will wait for load balancer IP and return it and hostnames.

func GetCAKeyPair

func GetCAKeyPair(credentials *Credentials) *triple.KeyPair

GetCAKeyPair retrieves the CA key pair stored in the internal credentials structure.

func GetClientConfig

func GetClientConfig(pathOptions *clientcmd.PathOptions, context, kubeconfigPath string) clientcmd.ClientConfig

GetClientConfig gets a ClientConfig for the proivided context in kubeconfig file referenced by kubeconfigPath.

func GetClusterNodeIPs

func GetClusterNodeIPs(clientset client.Interface) ([]string, error)

GetClusterNodeIPs returns a list of the IP addresses of nodes in the cluster, with a preference for external IP addresses.

Types

type Credentials

type Credentials struct {
	// contains filtered or unexported fields
}

Credentials is the set of credentials and certificates that are used by a cluster registry.

type SubcommandOptions

type SubcommandOptions struct {
	Name                      string
	Host                      string
	ClusterRegistryNamespace  string
	Kubeconfig                string
	ServerImage               string
	EtcdImage                 string
	EtcdPVCapacity            string
	EtcdPVStorageClass        string
	EtcdPersistentStorage     bool
	DryRun                    bool
	APIServerOverridesString  string
	APIServerOverrides        map[string]string
	APIServerServiceType      v1.ServiceType
	APIServerAdvertiseAddress string
	APIServerNodePortPort     int32
	APIServerNodePortPortPtr  *int32
}

SubcommandOptions holds the configuration required by the subcommands of `clusterregistry`.

func (*SubcommandOptions) BindCommon

func (o *SubcommandOptions) BindCommon(flags *pflag.FlagSet, defaultServerImage, defaultEtcdImage string)

BindCommon adds the common options that are shared by different sub-commands to the list of flags.

func (*SubcommandOptions) CreateAPIServer

func (o *SubcommandOptions) CreateAPIServer(cmdOut io.Writer, clientset client.Interface,
	apiServerEnableHTTPBasicAuth, apiServerEnableTokenAuth, aggregated bool, ips []string,
	pvc *v1.PersistentVolumeClaim, serviceAccountName string) error

CreateAPIServer creates a Deployment for the clusterregistry and etcd.

func (*SubcommandOptions) CreateAPIServerCredentialsSecret

func (o *SubcommandOptions) CreateAPIServerCredentialsSecret(clientset client.Interface,
	credentials *Credentials) error

CreateAPIServerCredentialsSecret creates the secret containing the apiserver credentials passed in.

func (*SubcommandOptions) CreateNamespace

func (o *SubcommandOptions) CreateNamespace(cmdOut io.Writer,
	clientset client.Interface) error

CreateNamespace creates the cluster registry namespace.

func (*SubcommandOptions) CreatePVC

func (o *SubcommandOptions) CreatePVC(cmdOut io.Writer,
	clientset client.Interface, svcName string) (*v1.PersistentVolumeClaim, error)

CreatePVC creates a PersistentVolumeClaim for the cluster registry.

func (*SubcommandOptions) CreateService

func (o *SubcommandOptions) CreateService(cmdOut io.Writer,
	clientset client.Interface) (*v1.Service, []string, []string, error)

CreateService creates the cluster registry apiserver service.

func (*SubcommandOptions) GenerateCredentials

func (o *SubcommandOptions) GenerateCredentials(cmdOut io.Writer, svcName string,
	ips, hostnames []string, apiServerEnableHTTPBasicAuth,
	apiServerEnableTokenAuth bool) (*Credentials, error)

GenerateCredentials creates the credentials for apiserver secret.

func (*SubcommandOptions) MarshalOptions

func (o *SubcommandOptions) MarshalOptions() error

MarshalOptions marshals options if necessary.

func (*SubcommandOptions) SetName

func (o *SubcommandOptions) SetName(args []string) error

SetName sets the name of the cluster registry.

func (*SubcommandOptions) UpdateKubeconfig

func (o *SubcommandOptions) UpdateKubeconfig(cmdOut io.Writer,
	pathOptions *clientcmd.PathOptions, svc *v1.Service, ips, hostnames []string,
	credentials *Credentials) error

UpdateKubeconfig handles updating the kubeconfig by building up the endpoint while printing and logging progress.

func (*SubcommandOptions) ValidateCommonOptions

func (o *SubcommandOptions) ValidateCommonOptions() error

ValidateCommonOptions validates the options that are shared across different sub-commands.

func (*SubcommandOptions) WaitForAPIServer

func (o *SubcommandOptions) WaitForAPIServer(cmdOut io.Writer,
	clientset client.Interface, pathOptions *clientcmd.PathOptions,
	ips, hostnames []string, svc *v1.Service) error

WaitForAPIServer blocks until the clusterregistry API server to be healthy.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL