server: expose container Name and IP
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
5947698818
commit
e1125af435
3 changed files with 17 additions and 1 deletions
|
@ -396,6 +396,11 @@ func (s *Server) createSandboxContainer(ctx context.Context, containerID string,
|
||||||
specgen.AddAnnotation(k, v)
|
specgen.AddAnnotation(k, v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if labels != nil {
|
||||||
|
for k, v := range labels {
|
||||||
|
specgen.AddAnnotation(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// set this container's apparmor profile if it is set by sandbox
|
// set this container's apparmor profile if it is set by sandbox
|
||||||
if s.appArmorEnabled {
|
if s.appArmorEnabled {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
|
|
||||||
// ContainerInfo stores information about containers
|
// ContainerInfo stores information about containers
|
||||||
type ContainerInfo struct {
|
type ContainerInfo struct {
|
||||||
|
Name string `json:"name"`
|
||||||
Pid int `json:"pid"`
|
Pid int `json:"pid"`
|
||||||
Image string `json:"image"`
|
Image string `json:"image"`
|
||||||
CreatedTime int64 `json:"created_time"`
|
CreatedTime int64 `json:"created_time"`
|
||||||
|
@ -19,6 +20,7 @@ type ContainerInfo struct {
|
||||||
LogPath string `json:"log_path"`
|
LogPath string `json:"log_path"`
|
||||||
Root string `json:"root"`
|
Root string `json:"root"`
|
||||||
Sandbox string `json:"sandbox"`
|
Sandbox string `json:"sandbox"`
|
||||||
|
IP string `json:"ip_address"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// CrioInfo stores information about the crio daemon
|
// CrioInfo stores information about the crio daemon
|
||||||
|
@ -60,8 +62,13 @@ func (s *Server) GetInfoMux() *bone.Mux {
|
||||||
http.Error(w, fmt.Sprintf("container %s state is nil", containerID), http.StatusNotFound)
|
http.Error(w, fmt.Sprintf("container %s state is nil", containerID), http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
sb := s.getSandbox(ctr.Sandbox())
|
||||||
|
if sb == nil {
|
||||||
|
http.Error(w, fmt.Sprintf("can't find the sandbox for container id, sandbox id %s: %s", containerID, ctr.Sandbox()), http.StatusNotFound)
|
||||||
|
return
|
||||||
|
}
|
||||||
ci := ContainerInfo{
|
ci := ContainerInfo{
|
||||||
|
Name: ctr.Name(),
|
||||||
Pid: ctrState.Pid,
|
Pid: ctrState.Pid,
|
||||||
Image: ctr.Image(),
|
Image: ctr.Image(),
|
||||||
CreatedTime: ctrState.Created.UnixNano(),
|
CreatedTime: ctrState.Created.UnixNano(),
|
||||||
|
@ -70,6 +77,7 @@ func (s *Server) GetInfoMux() *bone.Mux {
|
||||||
Root: ctr.MountPoint(),
|
Root: ctr.MountPoint(),
|
||||||
LogPath: filepath.Dir(ctr.LogPath()),
|
LogPath: filepath.Dir(ctr.LogPath()),
|
||||||
Sandbox: ctr.Sandbox(),
|
Sandbox: ctr.Sandbox(),
|
||||||
|
IP: sb.IP(),
|
||||||
}
|
}
|
||||||
js, err := json.Marshal(ci)
|
js, err := json.Marshal(ci)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -369,6 +369,9 @@ func (s *Server) RunPodSandbox(ctx context.Context, req *pb.RunPodSandboxRequest
|
||||||
for k, v := range kubeAnnotations {
|
for k, v := range kubeAnnotations {
|
||||||
g.AddAnnotation(k, v)
|
g.AddAnnotation(k, v)
|
||||||
}
|
}
|
||||||
|
for k, v := range labels {
|
||||||
|
g.AddAnnotation(k, v)
|
||||||
|
}
|
||||||
|
|
||||||
// extract linux sysctls from annotations and pass down to oci runtime
|
// extract linux sysctls from annotations and pass down to oci runtime
|
||||||
safe, unsafe, err := SysctlsFromPodAnnotations(kubeAnnotations)
|
safe, unsafe, err := SysctlsFromPodAnnotations(kubeAnnotations)
|
||||||
|
|
Loading…
Reference in a new issue