Class Container

  • All Implemented Interfaces:
    AutoUpdatable, PodWithAffinity, PodWithPorts, ResourceLimited

    public class Container
    extends Pod
    implements ResourceLimited, PodWithPorts, PodWithAffinity, AutoUpdatable
    An implementation of Pod that represents a Docker container
     {
          "type": "container",
          "id": "example1",
          "image": "docker.io/bfirsh/reticulate-splines",
          "repo": "dockerhub",
          "entrypoint": [],
          "env": {
              "aaa": "bbb"
          },
          "randomEnv": {
              "test": {
                  "type": "string",
                  "length": 6,
                  "alphabet": "1234567890abcdef"
              },
              "test2": {
                  "type": "int",
                  "min": 69,
                  "max": 420
              }
          },
          "labels": {
              "key": "value"
          },
          "affinity": ["aslr"],
          "antiaffinity": ["ARM"],
          "resourceQuota": {
              "memory": 536870912,
              "swap": 0,
              "nanocpu": 10000000
          },
          "capDrop": ["BLOCK_SUSPEND"],
          "capAdd": ["MKNOD"],
          "restartPolicy": "always",
          "healthcheck": [
              {
                  "id": "tcpconnect",
                  "type": "tcp",
                  "port": 6000,
                  "timeout": 5
              },
              {
                  "id": "flagcheck",
                  "type": "tcppayload",
                  "payloads": [
                      {
                          "type": "send",
                          "hex": "deadbeef"
                      },
                      {
                          "type": "receiveexact",
                          "hex": "deadbeef"
                      },
                      {
                          "type": "receiveregex",
                          "hex": ".*"
                      }
                  ]
              },
              {
                  "id": "web",
                  "type": "http",
                  "path": "/test",
                  "port": 80,
                  "vhost": "dave.lc"
              }
          ],
          "terminationTimeout": 5,
          "metadata": {
              "aaa": "bbb"
          },
          "portMappings": [
              {
                  "port": 6000,
                  "protocol": "tcp",
                  "advertise": true
              }
          ]
     }
     
    • Constructor Summary

      Constructors 
      Constructor Description
      Container​(java.lang.String type, java.lang.String id, java.lang.String image, java.lang.String repo, NamespacedId repoCredentials, java.util.List<java.lang.String> entrypoint, java.util.Map<java.lang.String,​java.lang.String> env, java.util.Map<java.lang.String,​RandomEnv> randomEnv, java.util.Map<java.lang.String,​java.lang.String> labels, java.util.Map<java.lang.String,​java.lang.String> affinity, java.util.Map<java.lang.String,​java.lang.String> antiaffinity, ResourceQuota resourceQuota, java.lang.String restartPolicy, java.util.List<java.lang.String> capDrop, java.util.List<java.lang.String> capAdd, java.util.List<HealthCheck> healthChecks, java.lang.Integer terminationTimeout, java.util.List<PortMapping> portMappings, java.util.Map<java.lang.String,​java.lang.String> metadata, boolean autoUpdate, java.util.List<java.lang.String> securityOptions)
      Creates a container
    • Constructor Detail

      • Container

        public Container​(java.lang.String type,
                         java.lang.String id,
                         java.lang.String image,
                         java.lang.String repo,
                         NamespacedId repoCredentials,
                         java.util.List<java.lang.String> entrypoint,
                         java.util.Map<java.lang.String,​java.lang.String> env,
                         java.util.Map<java.lang.String,​RandomEnv> randomEnv,
                         java.util.Map<java.lang.String,​java.lang.String> labels,
                         java.util.Map<java.lang.String,​java.lang.String> affinity,
                         java.util.Map<java.lang.String,​java.lang.String> antiaffinity,
                         ResourceQuota resourceQuota,
                         java.lang.String restartPolicy,
                         java.util.List<java.lang.String> capDrop,
                         java.util.List<java.lang.String> capAdd,
                         java.util.List<HealthCheck> healthChecks,
                         java.lang.Integer terminationTimeout,
                         java.util.List<PortMapping> portMappings,
                         java.util.Map<java.lang.String,​java.lang.String> metadata,
                         boolean autoUpdate,
                         java.util.List<java.lang.String> securityOptions)
        Creates a container
        Parameters:
        type - the type of the pod (container)
        id - the id of the container
        image - the image to use
        repo - the repository id
        repoCredentials - the credentials to use for the repository
        entrypoint - the container entrypoint
        env - the environment variables to set
        randomEnv - the randomised environment variables to set
        labels - labels to add to the container
        affinity - which types of host a pod should be preferentially scheduled on
        antiaffinity - which types of host a pod should avoid being scheduled on
        resourceQuota - the resource quota of the container
        restartPolicy - the restart policy of the container
        capDrop - capabilities to drop
        capAdd - capabilities to add
        healthChecks - healthchecks for the pod
        terminationTimeout - the timeout to use when the pod is terminated
        portMappings - ports to expose
        metadata - other metadata
        autoUpdate - if the container should be automatically updated
        securityOptions -
    • Method Detail

      • getImage

        public java.lang.String getImage()
      • getRepo

        public java.lang.String getRepo()
      • getRepoCredentials

        public NamespacedId getRepoCredentials()
      • getEntrypoint

        public java.util.List<java.lang.String> getEntrypoint()
      • getEnv

        public java.util.Map<java.lang.String,​java.lang.String> getEnv()
      • getRandomEnv

        public java.util.Map<java.lang.String,​RandomEnv> getRandomEnv()
      • getLabels

        public java.util.Map<java.lang.String,​java.lang.String> getLabels()
      • getAffinity

        public java.util.Map<java.lang.String,​java.lang.String> getAffinity()
        Specified by:
        getAffinity in interface PodWithAffinity
      • getAntiaffinity

        public java.util.Map<java.lang.String,​java.lang.String> getAntiaffinity()
        Specified by:
        getAntiaffinity in interface PodWithAffinity
      • getRestartPolicy

        public java.lang.String getRestartPolicy()
      • getCapDrop

        public java.util.List<java.lang.String> getCapDrop()
      • getCapAdd

        public java.util.List<java.lang.String> getCapAdd()
      • getHealthChecks

        public java.util.List<HealthCheck> getHealthChecks()
      • getTerminationTimeout

        public java.lang.Integer getTerminationTimeout()
      • getMetadata

        public java.util.Map<java.lang.String,​java.lang.String> getMetadata()
      • getSecurityOptions

        public java.util.List<java.lang.String> getSecurityOptions()
      • getFullEnv

        public java.util.List<java.lang.String> getFullEnv()
      • getGeneratedRandomEnv

        public java.util.Map<java.lang.String,​java.lang.String> getGeneratedRandomEnv()
      • canUseRunner

        public boolean canUseRunner​(java.lang.String runner)
        Specified by:
        canUseRunner in class Pod
      • getTag

        public java.lang.String getTag()
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object