github.com/containers/podman/v2@v2.2.2-0.20210501105131-c1e07d070c4c/pkg/specgen/podspecgen.go (about) 1 package specgen 2 3 import ( 4 "net" 5 ) 6 7 // PodBasicConfig contains basic configuration options for pods. 8 type PodBasicConfig struct { 9 // Name is the name of the pod. 10 // If not provided, a name will be generated when the pod is created. 11 // Optional. 12 Name string `json:"name,omitempty"` 13 // Hostname is the pod's hostname. If not set, the name of the pod will 14 // be used (if a name was not provided here, the name auto-generated for 15 // the pod will be used). This will be used by the infra container and 16 // all containers in the pod as long as the UTS namespace is shared. 17 // Optional. 18 Hostname string `json:"hostname,omitempty"` 19 // Labels are key-value pairs that are used to add metadata to pods. 20 // Optional. 21 Labels map[string]string `json:"labels,omitempty"` 22 // NoInfra tells the pod not to create an infra container. If this is 23 // done, many networking-related options will become unavailable. 24 // Conflicts with setting any options in PodNetworkConfig, and the 25 // InfraCommand and InfraImages in this struct. 26 // Optional. 27 NoInfra bool `json:"no_infra,omitempty"` 28 // InfraConmonPidFile is a custom path to store the infra container's 29 // conmon PID. 30 InfraConmonPidFile string `json:"infra_conmon_pid_file,omitempty"` 31 // InfraCommand sets the command that will be used to start the infra 32 // container. 33 // If not set, the default set in the Libpod configuration file will be 34 // used. 35 // Conflicts with NoInfra=true. 36 // Optional. 37 InfraCommand []string `json:"infra_command,omitempty"` 38 // InfraImage is the image that will be used for the infra container. 39 // If not set, the default set in the Libpod configuration file will be 40 // used. 41 // Conflicts with NoInfra=true. 42 // Optional. 43 InfraImage string `json:"infra_image,omitempty"` 44 // SharedNamespaces instructs the pod to share a set of namespaces. 45 // Shared namespaces will be joined (by default) by every container 46 // which joins the pod. 47 // If not set and NoInfra is false, the pod will set a default set of 48 // namespaces to share. 49 // Conflicts with NoInfra=true. 50 // Optional. 51 SharedNamespaces []string `json:"shared_namespaces,omitempty"` 52 // PodCreateCommand is the command used to create this pod. 53 // This will be shown in the output of Inspect() on the pod, and may 54 // also be used by some tools that wish to recreate the pod 55 // (e.g. `podman generate systemd --new`). 56 // Optional. 57 PodCreateCommand []string `json:"pod_create_command,omitempty"` 58 } 59 60 // PodNetworkConfig contains networking configuration for a pod. 61 type PodNetworkConfig struct { 62 // NetNS is the configuration to use for the infra container's network 63 // namespace. This network will, by default, be shared with all 64 // containers in the pod. 65 // Cannot be set to FromContainer and FromPod. 66 // Setting this to anything except default conflicts with NoInfra=true. 67 // Defaults to Bridge as root and Slirp as rootless. 68 // Mandatory. 69 NetNS Namespace `json:"netns,omitempty"` 70 // StaticIP sets a static IP for the infra container. As the infra 71 // container's network is used for the entire pod by default, this will 72 // thus be a static IP for the whole pod. 73 // Only available if NetNS is set to Bridge (the default for root). 74 // As such, conflicts with NoInfra=true by proxy. 75 // Optional. 76 StaticIP *net.IP `json:"static_ip,omitempty"` 77 // StaticMAC sets a static MAC for the infra container. As the infra 78 // container's network is used for the entire pod by default, this will 79 // thus be a static MAC for the entire pod. 80 // Only available if NetNS is set to Bridge (the default for root). 81 // As such, conflicts with NoInfra=true by proxy. 82 // Optional. 83 StaticMAC *net.HardwareAddr `json:"static_mac,omitempty"` 84 // PortMappings is a set of ports to map into the infra container. 85 // As, by default, containers share their network with the infra 86 // container, this will forward the ports to the entire pod. 87 // Only available if NetNS is set to Bridge or Slirp. 88 // Optional. 89 PortMappings []PortMapping `json:"portmappings,omitempty"` 90 // CNINetworks is a list of CNI networks that the infra container will 91 // join. As, by default, containers share their network with the infra 92 // container, these networks will effectively be joined by the 93 // entire pod. 94 // Only available when NetNS is set to Bridge, the default for root. 95 // Optional. 96 CNINetworks []string `json:"cni_networks,omitempty"` 97 // NoManageResolvConf indicates that /etc/resolv.conf should not be 98 // managed by the pod. Instead, each container will create and manage a 99 // separate resolv.conf as if they had not joined a pod. 100 // Conflicts with NoInfra=true and DNSServer, DNSSearch, DNSOption. 101 // Optional. 102 NoManageResolvConf bool `json:"no_manage_resolv_conf,omitempty"` 103 // DNSServer is a set of DNS servers that will be used in the infra 104 // container's resolv.conf, which will, by default, be shared with all 105 // containers in the pod. 106 // If not provided, the host's DNS servers will be used, unless the only 107 // server set is a localhost address. As the container cannot connect to 108 // the host's localhost, a default server will instead be set. 109 // Conflicts with NoInfra=true. 110 // Optional. 111 DNSServer []net.IP `json:"dns_server,omitempty"` 112 // DNSSearch is a set of DNS search domains that will be used in the 113 // infra container's resolv.conf, which will, by default, be shared with 114 // all containers in the pod. 115 // If not provided, DNS search domains from the host's resolv.conf will 116 // be used. 117 // Conflicts with NoInfra=true. 118 // Optional. 119 DNSSearch []string `json:"dns_search,omitempty"` 120 // DNSOption is a set of DNS options that will be used in the infra 121 // container's resolv.conf, which will, by default, be shared with all 122 // containers in the pod. 123 // Conflicts with NoInfra=true. 124 // Optional. 125 DNSOption []string `json:"dns_option,omitempty"` 126 // NoManageHosts indicates that /etc/hosts should not be managed by the 127 // pod. Instead, each container will create a separate /etc/hosts as 128 // they would if not in a pod. 129 // Conflicts with HostAdd. 130 NoManageHosts bool `json:"no_manage_hosts,omitempty"` 131 // HostAdd is a set of hosts that will be added to the infra container's 132 // /etc/hosts that will, by default, be shared with all containers in 133 // the pod. 134 // Conflicts with NoInfra=true and NoManageHosts. 135 // Optional. 136 HostAdd []string `json:"hostadd,omitempty"` 137 // NetworkOptions are additional options for each network 138 // Optional. 139 NetworkOptions map[string][]string `json:"network_options,omitempty"` 140 } 141 142 // PodCgroupConfig contains configuration options about a pod's cgroups. 143 // This will be expanded in future updates to pods. 144 type PodCgroupConfig struct { 145 // CgroupParent is the parent for the CGroup that the pod will create. 146 // This pod cgroup will, in turn, be the default cgroup parent for all 147 // containers in the pod. 148 // Optional. 149 CgroupParent string `json:"cgroup_parent,omitempty"` 150 } 151 152 // PodSpecGenerator describes options to create a pod 153 // swagger:model PodSpecGenerator 154 type PodSpecGenerator struct { 155 PodBasicConfig 156 PodNetworkConfig 157 PodCgroupConfig 158 } 159 160 // NewPodSpecGenerator creates a new pod spec 161 func NewPodSpecGenerator() *PodSpecGenerator { 162 return &PodSpecGenerator{} 163 }