info

package
v0.0.0-...-5d16d2b Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetKubernetesApiUrlFromEnv

func GetKubernetesApiUrlFromEnv(l golog.MyLogger) (string, error)

GetKubernetesApiUrlFromEnv returns the k8s api url based on the content of standard env var :

KUBERNETES_SERVICE_HOST
KUBERNETES_SERVICE_PORT
in case the above ENV variables doesn't  exist the function returns an empty string and an error

func GetKubernetesConnInfo

func GetKubernetesConnInfo(l golog.MyLogger, defaultReadTimeout time.Duration) (*K8sInfo, ErrorConfig)

GetKubernetesConnInfo returns a K8sInfo with various information retrieved from the current k8s api url K8sInfo.CurrentNamespace contains the current namespace of the running pod K8sInfo.Token contains the bearer authentication token for the running k8s instance in which this pods lives K8sInfo.CaCert contains the certificate of the running k8s instance in which this pods lives

func GetKubernetesLatestVersion

func GetKubernetesLatestVersion(l golog.MyLogger) (string, error)

func GetOsInfo

func GetOsInfo() (*OsInfo, ErrorConfig)

func GetOsUptime

func GetOsUptime() (string, error)

func IsRunningInsideKubernetes

func IsRunningInsideKubernetes() bool

IsRunningInsideKubernetes returns true if running inside k8s orchestrator y checking if KUBERNETES_SERVICE_HOST is defined

Types

type ErrorConfig

type ErrorConfig struct {
	Err error
	Msg string
}

func (*ErrorConfig) Error

func (e *ErrorConfig) Error() string

Error returns a string with an error and a specifics message

type K8sInfo

type K8sInfo struct {
	CurrentNamespace string `json:"current_namespace"`
	Version          string `json:"version"`
	Token            string `json:"token"`
	CaCert           string `json:"ca_cert"`
}

type OsInfo

type OsInfo struct {
	Name      string `json:"name"`
	Version   string `json:"version"`
	VersionId string `json:"versionId"`
}

type RuntimeInfo

type RuntimeInfo struct {
	Hostname            string              `json:"hostname"`              // host name reported by the kernel.
	Pid                 int                 `json:"pid"`                   // process id of the caller.
	PPid                int                 `json:"ppid"`                  // process id of the caller's parent.
	Uid                 int                 `json:"uid"`                   // numeric user id of the caller.
	AppName             string              `json:"app_name"`              // name of this application
	Version             string              `json:"version"`               // version of this application
	ParamName           string              `json:"param_name"`            // value of the name parameter (_NO_PARAMETER_NAME_ if name was not set)
	RemoteAddr          string              `json:"remote_addr"`           // remote client ip address
	RequestId           string              `json:"request_id"`            // globally unique request id
	GOOS                string              `json:"goos"`                  // operating system
	GOARCH              string              `json:"goarch"`                // architecture
	Runtime             string              `json:"runtime"`               // go runtime at compilation time
	NumGoroutine        string              `json:"num_goroutine"`         // number of go routines
	OsReleaseName       string              `json:"os_release_name"`       // Linux release Name or _UNKNOWN_
	OsReleaseVersion    string              `json:"os_release_version"`    // Linux release Version or _UNKNOWN_
	OsReleaseVersionId  string              `json:"os_release_version_id"` // Linux release VersionId or _UNKNOWN_
	NumCPU              string              `json:"num_cpu"`               // number of cpu
	Uptime              string              `json:"uptime"`                // tells how long this service was started based on an internal variable
	UptimeOs            string              `json:"uptime_os"`             // tells how long system was started based on /proc/uptime
	K8sApiUrl           string              `json:"k8s_api_url"`           // url for k8s api based KUBERNETES_SERVICE_HOST
	K8sVersion          string              `json:"k8s_version"`           // version of k8s cluster
	K8sLatestVersion    string              `json:"k8s_latest_version"`    // latest version announced in https://kubernetes.io/
	K8sCurrentNamespace string              `json:"k8s_current_namespace"` // k8s namespace of this container
	EnvVars             []string            `json:"env_vars"`              // environment variables
	Headers             map[string][]string `json:"headers"`               // received headers
}

Jump to

Keyboard shortcuts

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