...

Package apiclient

import "k8s.io/kubernetes/cmd/kubeadm/app/util/apiclient"
Overview
Index

Overview ▾

Index ▾

func CreateOrMutateConfigMap(client clientset.Interface, cm *v1.ConfigMap, mutator ConfigMapMutator) error
func CreateOrRetainConfigMap(client clientset.Interface, cm *v1.ConfigMap, configMapName string) error
func CreateOrRetainDeployment(client clientset.Interface, deploy *apps.Deployment, deployName string) error
func CreateOrUpdateClusterRole(client clientset.Interface, clusterRole *rbac.ClusterRole) error
func CreateOrUpdateClusterRoleBinding(client clientset.Interface, clusterRoleBinding *rbac.ClusterRoleBinding) error
func CreateOrUpdateConfigMap(client clientset.Interface, cm *v1.ConfigMap) error
func CreateOrUpdateDaemonSet(client clientset.Interface, ds *apps.DaemonSet) error
func CreateOrUpdateDeployment(client clientset.Interface, deploy *apps.Deployment) error
func CreateOrUpdateRole(client clientset.Interface, role *rbac.Role) error
func CreateOrUpdateRoleBinding(client clientset.Interface, roleBinding *rbac.RoleBinding) error
func CreateOrUpdateSecret(client clientset.Interface, secret *v1.Secret) error
func CreateOrUpdateServiceAccount(client clientset.Interface, sa *v1.ServiceAccount) error
func DefaultMarshalFunc(obj runtime.Object, gv schema.GroupVersion) ([]byte, error)
func GetConfigMapWithShortRetry(client clientset.Interface, namespace, name string) (*v1.ConfigMap, error)
func NewDryRunClient(drg DryRunGetter, w io.Writer) clientset.Interface
func NewDryRunClientWithOpts(opts DryRunClientOptions) clientset.Interface
func PatchNode(client clientset.Interface, nodeName string, patchFn func(*v1.Node)) error
func PatchNodeOnce(client clientset.Interface, nodeName string, patchFn func(*v1.Node), lastError *error) func(context.Context) (bool, error)
func PrintBytesWithLinePrefix(w io.Writer, objBytes []byte, linePrefix string)
type ClientBackedDryRunGetter
    func NewClientBackedDryRunGetter(config *rest.Config) (*ClientBackedDryRunGetter, error)
    func NewClientBackedDryRunGetterFromKubeconfig(file string) (*ClientBackedDryRunGetter, error)
    func (clg *ClientBackedDryRunGetter) Client() clientset.Interface
    func (clg *ClientBackedDryRunGetter) HandleGetAction(action core.GetAction) (bool, runtime.Object, error)
    func (clg *ClientBackedDryRunGetter) HandleListAction(action core.ListAction) (bool, runtime.Object, error)
type ConfigMapMutator
type DryRunClientOptions
    func GetDefaultDryRunClientOptions(drg DryRunGetter, w io.Writer) DryRunClientOptions
type DryRunGetter
type InitDryRunGetter
    func NewInitDryRunGetter(controlPlaneName string, serviceSubnet string) *InitDryRunGetter
    func (idr *InitDryRunGetter) HandleGetAction(action core.GetAction) (bool, runtime.Object, error)
    func (idr *InitDryRunGetter) HandleListAction(action core.ListAction) (bool, runtime.Object, error)
type KubeWaiter
    func (w *KubeWaiter) SetTimeout(timeout time.Duration)
    func (w *KubeWaiter) WaitForAPI() error
    func (w *KubeWaiter) WaitForControlPlaneComponents(cfg *kubeadmapi.ClusterConfiguration) error
    func (w *KubeWaiter) WaitForKubelet() error
    func (w *KubeWaiter) WaitForPodToDisappear(podName string) error
    func (w *KubeWaiter) WaitForPodsWithLabel(kvLabel string) error
    func (w *KubeWaiter) WaitForStaticPodControlPlaneHashes(nodeName string) (map[string]string, error)
    func (w *KubeWaiter) WaitForStaticPodHashChange(nodeName, component, previousHash string) error
    func (w *KubeWaiter) WaitForStaticPodSingleHash(nodeName string, component string) (string, error)
type MarshalFunc
type Waiter
    func NewKubeWaiter(client clientset.Interface, timeout time.Duration, writer io.Writer) Waiter

Package files

clientbacked_dryrun.go dryrunclient.go idempotency.go init_dryrun.go wait.go

func CreateOrMutateConfigMap

func CreateOrMutateConfigMap(client clientset.Interface, cm *v1.ConfigMap, mutator ConfigMapMutator) error

CreateOrMutateConfigMap tries to create the ConfigMap provided as cm. If the resource exists already, the latest version will be fetched from the cluster and mutator callback will be called on it, then an Update of the mutated ConfigMap will be performed. This function is resilient to conflicts, and a retry will be issued if the ConfigMap was modified on the server between the refresh and the update (while the mutation was taking place)

func CreateOrRetainConfigMap

func CreateOrRetainConfigMap(client clientset.Interface, cm *v1.ConfigMap, configMapName string) error

CreateOrRetainConfigMap creates a ConfigMap if the target resource doesn't exist. If the resource exists already, this function will retain the resource instead.

func CreateOrRetainDeployment

func CreateOrRetainDeployment(client clientset.Interface, deploy *apps.Deployment, deployName string) error

CreateOrRetainDeployment creates a Deployment if the target resource doesn't exist. If the resource exists already, this function will retain the resource instead.

func CreateOrUpdateClusterRole

func CreateOrUpdateClusterRole(client clientset.Interface, clusterRole *rbac.ClusterRole) error

CreateOrUpdateClusterRole creates a ClusterRole if the target resource doesn't exist. If the resource exists already, this function will update the resource instead.

func CreateOrUpdateClusterRoleBinding

func CreateOrUpdateClusterRoleBinding(client clientset.Interface, clusterRoleBinding *rbac.ClusterRoleBinding) error

CreateOrUpdateClusterRoleBinding creates a ClusterRoleBinding if the target resource doesn't exist. If the resource exists already, this function will update the resource instead.

func CreateOrUpdateConfigMap

func CreateOrUpdateConfigMap(client clientset.Interface, cm *v1.ConfigMap) error

CreateOrUpdateConfigMap creates a ConfigMap if the target resource doesn't exist. If the resource exists already, this function will update the resource instead.

func CreateOrUpdateDaemonSet

func CreateOrUpdateDaemonSet(client clientset.Interface, ds *apps.DaemonSet) error

CreateOrUpdateDaemonSet creates a DaemonSet if the target resource doesn't exist. If the resource exists already, this function will update the resource instead.

func CreateOrUpdateDeployment

func CreateOrUpdateDeployment(client clientset.Interface, deploy *apps.Deployment) error

CreateOrUpdateDeployment creates a Deployment if the target resource doesn't exist. If the resource exists already, this function will update the resource instead.

func CreateOrUpdateRole

func CreateOrUpdateRole(client clientset.Interface, role *rbac.Role) error

CreateOrUpdateRole creates a Role if the target resource doesn't exist. If the resource exists already, this function will update the resource instead.

func CreateOrUpdateRoleBinding

func CreateOrUpdateRoleBinding(client clientset.Interface, roleBinding *rbac.RoleBinding) error

CreateOrUpdateRoleBinding creates a RoleBinding if the target resource doesn't exist. If the resource exists already, this function will update the resource instead.

func CreateOrUpdateSecret

func CreateOrUpdateSecret(client clientset.Interface, secret *v1.Secret) error

CreateOrUpdateSecret creates a Secret if the target resource doesn't exist. If the resource exists already, this function will update the resource instead.

func CreateOrUpdateServiceAccount

func CreateOrUpdateServiceAccount(client clientset.Interface, sa *v1.ServiceAccount) error

CreateOrUpdateServiceAccount creates a ServiceAccount if the target resource doesn't exist. If the resource exists already, this function will update the resource instead.

func DefaultMarshalFunc

func DefaultMarshalFunc(obj runtime.Object, gv schema.GroupVersion) ([]byte, error)

DefaultMarshalFunc is the default MarshalFunc used; uses YAML to print objects to the user

func GetConfigMapWithShortRetry

func GetConfigMapWithShortRetry(client clientset.Interface, namespace, name string) (*v1.ConfigMap, error)

GetConfigMapWithShortRetry tries to retrieve a ConfigMap using the given client, retrying for a short time if it gets an unexpected error. The main usage of this function is in areas of the code that fallback to a default ConfigMap value in case the one from the API cannot be quickly obtained.

func NewDryRunClient

func NewDryRunClient(drg DryRunGetter, w io.Writer) clientset.Interface

NewDryRunClient is a wrapper for NewDryRunClientWithOpts using some default values

func NewDryRunClientWithOpts

func NewDryRunClientWithOpts(opts DryRunClientOptions) clientset.Interface

NewDryRunClientWithOpts returns a clientset.Interface that can be used normally for talking to the Kubernetes API. This client doesn't apply changes to the backend. The client gets GET/LIST values from the DryRunGetter implementation. This client logs all I/O to the writer w in YAML format

func PatchNode

func PatchNode(client clientset.Interface, nodeName string, patchFn func(*v1.Node)) error

PatchNode tries to patch a node using patchFn for the actual mutating logic. Retries are provided by the wait package.

func PatchNodeOnce

func PatchNodeOnce(client clientset.Interface, nodeName string, patchFn func(*v1.Node), lastError *error) func(context.Context) (bool, error)

PatchNodeOnce executes patchFn on the node object found by the node name.

func PrintBytesWithLinePrefix

func PrintBytesWithLinePrefix(w io.Writer, objBytes []byte, linePrefix string)

PrintBytesWithLinePrefix prints objBytes to writer w with linePrefix in the beginning of every line

type ClientBackedDryRunGetter

ClientBackedDryRunGetter implements the DryRunGetter interface for use in NewDryRunClient() and proxies all GET and LIST requests to the backing API server reachable via rest.Config

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

func NewClientBackedDryRunGetter

func NewClientBackedDryRunGetter(config *rest.Config) (*ClientBackedDryRunGetter, error)

NewClientBackedDryRunGetter creates a new ClientBackedDryRunGetter instance based on the rest.Config object

func NewClientBackedDryRunGetterFromKubeconfig

func NewClientBackedDryRunGetterFromKubeconfig(file string) (*ClientBackedDryRunGetter, error)

NewClientBackedDryRunGetterFromKubeconfig creates a new ClientBackedDryRunGetter instance from the given KubeConfig file

func (*ClientBackedDryRunGetter) Client

func (clg *ClientBackedDryRunGetter) Client() clientset.Interface

Client gets the backing clientset.Interface

func (*ClientBackedDryRunGetter) HandleGetAction

func (clg *ClientBackedDryRunGetter) HandleGetAction(action core.GetAction) (bool, runtime.Object, error)

HandleGetAction handles GET actions to the dryrun clientset this interface supports

func (*ClientBackedDryRunGetter) HandleListAction

func (clg *ClientBackedDryRunGetter) HandleListAction(action core.ListAction) (bool, runtime.Object, error)

HandleListAction handles LIST actions to the dryrun clientset this interface supports

type ConfigMapMutator

ConfigMapMutator is a function that mutates the given ConfigMap and optionally returns an error

type ConfigMapMutator func(*v1.ConfigMap) error

type DryRunClientOptions

DryRunClientOptions specifies options to pass to NewDryRunClientWithOpts in order to get a dryrun clientset

type DryRunClientOptions struct {
    Writer          io.Writer
    Getter          DryRunGetter
    PrependReactors []core.Reactor
    AppendReactors  []core.Reactor
    MarshalFunc     MarshalFunc
    PrintGETAndLIST bool
}

func GetDefaultDryRunClientOptions

func GetDefaultDryRunClientOptions(drg DryRunGetter, w io.Writer) DryRunClientOptions

GetDefaultDryRunClientOptions returns the default DryRunClientOptions values

type DryRunGetter

DryRunGetter is an interface that must be supplied to the NewDryRunClient function in order to construct a fully functional fake dryrun clientset

type DryRunGetter interface {
    HandleGetAction(core.GetAction) (bool, runtime.Object, error)
    HandleListAction(core.ListAction) (bool, runtime.Object, error)
}

type InitDryRunGetter

InitDryRunGetter implements the DryRunGetter interface and can be used to GET/LIST values in the dryrun fake clientset Need to handle these routes in a special manner: - GET /default/services/kubernetes -- must return a valid Service - GET /clusterrolebindings/system:nodes -- can safely return a NotFound error - GET /nodes/<node-name> -- must return a valid Node - ...all other, unknown GETs/LISTs will be logged

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

func NewInitDryRunGetter

func NewInitDryRunGetter(controlPlaneName string, serviceSubnet string) *InitDryRunGetter

NewInitDryRunGetter creates a new instance of the InitDryRunGetter struct

func (*InitDryRunGetter) HandleGetAction

func (idr *InitDryRunGetter) HandleGetAction(action core.GetAction) (bool, runtime.Object, error)

HandleGetAction handles GET actions to the dryrun clientset this interface supports

func (*InitDryRunGetter) HandleListAction

func (idr *InitDryRunGetter) HandleListAction(action core.ListAction) (bool, runtime.Object, error)

HandleListAction handles GET actions to the dryrun clientset this interface supports. Currently there are no known LIST calls during kubeadm init this code has to take care of.

type KubeWaiter

KubeWaiter is an implementation of Waiter that is backed by a Kubernetes client

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

func (*KubeWaiter) SetTimeout

func (w *KubeWaiter) SetTimeout(timeout time.Duration)

SetTimeout adjusts the timeout to the specified duration

func (*KubeWaiter) WaitForAPI

func (w *KubeWaiter) WaitForAPI() error

WaitForAPI waits for the API Server's /healthz endpoint to report "ok"

func (*KubeWaiter) WaitForControlPlaneComponents

func (w *KubeWaiter) WaitForControlPlaneComponents(cfg *kubeadmapi.ClusterConfiguration) error

WaitForControlPlaneComponents waits for all control plane components to report "ok" on /healthz

func (*KubeWaiter) WaitForKubelet

func (w *KubeWaiter) WaitForKubelet() error

WaitForKubelet blocks until the kubelet /healthz endpoint returns 'ok'.

func (*KubeWaiter) WaitForPodToDisappear

func (w *KubeWaiter) WaitForPodToDisappear(podName string) error

WaitForPodToDisappear blocks until it timeouts or gets a "NotFound" response from the API Server when getting the Static Pod in question

func (*KubeWaiter) WaitForPodsWithLabel

func (w *KubeWaiter) WaitForPodsWithLabel(kvLabel string) error

WaitForPodsWithLabel will lookup pods with the given label and wait until they are all reporting status as running.

func (*KubeWaiter) WaitForStaticPodControlPlaneHashes

func (w *KubeWaiter) WaitForStaticPodControlPlaneHashes(nodeName string) (map[string]string, error)

WaitForStaticPodControlPlaneHashes blocks until it timeouts or gets a hash map for all components and their Static Pods

func (*KubeWaiter) WaitForStaticPodHashChange

func (w *KubeWaiter) WaitForStaticPodHashChange(nodeName, component, previousHash string) error

WaitForStaticPodHashChange blocks until it timeouts or notices that the Mirror Pod (for the Static Pod, respectively) has changed This implicitly means this function blocks until the kubelet has restarted the Static Pod in question

func (*KubeWaiter) WaitForStaticPodSingleHash

func (w *KubeWaiter) WaitForStaticPodSingleHash(nodeName string, component string) (string, error)

WaitForStaticPodSingleHash blocks until it timeouts or gets a hash for a single component and its Static Pod

type MarshalFunc

MarshalFunc takes care of converting any object to a byte array for displaying the object to the user

type MarshalFunc func(runtime.Object, schema.GroupVersion) ([]byte, error)

type Waiter

Waiter is an interface for waiting for criteria in Kubernetes to happen

type Waiter interface {
    // WaitForControlPlaneComponents waits for all control plane components to report "ok" on /healthz
    WaitForControlPlaneComponents(cfg *kubeadmapi.ClusterConfiguration) error
    // WaitForAPI waits for the API Server's /healthz endpoint to become "ok"
    // TODO: remove WaitForAPI once WaitForAllControlPlaneComponents goes GA:
    // https://github.com/kubernetes/kubeadm/issues/2907
    WaitForAPI() error
    // WaitForPodsWithLabel waits for Pods in the kube-system namespace to become Ready
    WaitForPodsWithLabel(kvLabel string) error
    // WaitForPodToDisappear waits for the given Pod in the kube-system namespace to be deleted
    WaitForPodToDisappear(staticPodName string) error
    // WaitForStaticPodSingleHash fetches sha256 hash for the control plane static pod
    WaitForStaticPodSingleHash(nodeName string, component string) (string, error)
    // WaitForStaticPodHashChange waits for the given static pod component's static pod hash to get updated.
    // By doing that we can be sure that the kubelet has restarted the given Static Pod
    WaitForStaticPodHashChange(nodeName, component, previousHash string) error
    // WaitForStaticPodControlPlaneHashes fetches sha256 hashes for the control plane static pods
    WaitForStaticPodControlPlaneHashes(nodeName string) (map[string]string, error)
    // WaitForKubelet blocks until the kubelet /healthz endpoint returns 'ok'
    WaitForKubelet() error
    // SetTimeout adjusts the timeout to the specified duration
    SetTimeout(timeout time.Duration)
}

func NewKubeWaiter

func NewKubeWaiter(client clientset.Interface, timeout time.Duration, writer io.Writer) Waiter

NewKubeWaiter returns a new Waiter object that talks to the given Kubernetes cluster