github.com/rkt/rkt@v1.30.1-0.20200224141603-171c416fac02/api/v1alpha/api.proto (about)

     1  // Copyright 2015 The rkt Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  // *************************************************** //
    16  // ************ WARNING - HERE BE DRAGONS ************ //
    17  //                                                     //
    18  //   The API defined here is proposed, experimental,   //
    19  //   and (for now) subject to change at any time.      //
    20  //                                                     //
    21  //  If you think you want to use it, or for any other  //
    22  //     queries, contact <rkt-dev@googlegroups.com>     //
    23  //      or file an issue on github.com/rkt/rkt      //
    24  //                                                     //
    25  // *************************************************** //
    26  // ****************** END WARNING ******************** //
    27  
    28  syntax = "proto3";
    29  
    30  package v1alpha;
    31  
    32  // ImageType defines the supported image type.
    33  enum ImageType {
    34          IMAGE_TYPE_UNDEFINED = 0;
    35          IMAGE_TYPE_APPC      = 1;
    36          IMAGE_TYPE_DOCKER    = 2;
    37          IMAGE_TYPE_OCI       = 3;
    38  }
    39  
    40  // ImageFormat defines the format of the image.
    41  message ImageFormat {
    42          // Type of the image, required.
    43          ImageType type = 1;
    44  
    45          // Version of the image format, required.
    46          string version = 2;
    47  }
    48  
    49  // Image describes the image's information.
    50  message Image {
    51          // Base format of the image, required. This indicates the original format
    52          // for the image as nowadays all the image formats will be transformed to
    53          // ACI.
    54          ImageFormat base_format = 1;
    55  
    56          // ID of the image, a string that can be used to uniquely identify the image,
    57          // e.g. sha512 hash of the ACIs, required.
    58          string id = 2;
    59  
    60          // Name of the image in the image manifest, e.g. 'coreos.com/etcd', optional.
    61          string name = 3;
    62  
    63          // Version of the image, e.g. 'latest', '2.0.10', optional.
    64          string version = 4;
    65  
    66          // Timestamp of when the image is imported, it is the seconds since epoch, optional.
    67          int64 import_timestamp = 5;
    68  
    69          // JSON-encoded byte array that represents the image manifest, optional.
    70          bytes manifest = 6;
    71  
    72          // Size is the size in bytes of this image in the store.
    73          int64 size = 7;
    74  
    75          // Annotations on this image.
    76          repeated KeyValue annotations = 8;
    77  
    78          // Labels of this image.
    79          repeated KeyValue labels = 9;
    80  }
    81  
    82  // Network describes the network information of a pod.
    83  message Network {
    84          // Name of the network that a pod belongs to, required.
    85          string name = 1;
    86  
    87          // Pod's IPv4 address within the network, optional if IPv6 address is given.
    88          string ipv4 = 2;
    89  
    90          // Pod's IPv6 address within the network, optional if IPv4 address is given.
    91          string ipv6 = 3;
    92  }
    93  
    94  // AppState defines the possible states of the app.
    95  enum AppState {
    96          APP_STATE_UNDEFINED = 0;
    97          APP_STATE_RUNNING   = 1;
    98          APP_STATE_EXITED    = 2;
    99  }
   100  
   101  // App describes the information of an app that's running in a pod.
   102  message App {
   103          // Name of the app, required.
   104          string name = 1;
   105  
   106          // Image used by the app, required. However, this may only contain the image id
   107          // if it is returned by ListPods().
   108          Image image = 2;
   109  
   110          // State of the app. optional, non-empty only if it's returned by InspectPod().
   111          AppState state = 3;
   112  
   113          // Exit code of the app. optional, only valid if it's returned by InspectPod() and
   114          // the app has already exited.
   115          sint32 exit_code = 4;
   116  
   117  	// Annotations for this app.
   118          repeated KeyValue annotations = 5;
   119  }
   120  
   121  // PodState defines the possible states of the pod.
   122  // See https://github.com/rkt/rkt/blob/master/Documentation/devel/pod-lifecycle.md for a detailed
   123  // explanation of each state.
   124  enum PodState {
   125          POD_STATE_UNDEFINED = 0;
   126  
   127          // States before the pod is running.
   128          POD_STATE_EMBRYO    = 1; // Pod is created, ready to entering 'preparing' state.
   129          POD_STATE_PREPARING = 2; // Pod is being prepared. On success it will become 'prepared', otherwise it will become 'aborted prepared'.
   130          POD_STATE_PREPARED  = 3; // Pod has been successfully prepared, ready to enter 'running' state. it can also enter 'deleting' if it's garbage collected before running.
   131  
   132          // State that indicates the pod is running.
   133          POD_STATE_RUNNING = 4; // Pod is running, when it exits, it will become 'exited'.
   134  
   135          // States that indicates the pod is exited, and will never run.
   136          POD_STATE_ABORTED_PREPARE = 5; // Pod failed to prepare, it will only be garbage collected and will never run again.
   137          POD_STATE_EXITED          = 6; // Pod has exited, it now can be garbage collected.
   138          POD_STATE_DELETING        = 7; // Pod is being garbage collected, after that it will enter 'garbage' state.
   139          POD_STATE_GARBAGE         = 8; // Pod is marked as garbage collected, it no longer exists on the machine.
   140  }
   141  
   142  // Pod describes a pod's information.
   143  // If a pod is in Embryo, Preparing, AbortedPrepare state,
   144  // only id and state will be returned.
   145  //
   146  // If a pod is in other states, the pod manifest and
   147  // apps will be returned when 'detailed' is true in the request.
   148  //
   149  // A valid pid of the stage1 process of the pod will be returned
   150  // if the pod is Running has run once.
   151  //
   152  // Networks are only returned when a pod is in Running.
   153  message Pod {
   154          // ID of the pod, in the form of a UUID.
   155          string id = 1;
   156  
   157          // PID of the stage1 process of the pod.
   158          sint32 pid = 2;
   159  
   160          // State of the pod.
   161          PodState state = 3;
   162  
   163          // List of apps in the pod.
   164          repeated App apps = 4;
   165  
   166          // Network information of the pod.
   167          // Note that a pod can be in multiple networks.
   168          repeated Network networks = 5;
   169  
   170          // JSON-encoded byte array that represents the pod manifest of the pod.
   171          bytes manifest = 6;
   172  
   173          // Annotations on this pod.
   174          repeated KeyValue annotations = 7;
   175  
   176          // Cgroup of the pod, empty if the pod is not running.
   177          string cgroup = 8;
   178  
   179          // Timestamp of when the pod is created, nanoseconds since epoch.
   180          // Zero if the pod is not created.
   181          int64 created_at = 9;
   182  
   183          // Timestamp of when the pod is started, nanoseconds since epoch.
   184          // Zero if the pod is not started.
   185          int64 started_at = 10;
   186  
   187          // Timestamp of when the pod is moved to exited-garbage/garbage,
   188          // in nanoseconds since epoch.
   189          // Zero if the pod is not moved to exited-garbage/garbage yet.
   190          int64 gc_marked_at = 11;
   191  }
   192  
   193  message KeyValue {
   194          // Key part of the key-value pair.
   195          string Key = 1;
   196          // Value part of the key-value pair.
   197          string value = 2;
   198  }
   199  
   200  // PodFilter defines the condition that the returned pods need to satisfy in ListPods().
   201  // The conditions are combined by 'AND', and different filters are combined by 'OR'.
   202  message PodFilter {
   203          // If not empty, the pods that have any of the ids will be returned.
   204          repeated string ids = 1;
   205  
   206          // If not empty, the pods that have any of the states will be returned.
   207          repeated PodState states = 2;
   208  
   209          // If not empty, the pods that all of the apps will be returned.
   210          repeated string app_names = 3;
   211  
   212          // If not empty, the pods that have all of the images(in the apps) will be returned
   213          repeated string image_ids = 4;
   214  
   215          // If not empty, the pods that are in all of the networks will be returned.
   216          repeated string network_names = 5;
   217  
   218          // If not empty, the pods that have all of the annotations will be returned.
   219          repeated KeyValue annotations = 6;
   220  
   221          // If not empty, the pods whose cgroup are listed will be returned.
   222          repeated string cgroups = 7;
   223  
   224          // If not empty, the pods whose these cgroup belong to will be returned.
   225          // i.e. the pod's cgroup is a prefix of the specified cgroup
   226          repeated string pod_sub_cgroups = 8;
   227  }
   228  
   229  // ImageFilter defines the condition that the returned images need to satisfy in ListImages().
   230  // The conditions are combined by 'AND', and different filters are combined by 'OR'.
   231  message ImageFilter {
   232          // If not empty, the images that have any of the ids will be returned.
   233          repeated string ids = 1;
   234  
   235          // if not empty, the images that have any of the prefixes in the name will be returned.
   236          repeated string prefixes = 2;
   237  
   238          // If not empty, the images that have any of the base names will be returned.
   239          // For example, both 'coreos.com/etcd' and 'k8s.io/etcd' will be returned if 'etcd' is included,
   240          // however 'k8s.io/etcd-backup' will not be returned.
   241          repeated string base_names = 3;
   242  
   243          // If not empty, the images that have any of the keywords in the name will be returned.
   244          // For example, both 'kubernetes-etcd', 'etcd:latest' will be returned if 'etcd' is included,
   245          repeated string keywords = 4;
   246  
   247          // If not empty, the images that have all of the labels will be returned.
   248          repeated KeyValue labels = 5;
   249  
   250          // If set, the images that are imported after this timestamp will be returned.
   251          int64 imported_after = 6;
   252  
   253          // If set, the images that are imported before this timestamp will be returned.
   254          int64 imported_before = 7;
   255  
   256          // If not empty, the images that have all of the annotations will be returned.
   257          repeated KeyValue annotations = 8;
   258  
   259          // If not empty, the images that have any of the exact full names will be returned.
   260          repeated string full_names = 9;
   261  }
   262  
   263  // GlobalFlags describes the flags that passed to rkt api service when it is launched.
   264  message GlobalFlags {
   265          // Data directory.
   266          string dir = 1;
   267  
   268          // System configuration directory.
   269          string system_config_dir = 2;
   270  
   271          // Local configuration directory.
   272          string local_config_dir = 3;
   273  
   274          // User configuration directory.
   275          string user_config_dir = 4;
   276  
   277          // Insecure flags configurates what security features to disable.
   278          string insecure_flags = 5;
   279  
   280          // Whether to automatically trust gpg keys fetched from https
   281          bool trust_keys_from_https = 6;
   282  }
   283  
   284  // Info describes the information of rkt on the machine.
   285  message Info {
   286          // Version of rkt, required, in the form of Semantic Versioning 2.0.0 (http://semver.org/).
   287          string rkt_version = 1;
   288  
   289          // Version of appc, required, in the form of Semantic Versioning 2.0.0 (http://semver.org/).
   290          string appc_version = 2;
   291  
   292          // Latest version of the api that's supported by the service, required, in the form of Semantic Versioning 2.0.0 (http://semver.org/).
   293          string api_version = 3;
   294  
   295          // The global flags that passed to the rkt api service when it's launched.
   296          GlobalFlags global_flags = 4;
   297  }
   298  
   299  // EventType defines the type of the events that will be received via ListenEvents().
   300  enum EventType {
   301          EVENT_TYPE_UNDEFINED = 0;
   302  
   303          // Pod events.
   304          EVENT_TYPE_POD_PREPARED          = 1;
   305          EVENT_TYPE_POD_PREPARE_ABORTED   = 2;
   306          EVENT_TYPE_POD_STARTED           = 3;
   307          EVENT_TYPE_POD_EXITED            = 4;
   308          EVENT_TYPE_POD_GARBAGE_COLLECTED = 5;
   309  
   310          // App events.
   311          EVENT_TYPE_APP_STARTED = 6;
   312          EVENT_TYPE_APP_EXITED  = 7; // (XXX)yifan: Maybe also return exit code in the event object?
   313  
   314          // Image events.
   315          EVENT_TYPE_IMAGE_IMPORTED = 8;
   316          EVENT_TYPE_IMAGE_REMOVED  = 9;
   317  }
   318  
   319  // Event describes the events that will be received via ListenEvents().
   320  message Event {
   321          // Type of the event, required.
   322          EventType type = 1;
   323  
   324          // ID of the subject that causes the event, required.
   325          // If the event is a pod or app event, the id is the pod's uuid.
   326          // If the event is an image event, the id is the image's id.
   327          string id = 2;
   328  
   329          // Name of the subject that causes the event, required.
   330          // If the event is a pod event, the name is the pod's name.
   331          // If the event is an app event, the name is the app's name.
   332          // If the event is an image event, the name is the image's name.
   333          string from = 3;
   334  
   335          // Timestamp of when the event happens, it is the seconds since epoch, required.
   336          int64 time = 4;
   337  
   338          // Data of the event, in the form of key-value pairs, optional.
   339          repeated KeyValue data = 5;
   340  }
   341  
   342  // EventFilter defines the condition that the returned events needs to satisfy in ListImages().
   343  // The condition are combined by 'AND'.
   344  message EventFilter {
   345          // If not empty, then only returns the events that have the listed types.
   346          repeated EventType types = 1;
   347  
   348          // If not empty, then only returns the events whose 'id' is included in the listed ids.
   349          repeated string ids = 2;
   350  
   351          // If not empty, then only returns the events whose 'from' is included in the listed names.
   352          repeated string names = 3;
   353  
   354          // If set, then only returns the events after this timestamp.
   355          // If the server starts after since_time, then only the events happened after the start of the server will be returned.
   356          // If since_time is a future timestamp, then no events will be returned until that time.
   357          int64 since_time = 4;
   358  
   359          // If set, then only returns the events before this timestamp.
   360          // If it is a future timestamp, then the event stream will be closed at that moment.
   361          int64 until_time = 5;
   362  }
   363  
   364  // Request for GetInfo().
   365  message GetInfoRequest {}
   366  
   367  // Response for GetInfo().
   368  message GetInfoResponse {
   369          Info info = 1; // Required.
   370  }
   371  
   372  // Request for ListPods().
   373  message ListPodsRequest {
   374          repeated PodFilter filters = 1; // Optional.
   375          bool detail = 2; // Optional.
   376  }
   377  
   378  // Response for ListPods().
   379  message ListPodsResponse {
   380          repeated Pod pods = 1; // Required.
   381  }
   382  
   383  // Request for InspectPod().
   384  message InspectPodRequest {
   385          // ID of the pod which we are querying status for, required.
   386          string id = 1;
   387  }
   388  
   389  // Response for InspectPod().
   390  message InspectPodResponse {
   391          Pod pod = 1; // Required.
   392  }
   393  
   394  // Request for ListImages().
   395  message ListImagesRequest {
   396          repeated ImageFilter filters = 1; // Optional.
   397          bool detail = 2; // Optional.
   398  }
   399  
   400  // Response for ListImages().
   401  message ListImagesResponse {
   402          repeated Image images = 1; // Required.
   403  }
   404  
   405  // Request for InspectImage().
   406  message InspectImageRequest {
   407          string id = 1; // Required.
   408  }
   409  
   410  // Response for InspectImage().
   411  message InspectImageResponse {
   412          Image image = 1; // Required.
   413  }
   414  
   415  // Request for ListenEvents().
   416  message ListenEventsRequest {
   417          EventFilter filter = 1; // Optional.
   418  }
   419  
   420  // Response for ListenEvents().
   421  message ListenEventsResponse {
   422          // Aggregate multiple events to reduce round trips, optional as the response can contain no events.
   423          repeated Event events = 1;
   424  }
   425  
   426  // Request for GetLogs().
   427  message GetLogsRequest {
   428          // ID of the pod which we will get logs from, required.
   429          string pod_id = 1;
   430  
   431          // Name of the app within the pod which we will get logs
   432          // from, optional. If not set, then the logs of all the
   433          // apps within the pod will be returned.
   434          string app_name = 2;
   435  
   436          // Number of most recent lines to return, optional.
   437          int32 lines = 3;
   438  
   439          // If true, then a response stream will not be closed,
   440          // and new log response will be sent via the stream, default is false.
   441          bool follow = 4;
   442  
   443          // If set, then only the logs after the timestamp will
   444          // be returned, optional.
   445          int64 since_time = 5;
   446  
   447          // If set, then only the logs before the timestamp will
   448          // be returned, optional.
   449          int64 until_time = 6;
   450  }
   451  
   452  // Response for GetLogs().
   453  message GetLogsResponse {
   454          // List of the log lines that returned, optional as the response can contain no logs.
   455          repeated string lines = 1;
   456  }
   457  
   458  // PublicAPI defines the read-only APIs that will be supported.
   459  // These will be handled over TCP sockets.
   460  service PublicAPI {
   461          // GetInfo gets the rkt's information on the machine.
   462          rpc GetInfo (GetInfoRequest) returns (GetInfoResponse) {}
   463  
   464          // ListPods lists rkt pods on the machine.
   465          rpc ListPods (ListPodsRequest) returns (ListPodsResponse) {}
   466  
   467          // InspectPod gets detailed pod information of the specified pod.
   468          rpc InspectPod (InspectPodRequest) returns (InspectPodResponse) {}
   469  
   470          // ListImages lists the images on the machine.
   471          rpc ListImages (ListImagesRequest) returns (ListImagesResponse) {}
   472  
   473          // InspectImage gets the detailed image information of the specified image.
   474          rpc InspectImage (InspectImageRequest) returns (InspectImageResponse) {}
   475  
   476          // ListenEvents listens for the events, it will return a response stream
   477          // that will contain event objects.
   478          rpc ListenEvents (ListenEventsRequest) returns (stream ListenEventsResponse) {}
   479  
   480          // GetLogs gets the logs for a pod, if the app is also specified, then only the logs
   481          // of the app will be returned.
   482          //
   483          // If 'follow' in the 'GetLogsRequest' is set to 'true', then the response stream
   484          // will not be closed after the first response, the future logs will be sent via
   485          // the stream.
   486          rpc GetLogs(GetLogsRequest) returns (stream GetLogsResponse) {}
   487  }