Documentation
¶
Overview ¶
Package aboutme provides information to a pod about itself.
Typical usage is to let the Pod auto-detect information about itself:
my, err := aboutme.FromEnv()
if err != nil {
// Error connecting to tke k8s API server
}
fmt.Printf("My Pod Name is %s", my.Name)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IPByInterface ¶
func MyIP ¶
MyIP examines the local interfaces and guesses which is its IP.
Containers tend to put the IP address in eth0, so this attempts to look up that interface and retrieve its IP. It is fairly naive. To get more thorough IP information, you may prefer to use the `net` package and look up the desired information.
Because this queries the interfaces, not the Kube API server, this could, in theory, return an IP address different from Me.IP.
Types ¶
type Me ¶
type Me struct {
ApiServer, Name string
IP, NodeIP, Namespace, SelfLink, UID string
Labels map[string]string
Annotations map[string]string
// contains filtered or unexported fields
}
func FromEnv ¶
FromEnv uses the environment to create a new Me.
To use this, a client MUST be running inside of a Pod environment. It uses a combination of environment variables and file paths to determine information about the cluster.
func (*Me) Client ¶
func (me *Me) Client() *unversioned.Client
Client returns an initialized Kubernetes API client.
func (*Me) ShuntEnv ¶
func (me *Me) ShuntEnv()
ShuntEnv puts the Me object into the environment.
The properties of Me are placed into the environment according to the following rules:
- In general, all variables are prefaced with MY_ (MY_IP, MY_NAMESPACE)
- Labels become MY_LABEL_[NAME]=[value]
- Annotations become MY_ANNOTATION_[NAME] = [value]