Add annotations for pods
Signed-off-by: Mrunal Patel <mrunalp@gmail.com>
This commit is contained in:
parent
b0e23c4a24
commit
d5a8d1bae3
1 changed files with 20 additions and 11 deletions
|
@ -16,11 +16,12 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type sandbox struct {
|
type sandbox struct {
|
||||||
id string
|
id string
|
||||||
name string
|
name string
|
||||||
logDir string
|
logDir string
|
||||||
labels map[string]string
|
labels map[string]string
|
||||||
containers oci.Store
|
annotations map[string]string
|
||||||
|
containers oci.Store
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -129,20 +130,28 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add annotations
|
||||||
|
annotations := req.GetConfig().GetAnnotations()
|
||||||
|
annotationsJSON, err := json.Marshal(annotations)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
g.AddAnnotation("ocid/labels", string(labelsJSON))
|
g.AddAnnotation("ocid/labels", string(labelsJSON))
|
||||||
|
g.AddAnnotation("ocid/annotations", string(annotationsJSON))
|
||||||
g.AddAnnotation("ocid/log_path", logDir)
|
g.AddAnnotation("ocid/log_path", logDir)
|
||||||
g.AddAnnotation("ocid/name", name)
|
g.AddAnnotation("ocid/name", name)
|
||||||
containerName := name + "-infra"
|
containerName := name + "-infra"
|
||||||
g.AddAnnotation("ocid/container_name", containerName)
|
g.AddAnnotation("ocid/container_name", containerName)
|
||||||
s.addSandbox(&sandbox{
|
s.addSandbox(&sandbox{
|
||||||
id: id,
|
id: id,
|
||||||
name: name,
|
name: name,
|
||||||
logDir: logDir,
|
logDir: logDir,
|
||||||
labels: labels,
|
labels: labels,
|
||||||
containers: oci.NewMemoryStore(),
|
annotations: annotations,
|
||||||
|
containers: oci.NewMemoryStore(),
|
||||||
})
|
})
|
||||||
|
|
||||||
annotations := req.GetConfig().GetAnnotations()
|
|
||||||
for k, v := range annotations {
|
for k, v := range annotations {
|
||||||
g.AddAnnotation(k, v)
|
g.AddAnnotation(k, v)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue