k8s

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2023 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Overview

Copyright © 2021 Antoine Martin <antoine@openance.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright © 2021 Antoine Martin <antoine@openance.com>

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var ApplicationSchemaGroupVersionKind = schema.GroupVersionKind{Group: "argoproj.io", Version: "v1alpha1", Kind: "Application"}
View Source
var KubernetesVersion = "1.26.0"

Functions

func AreWorkloadsReady added in v0.1.19

func AreWorkloadsReady(config *Config, callback WorkloadStateCallbackFunc) wait.ConditionFunc

func CleanConfig

func CleanConfig() (err error)

func CreateKubeadmConfiguration added in v0.2.0

func CreateKubeadmConfiguration(wr io.Writer, config *KubeadmConfig) error

func GetIkniteConfigMap added in v0.1.20

func GetIkniteConfigMap(client *kubernetes.Clientset) (cm *corev1.ConfigMap, err error)

func OkString added in v0.1.19

func OkString(b bool) string

func RunKubeadm

func RunKubeadm(parameters []string) (err error)

func RunKubeadmInit

func RunKubeadmInit(config *KubeadmConfig) error

func StatusViewerFor added in v0.1.19

func StatusViewerFor(kind schema.GroupKind) (polymorphichelpers.StatusViewer, error)

func WriteIkniteConfigMap added in v0.1.20

func WriteIkniteConfigMap(client *kubernetes.Clientset, cm *corev1.ConfigMap) (res *corev1.ConfigMap, err error)

func WriteKubeadmConfiguration added in v0.2.0

func WriteKubeadmConfiguration(fs afero.Fs, config *KubeadmConfig) (f afero.File, err error)

Types

type Application added in v0.1.19

type Application struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata" protobuf:"bytes,1,opt,name=metadata"`
	Status            ApplicationStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
}

type ApplicationStatus added in v0.1.19

type ApplicationStatus struct {
	Sync   SyncStatus   `json:"sync,omitempty" protobuf:"bytes,2,opt,name=sync"`
	Health HealthStatus `json:"health,omitempty" protobuf:"bytes,3,opt,name=health"`
}

type ApplicationStatusViewer added in v0.1.19

type ApplicationStatusViewer struct{}

func (*ApplicationStatusViewer) Status added in v0.1.19

func (s *ApplicationStatusViewer) Status(obj runtime.Unstructured, revision int64) (string, bool, error)

type Config

type Config api.Config

func LoadFromDefault

func LoadFromDefault() (*Config, error)

LoadFromDefault loads the configuration from the default admin.conf file, usually located at /etc/kubernetes/admin.conf.

func LoadFromFile added in v0.1.15

func LoadFromFile(filename string) (*Config, error)

LoadFromFile loads the configuration from the file specified by filename.

func (*Config) CheckClusterRunning

func (config *Config) CheckClusterRunning(retries, okResponses, waitTime int) error

CheckClusterRunning checks that the cluster is running by requesting the API server /readyz endpoint. It checks retries times and waits for waitTime milliseconds between each check. It needs at least okResponses good responses from the server.

func (*Config) Client

func (config *Config) Client() (client *kubernetes.Clientset, err error)

Client returns a clientset for config.

func (*Config) IsConfigServerAddress

func (config *Config) IsConfigServerAddress(address string) bool

IsConfigServerAddress checks that config points to the server at ip IP address

func (*Config) RESTClient added in v0.1.19

func (config *Config) RESTClient() *RESTClientGetter

func (*Config) RenameConfig

func (c *Config) RenameConfig(newName string) *Config

RenameConfig changes the name of the cluster and the context from the default (kubernetes) to newName in c.

func (*Config) RestartProxy

func (config *Config) RestartProxy() (err error)

RestartProxy restarts kube-proxy after config has been updated. This needs to be done after an IP address change. The restart method is taken from kubectl: https://github.com/kubernetes/kubectl/blob/652881798563c00c1895ded6ced819030bfaa4d7/pkg/polymorphichelpers/objectrestarter.go#L81

func (*Config) WaitForWorkloads added in v0.1.19

func (config *Config) WaitForWorkloads(timeout time.Duration, callback WorkloadStateCallbackFunc) error

func (*Config) WriteToFile

func (config *Config) WriteToFile(filename string) error

WriteToFile writes the config configuration to the file pointed by filename. it returns the appropriate error in case of failure.

type HealthStatus added in v0.1.19

type HealthStatus struct {
	// Status holds the status code of the application or resource
	Status string `json:"status,omitempty" protobuf:"bytes,1,opt,name=status"`
	// Message is a human-readable informational message describing the health status
	Message string `json:"message,omitempty" protobuf:"bytes,2,opt,name=message"`
}

type KubeadmConfig added in v0.2.0

type KubeadmConfig struct {
	Ip                string `mapstructure:"ip"`
	KubernetesVersion string `mapstructure:"kubernetes_version"`
	DomainName        string `mapstructure:"domain_name"`
	CreateIp          bool   `mapstructure:"create_ip"`
	NetworkInterface  string `mapstructure:"network_interface"`
	EnableMDNS        bool   `mapstructure:"enable_mdns"`
}

func (*KubeadmConfig) GetApiEndPoint added in v0.2.0

func (c *KubeadmConfig) GetApiEndPoint() string

type RESTClientGetter added in v0.1.19

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

func (*RESTClientGetter) AllWorkloadStates added in v0.1.19

func (client *RESTClientGetter) AllWorkloadStates() (result []*WorkloadState, err error)

func (*RESTClientGetter) HasApplications added in v0.1.19

func (client *RESTClientGetter) HasApplications() (has bool, err error)

func (*RESTClientGetter) ToDiscoveryClient added in v0.1.19

func (r *RESTClientGetter) ToDiscoveryClient() (discovery.CachedDiscoveryInterface, error)

func (*RESTClientGetter) ToRESTConfig added in v0.1.19

func (r *RESTClientGetter) ToRESTConfig() (*rest.Config, error)

func (*RESTClientGetter) ToRESTMapper added in v0.1.19

func (r *RESTClientGetter) ToRESTMapper() (meta.RESTMapper, error)

func (*RESTClientGetter) ToRawKubeConfigLoader added in v0.1.19

func (r *RESTClientGetter) ToRawKubeConfigLoader() clientcmd.ClientConfig

type SyncStatus added in v0.1.19

type SyncStatus struct {
	Status string `json:"status" protobuf:"bytes,1,opt,name=status,casttype=SyncStatusCode"`
}

type WorkloadState added in v0.1.19

type WorkloadState struct {
	Namespace string
	Name      string
	Ok        bool
	Message   string
}

func (*WorkloadState) LongString added in v0.1.19

func (r *WorkloadState) LongString() string

func (*WorkloadState) String added in v0.1.19

func (r *WorkloadState) String() string

type WorkloadStateCallbackFunc added in v0.1.19

type WorkloadStateCallbackFunc func(state bool, total int, ready []*WorkloadState, unready []*WorkloadState)

Jump to

Keyboard shortcuts

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