github.com/influxdata/influxdb/v2@v2.7.6/telegraf/plugins/inputs/kubernetes.go (about) 1 package inputs 2 3 import ( 4 "errors" 5 "fmt" 6 ) 7 8 // Kubernetes is based on telegraf Kubernetes plugin 9 type Kubernetes struct { 10 baseInput 11 URL string `json:"url"` 12 } 13 14 // PluginName is based on telegraf plugin name. 15 func (k *Kubernetes) PluginName() string { 16 return "kubernetes" 17 } 18 19 // TOML encodes to toml string. 20 func (k *Kubernetes) TOML() string { 21 return fmt.Sprintf(`[[inputs.%s]] 22 ## URL for the kubelet 23 url = "%s" 24 25 ## Use bearer token for authorization. ('bearer_token' takes priority) 26 ## If both of these are empty, we'll use the default serviceaccount: 27 ## at: /run/secrets/kubernetes.io/serviceaccount/token 28 # bearer_token = "/path/to/bearer/token" 29 ## OR 30 # bearer_token_string = "abc_123" 31 32 ## Pod labels to be added as tags. An empty array for both include and 33 ## exclude will include all labels. 34 # label_include = [] 35 # label_exclude = ["*"] 36 37 ## Set response_timeout (default 5 seconds) 38 # response_timeout = "5s" 39 40 ## Optional TLS Config 41 # tls_ca = /path/to/cafile 42 # tls_cert = /path/to/certfile 43 # tls_key = /path/to/keyfile 44 ## Use TLS but skip chain & host verification 45 # insecure_skip_verify = false 46 `, k.PluginName(), k.URL) 47 } 48 49 // UnmarshalTOML decodes the parsed data to the object 50 func (k *Kubernetes) UnmarshalTOML(data interface{}) error { 51 dataOK, ok := data.(map[string]interface{}) 52 if !ok { 53 return errors.New("bad url for kubernetes input plugin") 54 } 55 if k.URL, ok = dataOK["url"].(string); !ok { 56 return errors.New("url is not a string value") 57 } 58 return nil 59 }