Documentation
¶
Overview ¶
This package contains helper functions for managing K8s cluster and Helm charts
Creating and deleting K8 manifests yamls Installing and uninstalling Helm charts Getting the status of K8s services Getting the status of K8s deployments Getting the status of K8s pods Getting the status of K8s services Managing Helm releases Managing Helm repositories
Index ¶
- type K8
- func (m *K8) ApplyYaml(yaml string, ns string) error
- func (m *K8) CheckStatusOf(ns string, checks []interface{}, not_running bool) (bool, []string, error)
- func (m *K8) CreateConfigAndContext() error
- func (m *K8) CreateNS(ns string) error
- func (m *K8) DeleteDemonSet(ns string, name string) error
- func (m *K8) DeleteDeployment(ns string, name string) error
- func (m *K8) DeleteNS(ns string) error
- func (m *K8) DeletePV(ns string, name string) error
- func (m *K8) DeletePVC(ns string, name string) error
- func (m *K8) DeletePod(ns string, name string) error
- func (m *K8) DeleteSecrets(ns string, name string) error
- func (m *K8) DeleteService(ns string, name string) error
- func (m *K8) DeleteStatefulSets(ns string, name string) error
- func (m *K8) DeleteYaml(yaml string, ns string) error
- func (m *K8) DeployHelmChart(chart_path string, release_name string, namespace string, ...) error
- func (m *K8) DryRun() bool
- func (m *K8) GetDemonSet(ns string) (*appsv1.DaemonSetList, error)
- func (m *K8) GetDeployments(ns string) (*appsv1.DeploymentList, error)
- func (m *K8) GetPods(ns string) (*v1.PodList, error)
- func (m *K8) GetSecrets(ns string) (*v1.SecretList, error)
- func (m *K8) GetServiceIP(ns string, regex_service_name string) ([]ServiceDetails, error)
- func (m *K8) GetServices(ns string) (*v1.ServiceList, error)
- func (m *K8) GetStatefulSets(ns string) (*appsv1.StatefulSetList, error)
- func (m *K8) PodCopy(ns string, src string, dst string, container_name string) (string, error)
- func (m *K8) PodExec(ns string, pod_name string, command string) (string, error)
- func (m *K8) ProcessK8File(file_data []byte, ns string, apply bool) error
- func (m *K8) RepoAdd(name string, url string, user string, password string) error
- func (m *K8) RepoUpdate() error
- func (m *K8) SetDryRun(dry_run bool)
- func (m *K8) SetVerbose(verbose bool)
- func (m *K8) String() string
- func (m *K8) UninstallHelmChart(release_name string, namespace string) error
- func (m *K8) Update(opts ...K8Option)
- func (m *K8) UpgradeHelmChart(chart_path string, release_name string, namespace string, ...) error
- func (m *K8) Verbose() bool
- type K8Option
- func OptionK8Auth(auth string) K8Option
- func OptionK8ConfigPath(config_path string) K8Option
- func OptionK8DefaultContext(default_context string) K8Option
- func OptionK8Host(host string) K8Option
- func OptionK8IgnoreSSL(ignore_ssl bool) K8Option
- func OptionK8UseTokenConnection(use_token_connection bool) K8Option
- type ServiceDetails
- type SimpleRESTClientGetter
- func (c *SimpleRESTClientGetter) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)
- func (c *SimpleRESTClientGetter) ToRESTConfig() (*rest.Config, error)
- func (c *SimpleRESTClientGetter) ToRESTMapper() (meta.RESTMapper, error)
- func (c *SimpleRESTClientGetter) ToRawKubeConfigLoader() clientcmd.ClientConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type K8 ¶
type K8 struct { DefaultContext string `json:"default_context" yaml:"default_context" flag:"context c" desc:"The default context to use"` ConfigPath string `json:"config_path" yaml:"config_path" flag:"config_path p" desc:"The path to the kube config file"` Host string `json:"host" yaml:"host" flag:"host h" desc:"The host to connect to"` Authorization string `json:"authorization" yaml:"authorization" flag:"auth a" desc:"The authorization token"` UseTokenConnection bool `` //if true, use the token connection, otherwise use the kube config file /* 167-byte string literal not displayed */ Ignore_ssl bool `json:"ignore_ssl" yaml:"ignore_ssl" flag:"ignore_ssl i" desc:"If true, ignore the ssl connection"` // contains filtered or unexported fields }
K8 is the struct for the k8 connection If you want to use the kube config file, you need to set the DefaultContext and ConfigPath DefaultContext is the default context to use ConfigPath is the path to the kube config file Host is the host to connect to You will need to set the Host and Authorization if you want to use the token connection Authorization is the authorization token UseTokenConnection if true, use the token connection, otherwise use the kube config file Ignore_ssl if true, ignore the ssl connection
func CreateK8 ¶ added in v0.2.0
CreateK8 creates a instance of the k8 type Does not create the config and context Use CreateConfigAndContext() to create the config and context opts are the options for the k8 type returns the k8 type returns an error if there is an issue
func CreateK8KubeConfig ¶
Create a instance of the k8 type default_context is the default context to use config_path is the path to the kube config file
func CreateK8Options ¶
CreateK8Options creates a instance of the k8 type opts are the options for the k8 type returns the k8 type returns an error if there is an issue
func CreateK8Token ¶
CreateK8Token creates a instance of the k8 type host is the host to connect to auth is the authorization token ignore_ssl if true, ignore the ssl connection returns the k8 type returns an error if there is an issue
func (*K8) ApplyYaml ¶
ApplyYaml applies a resource using a yaml manifest ctx: context cfg: k8 config yaml: yaml manifest ns: namespace return: error
func (*K8) CheckStatusOf ¶
func (m *K8) CheckStatusOf(ns string, checks []interface{}, not_running bool) (bool, []string, error)
CheckStatusOf checks the status of a list of checks ns: namespace checks: list of checks to perform return: bool, []string, error bool: true if all checks passed []string: list of the results of the checks error: error if any
Example: checks := []interface{}{ "deployment:nginx(.*)", "replica:nginx2(.*)", "stateful:nginx3(.*)", "demon:nginx4(.*)", "service:nginx(.*)", }
func (*K8) CreateConfigAndContext ¶ added in v0.2.0
buildRestConfig builds the rest config And add to the k8 type returns error if there is an issue
func (*K8) DeleteDemonSet ¶ added in v0.2.1
GetDemonSet gets demonsets from a k8 cluster ns: namespace return: appsv1.DaemonSetList, error
func (*K8) DeleteDeployment ¶ added in v0.2.0
func (*K8) DeleteNS ¶
DeleteNS deletes a namespace in a k8 cluster ns: namespace return: error Does not delete default namespace
func (*K8) DeletePV ¶ added in v0.2.1
DeletePV deletes a PV - ns is the namespace - name is the name of the PV - returns an error if there is one
func (*K8) DeletePVC ¶ added in v0.2.1
DeletePVC deletes a PVC - ns is the namespace - name is the name of the PVC - returns an error if there is one
func (*K8) DeletePod ¶ added in v0.2.0
DeletePod deletes a pod from a k8 cluster ns: namespace name: pod name return: error
func (*K8) DeleteSecrets ¶ added in v0.2.1
DeleteSecrets deletes secrets from a k8 cluster ns: namespace name: name of secret return: error
func (*K8) DeleteService ¶ added in v0.2.0
DeleteService deletes a service from a k8 cluster ns: namespace name: name of the service return: error
func (*K8) DeleteStatefulSets ¶ added in v0.2.1
DeleteStatefulSets deletes a statefulset from a k8 cluster ns: namespace name: name of the statefulset return: error
func (*K8) DeleteYaml ¶
DeleteYaml deletes a resource using a yaml manifest ctx: context cfg: k8 config yaml: yaml manifest ns: namespace return: error
func (*K8) DeployHelmChart ¶
func (m *K8) DeployHelmChart(chart_path string, release_name string, namespace string, configs map[string]interface{}) error
DeployHelmChart deploys a helm chart chart_path is the path to the chart to deploy release_name is the name of the release to deploy namespace is the namespace to deploy the release to configs is a map of values to pass to the chart returns nil error on success
func (*K8) DryRun ¶
DryRun returns the dry_run flag If true, do not execute the command, just print out the command
func (*K8) GetDemonSet ¶
func (m *K8) GetDemonSet(ns string) (*appsv1.DaemonSetList, error)
GetDemonSet gets demonsets from a k8 cluster ns: namespace return: appsv1.DaemonSetList, error
func (*K8) GetDeployments ¶
func (m *K8) GetDeployments(ns string) (*appsv1.DeploymentList, error)
GetDeployments gets deployments from a k8 cluster ns: namespace return: appsv1.DeploymentList, error
func (*K8) GetSecrets ¶
func (m *K8) GetSecrets(ns string) (*v1.SecretList, error)
GetSecrets gets secrets from a k8 cluster ns: namespace return: v1.SecretList, error
func (*K8) GetServiceIP ¶
func (m *K8) GetServiceIP(ns string, regex_service_name string) ([]ServiceDetails, error)
GetServiceIP gets service ip from a k8 cluster ns: namespace regex_service_name: regex to match service name return: v1.ServiceList, error
func (*K8) GetServices ¶
func (m *K8) GetServices(ns string) (*v1.ServiceList, error)
GetServices gets services from a k8 cluster ns: namespace
return: v1.ServiceList, error
func (*K8) GetStatefulSets ¶
func (m *K8) GetStatefulSets(ns string) (*appsv1.StatefulSetList, error)
GetStatefulSets gets statefulsets from a k8 cluster ns: namespace return: appsv1.StatefulSetList, error
func (*K8) PodCopy ¶
PodCopy copies a file to and from a pod ns: namespace src: source file dst: destination file container_name: container name return: stdout, error
func (*K8) PodExec ¶
PodExec executes a command in a pod ns: namespace pod_name: pod name command: command to execute return: stdout, error
func (*K8) ProcessK8File ¶ added in v0.2.0
ProcessK8File processes a k8 file with multiple definitions separated with --- file_data: file data ns: namespace apply: apply the file return: error
func (*K8) RepoAdd ¶
RepoAdd adds a helm repo name is the name of the repo url is the url of the repo user is the user to use for the repo password is the password to use for the repo
func (*K8) RepoUpdate ¶
RepoUpdate updates charts for all helm repos returns nil error on success
func (*K8) SetDryRun ¶
SetDryRun sets the dry_run flag If true, do not execute the command, just print out the command
func (*K8) SetVerbose ¶
SetVerbose sets the verbose flag If true, print out the verbose information
func (*K8) UninstallHelmChart ¶
UninstallHelmChart uninstalls a helm chart release_name is the name of the release to uninstall namespace is the namespace to uninstall the release from returns nil error on success
func (*K8) UpgradeHelmChart ¶
func (m *K8) UpgradeHelmChart(chart_path string, release_name string, namespace string, configs map[string]interface{}) error
UpgradeHelmChart upgrades a helm chart chart_path is the path to the chart to upgrade release_name is the name of the release to upgrade namespace is the namespace to upgrade the release to configs is a map of values to pass to the chart returns nil error on success
type K8Option ¶
type K8Option func(*K8)
K8Option is the option for the k8 connection
func OptionK8Auth ¶
OptionK8Auth is the option for the authorization
func OptionK8ConfigPath ¶
OptionK8ConfigPath is the option for the config path
func OptionK8DefaultContext ¶
OptionK8DefaultContext is the option for the default context
func OptionK8IgnoreSSL ¶
OptionK8IgnoreSSL is the option for the ignore ssl
func OptionK8UseTokenConnection ¶
OptionK8UseTokenConnection is the option for the use token connection
type ServiceDetails ¶ added in v0.2.2
type SimpleRESTClientGetter ¶
SimpleRESTClientGetter is a simple implementation of RESTClientGetter that
func NewRESTClientGetter ¶
func NewRESTClientGetter(namespace string, kubeConfig rest.Config) *SimpleRESTClientGetter
NewRESTClientGetter returns a new SimpleRESTClientGetter namespace is the namespace to use for requests kubeConfig is the config to use for requests returns a new SimpleRESTClientGetter
func (*SimpleRESTClientGetter) ToDiscoveryClient ¶
func (c *SimpleRESTClientGetter) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)
ToDiscoveryClient returns the DiscoveryClient returns the DiscoveryClient and nil error
func (*SimpleRESTClientGetter) ToRESTConfig ¶
func (c *SimpleRESTClientGetter) ToRESTConfig() (*rest.Config, error)
ToRESTConfig returns the RESTConfig returns the RESTConfig and nil error
func (*SimpleRESTClientGetter) ToRESTMapper ¶
func (c *SimpleRESTClientGetter) ToRESTMapper() (meta.RESTMapper, error)
ToRESTMapper returns the RESTMapper returns the RESTMapper and nil error
func (*SimpleRESTClientGetter) ToRawKubeConfigLoader ¶
func (c *SimpleRESTClientGetter) ToRawKubeConfigLoader() clientcmd.ClientConfig
ToRawKubeConfigLoader returns the RawKubeConfigLoader returns the RawKubeConfigLoader and nil error