joyrex2001 / kubedock

Kubedock is a minimal implementation of the docker api that will orchestrate containers on a Kubernetes cluster, rather than running containers locally.
MIT License
226 stars 33 forks source link

Is it possible for kubedock to apply annotations? #54

Closed rcgeorge23 closed 1 year ago

rcgeorge23 commented 1 year ago

Hi @joyrex2001,

Is there any way to get kubedock to apply annotations to pods when it starts them?

I can see there's a function that mentions annotations, but I can't see how to configure them.

// getAnnotations will return a map of annotations to be added to the
// container. This map contains the labels as specified in the container
// definition.
func (in *instance) getAnnotations(annotations map[string]string, tainr *types.Container) map[string]string {
    if annotations == nil {
        annotations = map[string]string{}
    }
    for k, v := range tainr.Labels {
        annotations[k] = v
    }
    annotations["kubedock.containername"] = tainr.Name
    return annotations
}

Thanks!

joyrex2001 commented 1 year ago

The labels that are defined inside the container, will be automatically added as annotations on the resources. So, if you want a specific annotation to be added, the way of doing that is to add this as a label to the container.

rcgeorge23 commented 1 year ago

Yep that worked, thanks @joyrex2001