I'm setting up a kubernet cluster to roll out our container applications. The applications actually need all labels, but the labels are longer than 63 characters and I get an error. This makes me dependent on annotations.
An annotation for a service looks like this: com.example.development.london/component.proxy-config.secure-routes.backend.proxy-path
. The /
only serves to bypass an RFC domain error.
In a Golang application all services of a namespace are requested. Actually based on the labels. For this I have used the following code so far.
func (kc *KubernetesCollector) generateRoutes(errorChannel chan<- error) {
log.Println("INFO: Try to generate routes")
services, err := kc.iface.Services(kc.namespace).List(metav1.ListOptions{
LabelSelector: fmt.Sprintf("%s==true", ConvertLabelToKubernetesAnnotation(ProxyConfDiscoverableLabel)),
})
...
func ConvertLabelToKubernetesAnnotation(label string) string {
return strings.Replace(label, "com.example.development.london.", "com.example.development.london/", -1)
}
But there is no possibility to return the services using annotations. Does anyone know another way how I can get all services that apply to an annotation with Go?