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