k8sapi

package
v2.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: AGPL-3.0 Imports: 33 Imported by: 0

Documentation

Overview

Package k8sapi is used to interact with the Kubernetes API to create or update required resources.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Initialize(kubeconfig []byte) error
	CreateConfigMap(ctx context.Context, configMap corev1.ConfigMap) error
	AddNodeSelectorsToDeployment(ctx context.Context, selectors map[string]string, name string, namespace string) error
	ListAllNamespaces(ctx context.Context) (*corev1.NamespaceList, error)
	AnnotateNode(ctx context.Context, nodeName, annotationKey, annotationValue string) error
	EnforceCoreDNSSpread(ctx context.Context) error
	PatchFirstNodePodCIDR(ctx context.Context, firstNodePodCIDR string) error
}

Client provides the functions to talk to the k8s API.

type KubdeadmConfiguration added in v2.2.0

type KubdeadmConfiguration struct{}

KubdeadmConfiguration is used to generate kubeadm configurations.

func (*KubdeadmConfiguration) InitConfiguration added in v2.2.0

func (c *KubdeadmConfiguration) InitConfiguration(externalCloudProvider bool, clusterVersion string) KubeadmInitYAML

InitConfiguration returns a new init configuration.

func (*KubdeadmConfiguration) JoinConfiguration added in v2.2.0

func (c *KubdeadmConfiguration) JoinConfiguration(externalCloudProvider bool) KubeadmJoinYAML

JoinConfiguration returns a new kubeadm join configuration.

type KubeadmInitYAML

type KubeadmInitYAML struct {
	InitConfiguration    kubeadm.InitConfiguration
	ClusterConfiguration kubeadm.ClusterConfiguration
	KubeletConfiguration kubeletconf.KubeletConfiguration
}

KubeadmInitYAML holds configuration for kubeadm init workflow.

func (*KubeadmInitYAML) Marshal

func (k *KubeadmInitYAML) Marshal() ([]byte, error)

Marshal into a k8s resource YAML.

func (*KubeadmInitYAML) SetCertSANs

func (k *KubeadmInitYAML) SetCertSANs(certSANs []string)

SetCertSANs sets the SANs for the certificate.

func (*KubeadmInitYAML) SetClusterName added in v2.6.0

func (k *KubeadmInitYAML) SetClusterName(clusterName string)

SetClusterName sets the name of the Kubernetes cluster. This name is reflected in the kubeconfig file and in the name of the default admin user.

func (*KubeadmInitYAML) SetControlPlaneEndpoint

func (k *KubeadmInitYAML) SetControlPlaneEndpoint(controlPlaneEndpoint string)

SetControlPlaneEndpoint sets the control plane endpoint if controlPlaneEndpoint is not empty.

func (*KubeadmInitYAML) SetNodeIP

func (k *KubeadmInitYAML) SetNodeIP(nodeIP string)

SetNodeIP sets the node IP.

func (*KubeadmInitYAML) SetNodeName

func (k *KubeadmInitYAML) SetNodeName(nodeName string)

SetNodeName sets name of node.

func (*KubeadmInitYAML) SetProviderID

func (k *KubeadmInitYAML) SetProviderID(providerID string)

SetProviderID sets the provider ID.

type KubeadmJoinYAML

type KubeadmJoinYAML struct {
	JoinConfiguration    kubeadm.JoinConfiguration
	KubeletConfiguration kubeletconf.KubeletConfiguration
}

KubeadmJoinYAML holds configuration for kubeadm join workflow.

func (*KubeadmJoinYAML) AppendDiscoveryTokenCaCertHash

func (k *KubeadmJoinYAML) AppendDiscoveryTokenCaCertHash(discoveryTokenCaCertHash string)

AppendDiscoveryTokenCaCertHash appends another trusted discovery token CA hash.

func (*KubeadmJoinYAML) Marshal

func (k *KubeadmJoinYAML) Marshal() ([]byte, error)

Marshal into a k8s resource YAML.

func (*KubeadmJoinYAML) SetAPIServerEndpoint

func (k *KubeadmJoinYAML) SetAPIServerEndpoint(apiServerEndpoint string)

SetAPIServerEndpoint sets the api server endpoint.

func (*KubeadmJoinYAML) SetControlPlane

func (k *KubeadmJoinYAML) SetControlPlane(advertiseAddress string)

SetControlPlane sets the control plane with the advertised address.

func (*KubeadmJoinYAML) SetNodeIP

func (k *KubeadmJoinYAML) SetNodeIP(nodeIP string)

SetNodeIP sets the node IP.

func (*KubeadmJoinYAML) SetNodeName

func (k *KubeadmJoinYAML) SetNodeName(nodeName string)

SetNodeName sets the node name.

func (*KubeadmJoinYAML) SetProviderID

func (k *KubeadmJoinYAML) SetProviderID(providerID string)

SetProviderID sets the provider ID.

func (*KubeadmJoinYAML) SetToken

func (k *KubeadmJoinYAML) SetToken(token string)

SetToken sets the boostrap token.

type KubernetesUtil

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

KubernetesUtil provides low level management of the kubernetes cluster.

func NewKubernetesUtil

func NewKubernetesUtil() *KubernetesUtil

NewKubernetesUtil creates a new KubernetesUtil.

func (*KubernetesUtil) FixCilium

func (k *KubernetesUtil) FixCilium(ctx context.Context) error

FixCilium fixes https://github.com/cilium/cilium/issues/19958 Instead of a rollout restart of the Cilium DaemonSet, it only restarts the local Cilium Pod.

func (*KubernetesUtil) InitCluster

func (k *KubernetesUtil) InitCluster(
	ctx context.Context, initConfig []byte, nodeName, clusterName string, ips []net.IP, controlPlaneHost, controlPlanePort string, conformanceMode bool, log *logger.Logger,
) ([]byte, error)

InitCluster instruments kubeadm to initialize the K8s cluster. On success an admin kubeconfig file is returned.

func (*KubernetesUtil) InstallComponents

func (k *KubernetesUtil) InstallComponents(ctx context.Context, kubernetesComponents components.Components) error

InstallComponents installs the kubernetes components passed from the CLI.

func (*KubernetesUtil) JoinCluster

func (k *KubernetesUtil) JoinCluster(ctx context.Context, joinConfig []byte, peerRole role.Role, controlPlaneHost, controlPlanePort string, log *logger.Logger) error

JoinCluster joins existing Kubernetes cluster using kubeadm join.

func (*KubernetesUtil) StartKubelet

func (k *KubernetesUtil) StartKubelet() error

StartKubelet enables and starts the kubelet systemd unit.

func (*KubernetesUtil) WaitForCilium added in v2.7.0

func (k *KubernetesUtil) WaitForCilium(ctx context.Context, log *logger.Logger) error

WaitForCilium waits until Cilium reports a healthy status over its /healthz endpoint.

type SetupPodNetworkInput

type SetupPodNetworkInput struct {
	CloudProvider     string
	NodeName          string
	FirstNodePodCIDR  string
	SubnetworkPodCIDR string
	LoadBalancerHost  string
	LoadBalancerPort  string
}

SetupPodNetworkInput holds all configuration options to setup the pod network.

Directories

Path Synopsis
Package resources contains Kubernetes configs and policies for Constellation.
Package resources contains Kubernetes configs and policies for Constellation.

Jump to

Keyboard shortcuts

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