k8smgmt

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const ConfigLabel = "config"
View Source
const DefaultNamespace string = "default"
View Source
const MexAppLabel = "mex-app"
View Source
const NoScheduleMasterTaintAnnotaionNew = "node-role.kubernetes.io/control-plane"
View Source
const NoScheduleMasterTaintAnnotaionOld = "node-role.kubernetes.io/master"
View Source
const WaitDeleted string = "WaitDeleted"
View Source
const WaitRunning string = "WaitRunning"

Variables

View Source
var TestReplacementVars = deployvars.DeploymentReplaceVars{
	Deployment: deployvars.CrmReplaceVars{
		ClusterIp:    "99.99.99.99",
		CloudletName: "dummyCloudlet",
		ClusterName:  "dummyCluster",
		CloudletOrg:  "dummyCloudletOrg",
		AppOrg:       "dummyAppOrg",
		DnsZone:      "dummy.net",
	},
}

TestReplacementVars are used to syntax check app envvars

Functions

func AddManifest

func AddManifest(mf, addmf string) string

func CheckNodesReady

func CheckNodesReady(ctx context.Context, client ssh.Client, clusterInst *edgeproto.ClusterInst) (int, int, error)

CheckNodesReady returns the number of ready and not ready nodes.

func CheckPodsStatus

func CheckPodsStatus(ctx context.Context, client ssh.Client, kConfArg, namespace, selector, waitFor string, startTimer time.Time) (bool, error)

func CleanupClusterConfig

func CleanupClusterConfig(ctx context.Context, client ssh.Client, clusterInst *edgeproto.ClusterInst) error

func CleanupHelmConfigs

func CleanupHelmConfigs(ctx context.Context, client ssh.Client, appName string) error

func ClearCluster

func ClearCluster(ctx context.Context, client ssh.Client, clusterInst *edgeproto.ClusterInst) error

func ClearClusterConfig

func ClearClusterConfig(ctx context.Context, client ssh.Client, configDir, namespace, kconfArg string) error

func CreateAllNamespaces

func CreateAllNamespaces(ctx context.Context, client ssh.Client, names *KubeNames) error

CreateAllNamespaces creates all the namespaces the app will use. It does not create a manifest for the namespaces, just allows the basic dependencies can be defined against them. Manifest definition can later be used to update the namespaces.

func CreateAppInst

func CreateAppInst(ctx context.Context, accessApi platform.AccessApi, client ssh.Client, names *KubeNames, app *edgeproto.App, appInst *edgeproto.AppInst, appInstFlavor *edgeproto.Flavor) error

func CreateHelmAppInst

func CreateHelmAppInst(ctx context.Context, client ssh.Client, names *KubeNames, clusterInst *edgeproto.ClusterInst, app *edgeproto.App, appInst *edgeproto.AppInst) error

func CreateMultitenantNamespace

func CreateMultitenantNamespace(ctx context.Context, client ssh.Client, names *KubeNames) error

func DeleteAppInst

func DeleteAppInst(ctx context.Context, client ssh.Client, names *KubeNames, app *edgeproto.App, appInst *edgeproto.AppInst) error

func DeleteHelmAppInst

func DeleteHelmAppInst(ctx context.Context, client ssh.Client, names *KubeNames, clusterInst *edgeproto.ClusterInst) error

func DeleteNamespace

func DeleteNamespace(ctx context.Context, client ssh.Client, names *KubeNames) error

func DeleteNodes

func DeleteNodes(ctx context.Context, client ssh.Client, kconfArg string, nodes []string) error

func FixImagePath

func FixImagePath(origImagePath string) string

FixImagePath removes localhost and adds Docker Hub as needed. For example, networkstatic/iperf3 becomes docker.io/networkstatic/iperf3

func GetAppEnvVars

func GetAppEnvVars(ctx context.Context, app *edgeproto.App, authApi cloudcommon.RegistryAuthApi, deploymentVars *deployvars.DeploymentReplaceVars) (*[]v1.EnvVar, error)

func GetAppInstRuntime

func GetAppInstRuntime(ctx context.Context, client ssh.Client, names *KubeNames, app *edgeproto.App, appInst *edgeproto.AppInst) (*edgeproto.AppInstRuntime, error)

func GetCloudletClusterName

func GetCloudletClusterName(cluster *edgeproto.ClusterInst) string

GetCloudletClusterName return the name of the cluster including cloudlet

func GetContainerCommand

func GetContainerCommand(ctx context.Context, clusterInst *edgeproto.ClusterInst, app *edgeproto.App, appInst *edgeproto.AppInst, req *edgeproto.ExecRequest) (string, error)

func GetK8sNodeNameSuffix

func GetK8sNodeNameSuffix(clusterInst *edgeproto.ClusterInst) string

func GetKconfArg

func GetKconfArg(clusterInst *edgeproto.ClusterInst) string

func GetKconfName

func GetKconfName(clusterInst *edgeproto.ClusterInst) string

func GetNamespace

func GetNamespace(appInst *edgeproto.AppInst) string

func GetNetworkPolicy

func GetNetworkPolicy(ctx context.Context, app *edgeproto.App, appInst *edgeproto.AppInst, names *KubeNames) (string, error)

func GetNodeInfos

func GetNodeInfos(ctx context.Context, client ssh.Client, kconfArg string) ([]*edgeproto.NodeInfo, error)

func GetNormalizedClusterName

func GetNormalizedClusterName(clusterInst *edgeproto.ClusterInst) string

func GetServices

func GetServices(ctx context.Context, client ssh.Client, names *KubeNames) ([]v1.Service, error)

func LbServicePortToString

func LbServicePortToString(p *v1.ServicePort) string

func MergeEnvVars

func MergeEnvVars(ctx context.Context, accessApi platform.AccessApi, app *edgeproto.App, appInst *edgeproto.AppInst, kubeManifest string, imagePullSecrets []string, names *KubeNames, appInstFlavor *edgeproto.Flavor) (string, error)

Merge in all the environment variables into

func NormalizeName

func NormalizeName(name string) string

func PopulateAppInstLoadBalancerIps

func PopulateAppInstLoadBalancerIps(ctx context.Context, client ssh.Client, names *KubeNames, appinst *edgeproto.AppInst) error

func QuantityToUdec64

func QuantityToUdec64(q resource.Quantity) (*edgeproto.Udec64, error)

QuantityToUdec64 converts a kubernetes Quantity to a Udec64. This should only fail if the value is negative, or the Quantity does not conform to the range of values it's supposed to be limited to.

func QuantityToUint64

func QuantityToUint64(q resource.Quantity) (uint64, error)

QuantityToUint64 converts a kubernetes Quantity to a uint64. This fails if the quantity is negative or has decimal precision.

func SetMasterNoscheduleTaint

func SetMasterNoscheduleTaint(ctx context.Context, client ssh.Client, masterName string, kubeconfig string, action NoScheduleMasterTaintAction) error

func UpdateAppInst

func UpdateAppInst(ctx context.Context, accessApi platform.AccessApi, client ssh.Client, names *KubeNames, app *edgeproto.App, appInst *edgeproto.AppInst, appInstFlavor *edgeproto.Flavor) error

func UpdateHelmAppInst

func UpdateHelmAppInst(ctx context.Context, client ssh.Client, names *KubeNames, app *edgeproto.App, appInst *edgeproto.AppInst) error

func UpdateLoadBalancerPortMap

func UpdateLoadBalancerPortMap(ctx context.Context, client ssh.Client, names *KubeNames, portMap map[string]string) error

func UpgradeConfig

func UpgradeConfig(ctx context.Context, caches *platform.Caches, sharedRootLBClient ssh.Client, getClient func(context.Context, *edgeproto.ClusterInst, string) (ssh.Client, error)) error

This function is called after CRM starts and has received all the cache data from the controller.

func WaitForAppInst

func WaitForAppInst(ctx context.Context, client ssh.Client, names *KubeNames, app *edgeproto.App, waitFor string) error

WaitForAppInst waits for pods to either start or result in an error if WaitRunning specified, or if WaitDeleted is specified then wait for them to all disappear.

func WaitNodesReady

func WaitNodesReady(ctx context.Context, client ssh.Client, clusterInst *edgeproto.ClusterInst, wantReadyNodesCount int, delay time.Duration, retries int) error

func WriteDeploymentManifestToFile

func WriteDeploymentManifestToFile(ctx context.Context, accessApi platform.AccessApi, client ssh.Client, names *KubeNames, app *edgeproto.App, appInst *edgeproto.AppInst, appInstFlavor *edgeproto.Flavor) error

Types

type KubeNames

type KubeNames struct {
	AppName                    string
	AppVersion                 string
	AppOrg                     string
	AppInstName                string
	AppInstOrg                 string
	HelmAppName                string
	AppURI                     string
	AppImage                   string
	AppRevision                string
	AppInstRevision            string
	ClusterName                string
	K8sNodeNameSuffix          string
	OperatorName               string
	ServiceNames               []string
	DeveloperDefinedNamespaces []string // namespaces included by developer in manifest
	KconfName                  string
	KconfArg                   string
	DeploymentType             string
	ImagePullSecrets           []string
	ImagePaths                 []string
	IsUriIPAddr                bool
	MultitenantNamespace       string // for apps launched in a multi-tenant cluster
	BaseKconfName              string
}

func GetKubeNames

func GetKubeNames(clusterInst *edgeproto.ClusterInst, app *edgeproto.App, appInst *edgeproto.AppInst, opts ...KubeNamesOp) (*KubeNames, error)

GetKubeNames udpates kubeNames with normalized strings for the included clusterinst, app, and appisnt

func (*KubeNames) ContainsService

func (k *KubeNames) ContainsService(svc string) bool

type KubeNamesOp

type KubeNamesOp func(k *KubeNames) error

type NoScheduleMasterTaintAction

type NoScheduleMasterTaintAction string
const NoScheduleMasterTaintAdd NoScheduleMasterTaintAction = "master-noschedule-taint-add"
const NoScheduleMasterTaintNone NoScheduleMasterTaintAction = "master-noschedule-taint-none"
const NoScheduleMasterTaintRemove NoScheduleMasterTaintAction = "master-noschedule-taint-remove"

type Nodes

type Nodes struct {
	ApiVersion string    `json:"apiVersion"`
	Items      []v1.Node `json:"items"`
}

Jump to

Keyboard shortcuts

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