github.com/skyscape-cloud-services/terraform@v0.9.2-0.20170609144644-7ece028a1747/builtin/providers/kubernetes/schema_pod_spec.go (about)

     1  package kubernetes
     2  
     3  import "github.com/hashicorp/terraform/helper/schema"
     4  
     5  func podSpecFields() map[string]*schema.Schema {
     6  	return map[string]*schema.Schema{
     7  		"active_deadline_seconds": {
     8  			Type:         schema.TypeInt,
     9  			Optional:     true,
    10  			ValidateFunc: validatePositiveInteger,
    11  			Description:  "Optional duration in seconds the pod may be active on the node relative to StartTime before the system will actively try to mark it failed and kill associated containers. Value must be a positive integer.",
    12  		},
    13  		"container": {
    14  			Type:        schema.TypeList,
    15  			Optional:    true,
    16  			Description: "List of containers belonging to the pod. Containers cannot currently be added or removed. There must be at least one container in a Pod. Cannot be updated. More info: http://kubernetes.io/docs/user-guide/containers",
    17  			Elem: &schema.Resource{
    18  				Schema: containerFields(),
    19  			},
    20  		},
    21  		"dns_policy": {
    22  			Type:        schema.TypeString,
    23  			Optional:    true,
    24  			Default:     "ClusterFirst",
    25  			Description: "Set DNS policy for containers within the pod. One of 'ClusterFirst' or 'Default'. Defaults to 'ClusterFirst'.",
    26  		},
    27  		"host_ipc": {
    28  			Type:        schema.TypeBool,
    29  			Optional:    true,
    30  			Default:     false,
    31  			Description: "Use the host's ipc namespace. Optional: Default to false.",
    32  		},
    33  		"host_network": {
    34  			Type:        schema.TypeBool,
    35  			Optional:    true,
    36  			Default:     false,
    37  			Description: "Host networking requested for this pod. Use the host's network namespace. If this option is set, the ports that will be used must be specified.",
    38  		},
    39  
    40  		"host_pid": {
    41  			Type:        schema.TypeBool,
    42  			Optional:    true,
    43  			Default:     false,
    44  			Description: "Use the host's pid namespace.",
    45  		},
    46  
    47  		"hostname": {
    48  			Type:        schema.TypeString,
    49  			Optional:    true,
    50  			Computed:    true,
    51  			Description: "Specifies the hostname of the Pod If not specified, the pod's hostname will be set to a system-defined value.",
    52  		},
    53  		"image_pull_secrets": {
    54  			Type:        schema.TypeList,
    55  			Description: "ImagePullSecrets is an optional list of references to secrets in the same namespace to use for pulling any of the images used by this PodSpec. If specified, these secrets will be passed to individual puller implementations for them to use. For example, in the case of docker, only DockerConfig type secrets are honored. More info: http://kubernetes.io/docs/user-guide/images#specifying-imagepullsecrets-on-a-pod",
    56  			Optional:    true,
    57  			Computed:    true,
    58  			Elem: &schema.Resource{
    59  				Schema: map[string]*schema.Schema{
    60  					"name": {
    61  						Type:        schema.TypeString,
    62  						Description: "Name of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#names",
    63  						Required:    true,
    64  					},
    65  				},
    66  			},
    67  		},
    68  		"node_name": {
    69  			Type:        schema.TypeString,
    70  			Optional:    true,
    71  			Computed:    true,
    72  			Description: "NodeName is a request to schedule this pod onto a specific node. If it is non-empty, the scheduler simply schedules this pod onto that node, assuming that it fits resource requirements.",
    73  		},
    74  		"node_selector": {
    75  			Type:        schema.TypeMap,
    76  			Optional:    true,
    77  			Description: "NodeSelector is a selector which must be true for the pod to fit on a node. Selector which must match a node's labels for the pod to be scheduled on that node. More info: http://kubernetes.io/docs/user-guide/node-selection.",
    78  		},
    79  		"restart_policy": {
    80  			Type:        schema.TypeString,
    81  			Optional:    true,
    82  			Default:     "Always",
    83  			Description: "Restart policy for all containers within the pod. One of Always, OnFailure, Never. More info: http://kubernetes.io/docs/user-guide/pod-states#restartpolicy.",
    84  		},
    85  		"security_context": {
    86  			Type:        schema.TypeList,
    87  			Optional:    true,
    88  			MaxItems:    1,
    89  			Description: "SecurityContext holds pod-level security attributes and common container settings. Optional: Defaults to empty",
    90  			Elem: &schema.Resource{
    91  				Schema: map[string]*schema.Schema{
    92  					"fs_group": {
    93  						Type:        schema.TypeInt,
    94  						Description: "A special supplemental group that applies to all containers in a pod. Some volume types allow the Kubelet to change the ownership of that volume to be owned by the pod: 1. The owning GID will be the FSGroup 2. The setgid bit is set (new files created in the volume will be owned by FSGroup) 3. The permission bits are OR'd with rw-rw---- If unset, the Kubelet will not modify the ownership and permissions of any volume.",
    95  						Optional:    true,
    96  					},
    97  					"run_as_non_root": {
    98  						Type:        schema.TypeBool,
    99  						Description: "Indicates that the container must run as a non-root user. If true, the Kubelet will validate the image at runtime to ensure that it does not run as UID 0 (root) and fail to start the container if it does.",
   100  						Optional:    true,
   101  					},
   102  					"run_as_user": {
   103  						Type:        schema.TypeInt,
   104  						Description: "The UID to run the entrypoint of the container process. Defaults to user specified in image metadata if unspecified",
   105  						Optional:    true,
   106  					},
   107  					"supplemental_groups": {
   108  						Type:        schema.TypeSet,
   109  						Description: "A list of groups applied to the first process run in each container, in addition to the container's primary GID. If unspecified, no groups will be added to any container.",
   110  						Optional:    true,
   111  						Elem: &schema.Schema{
   112  							Type: schema.TypeInt,
   113  						},
   114  					},
   115  					"se_linux_options": {
   116  						Type:        schema.TypeList,
   117  						Description: "The SELinux context to be applied to all containers. If unspecified, the container runtime will allocate a random SELinux context for each container. May also be set in SecurityContext. If set in both SecurityContext and PodSecurityContext, the value specified in SecurityContext takes precedence for that container.",
   118  						Optional:    true,
   119  						MaxItems:    1,
   120  						Elem: &schema.Resource{
   121  							Schema: seLinuxOptionsField(),
   122  						},
   123  					},
   124  				},
   125  			},
   126  		},
   127  		"service_account_name": {
   128  			Type:        schema.TypeString,
   129  			Optional:    true,
   130  			Computed:    true,
   131  			Description: "ServiceAccountName is the name of the ServiceAccount to use to run this pod. More info: http://releases.k8s.io/HEAD/docs/design/service_accounts.md.",
   132  		},
   133  		"subdomain": {
   134  			Type:        schema.TypeString,
   135  			Optional:    true,
   136  			Description: `If specified, the fully qualified Pod hostname will be "...svc.". If not specified, the pod will not have a domainname at all..`,
   137  		},
   138  		"termination_grace_period_seconds": {
   139  			Type:         schema.TypeInt,
   140  			Optional:     true,
   141  			Default:      30,
   142  			ValidateFunc: validateTerminationGracePeriodSeconds,
   143  			Description:  "Optional duration in seconds the pod needs to terminate gracefully. May be decreased in delete request. Value must be non-negative integer. The value zero indicates delete immediately. If this value is nil, the default grace period will be used instead. The grace period is the duration in seconds after the processes running in the pod are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this value longer than the expected cleanup time for your process.",
   144  		},
   145  
   146  		"volume": {
   147  			Type:        schema.TypeList,
   148  			Optional:    true,
   149  			Description: "List of volumes that can be mounted by containers belonging to the pod. More info: http://kubernetes.io/docs/user-guide/volumes",
   150  			Elem:        volumeSchema(),
   151  		},
   152  	}
   153  }
   154  
   155  func volumeSchema() *schema.Resource {
   156  	v := commonVolumeSources()
   157  
   158  	v["config_map"] = &schema.Schema{
   159  		Type:        schema.TypeList,
   160  		Description: "ConfigMap represents a configMap that should populate this volume",
   161  		Optional:    true,
   162  		MaxItems:    1,
   163  		Elem: &schema.Resource{
   164  			Schema: map[string]*schema.Schema{
   165  				"items": {
   166  					Type:        schema.TypeList,
   167  					Description: `If unspecified, each key-value pair in the Data field of the referenced ConfigMap will be projected into the volume as a file whose name is the key and content is the value. If specified, the listed keys will be projected into the specified paths, and unlisted keys will not be present. If a key is specified which is not present in the ConfigMap, the volume setup will error. Paths must be relative and may not contain the '..' path or start with '..'.`,
   168  					Optional:    true,
   169  					Elem: &schema.Resource{
   170  						Schema: map[string]*schema.Schema{
   171  							"key": {
   172  								Type:        schema.TypeString,
   173  								Optional:    true,
   174  								Description: "The key to project.",
   175  							},
   176  							"mode": {
   177  								Type:        schema.TypeInt,
   178  								Optional:    true,
   179  								Description: `Optional: mode bits to use on this file, must be a value between 0 and 0777. If not specified, the volume defaultMode will be used. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.`,
   180  							},
   181  							"path": {
   182  								Type:         schema.TypeString,
   183  								Optional:     true,
   184  								ValidateFunc: validateAttributeValueDoesNotContain(".."),
   185  								Description:  `The relative path of the file to map the key to. May not be an absolute path. May not contain the path element '..'. May not start with the string '..'.`,
   186  							},
   187  						},
   188  					},
   189  				},
   190  				"default_mode": {
   191  					Type:        schema.TypeInt,
   192  					Description: "Optional: mode bits to use on created files by default. Must be a value between 0 and 0777. Defaults to 0644. Directories within the path are not affected by this setting. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.",
   193  					Optional:    true,
   194  				},
   195  				"name": {
   196  					Type:        schema.TypeString,
   197  					Description: "Name of the referent. More info: http://kubernetes.io/docs/user-guide/identifiers#names",
   198  					Optional:    true,
   199  				},
   200  			},
   201  		},
   202  	}
   203  
   204  	v["git_repo"] = &schema.Schema{
   205  		Type:        schema.TypeList,
   206  		Description: "GitRepo represents a git repository at a particular revision.",
   207  		Optional:    true,
   208  		MaxItems:    1,
   209  		Elem: &schema.Resource{
   210  			Schema: map[string]*schema.Schema{
   211  				"directory": {
   212  					Type:         schema.TypeString,
   213  					Description:  "Target directory name. Must not contain or start with '..'. If '.' is supplied, the volume directory will be the git repository. Otherwise, if specified, the volume will contain the git repository in the subdirectory with the given name.",
   214  					Optional:     true,
   215  					ValidateFunc: validateAttributeValueDoesNotContain(".."),
   216  				},
   217  				"repository": {
   218  					Type:        schema.TypeString,
   219  					Description: "Repository URL",
   220  					Optional:    true,
   221  				},
   222  				"revision": {
   223  					Type:        schema.TypeString,
   224  					Description: "Commit hash for the specified revision.",
   225  					Optional:    true,
   226  				},
   227  			},
   228  		},
   229  	}
   230  	v["downward_api"] = &schema.Schema{
   231  		Type:        schema.TypeList,
   232  		Description: "DownwardAPI represents downward API about the pod that should populate this volume",
   233  		Optional:    true,
   234  		MaxItems:    1,
   235  		Elem: &schema.Resource{
   236  			Schema: map[string]*schema.Schema{
   237  				"default_mode": {
   238  					Type:        schema.TypeInt,
   239  					Description: "Optional: mode bits to use on created files by default. Must be a value between 0 and 0777. Defaults to 0644. Directories within the path are not affected by this setting. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.",
   240  					Optional:    true,
   241  				},
   242  				"items": {
   243  					Type:        schema.TypeList,
   244  					Description: `If unspecified, each key-value pair in the Data field of the referenced ConfigMap will be projected into the volume as a file whose name is the key and content is the value. If specified, the listed keys will be projected into the specified paths, and unlisted keys will not be present. If a key is specified which is not present in the ConfigMap, the volume setup will error. Paths must be relative and may not contain the '..' path or start with '..'.`,
   245  					Optional:    true,
   246  					Elem: &schema.Resource{
   247  						Schema: map[string]*schema.Schema{
   248  							"field_ref": {
   249  								Type:        schema.TypeList,
   250  								Required:    true,
   251  								MaxItems:    1,
   252  								Description: "Required: Selects a field of the pod: only annotations, labels, name and namespace are supported.",
   253  								Elem: &schema.Resource{
   254  									Schema: map[string]*schema.Schema{
   255  										"api_version": {
   256  											Type:        schema.TypeString,
   257  											Optional:    true,
   258  											Default:     "v1",
   259  											Description: `Version of the schema the FieldPath is written in terms of, defaults to "v1".`,
   260  										},
   261  										"field_path": {
   262  											Type:        schema.TypeString,
   263  											Optional:    true,
   264  											Description: "Path of the field to select in the specified API version",
   265  										},
   266  									},
   267  								},
   268  							},
   269  							"mode": {
   270  								Type:        schema.TypeInt,
   271  								Optional:    true,
   272  								Description: `Optional: mode bits to use on this file, must be a value between 0 and 0777. If not specified, the volume defaultMode will be used. This might be in conflict with other options that affect the file mode, like fsGroup, and the result can be other mode bits set.`,
   273  							},
   274  							"path": {
   275  								Type:         schema.TypeString,
   276  								Required:     true,
   277  								ValidateFunc: validateAttributeValueDoesNotContain(".."),
   278  								Description:  `Path is the relative path name of the file to be created. Must not be absolute or contain the '..' path. Must be utf-8 encoded. The first item of the relative path must not start with '..'`,
   279  							},
   280  							"resource_field_ref": {
   281  								Type:        schema.TypeList,
   282  								Optional:    true,
   283  								MaxItems:    1,
   284  								Description: "Selects a resource of the container: only resources limits and requests (limits.cpu, limits.memory, requests.cpu and requests.memory) are currently supported.",
   285  								Elem: &schema.Resource{
   286  									Schema: map[string]*schema.Schema{
   287  										"container_name": {
   288  											Type:     schema.TypeString,
   289  											Required: true,
   290  										},
   291  										"quantity": {
   292  											Type:     schema.TypeString,
   293  											Optional: true,
   294  										},
   295  										"resource": {
   296  											Type:        schema.TypeString,
   297  											Required:    true,
   298  											Description: "Resource to select",
   299  										},
   300  									},
   301  								},
   302  							},
   303  						},
   304  					},
   305  				},
   306  			},
   307  		},
   308  	}
   309  
   310  	v["empty_dir"] = &schema.Schema{
   311  		Type:        schema.TypeList,
   312  		Description: "EmptyDir represents a temporary directory that shares a pod's lifetime. More info: http://kubernetes.io/docs/user-guide/volumes#emptydir",
   313  		Optional:    true,
   314  		MaxItems:    1,
   315  		Elem: &schema.Resource{
   316  			Schema: map[string]*schema.Schema{
   317  				"medium": {
   318  					Type:         schema.TypeString,
   319  					Description:  `What type of storage medium should back this directory. The default is "" which means to use the node's default medium. Must be an empty string (default) or Memory. More info: http://kubernetes.io/docs/user-guide/volumes#emptydir`,
   320  					Optional:     true,
   321  					Default:      "",
   322  					ValidateFunc: validateAttributeValueIsIn([]string{"", "Memory"}),
   323  				},
   324  			},
   325  		},
   326  	}
   327  
   328  	v["persistent_volume_claim"] = &schema.Schema{
   329  		Type:        schema.TypeList,
   330  		Description: "The specification of a persistent volume.",
   331  		Optional:    true,
   332  		MaxItems:    1,
   333  		Elem: &schema.Resource{
   334  			Schema: map[string]*schema.Schema{
   335  				"claim_name": {
   336  					Type:        schema.TypeString,
   337  					Description: "ClaimName is the name of a PersistentVolumeClaim in the same ",
   338  					Optional:    true,
   339  				},
   340  				"read_only": {
   341  					Type:        schema.TypeBool,
   342  					Description: "Will force the ReadOnly setting in VolumeMounts.",
   343  					Optional:    true,
   344  					Default:     false,
   345  				},
   346  			},
   347  		},
   348  	}
   349  
   350  	v["secret"] = &schema.Schema{
   351  		Type:        schema.TypeList,
   352  		Description: "Secret represents a secret that should populate this volume. More info: http://kubernetes.io/docs/user-guide/volumes#secrets",
   353  		Optional:    true,
   354  		MaxItems:    1,
   355  		Elem: &schema.Resource{
   356  			Schema: map[string]*schema.Schema{
   357  				"secret_name": {
   358  					Type:        schema.TypeString,
   359  					Description: "Name of the secret in the pod's namespace to use. More info: http://kubernetes.io/docs/user-guide/volumes#secrets",
   360  					Optional:    true,
   361  				},
   362  			},
   363  		},
   364  	}
   365  	v["name"] = &schema.Schema{
   366  		Type:        schema.TypeString,
   367  		Description: "Volume's name. Must be a DNS_LABEL and unique within the pod. More info: http://kubernetes.io/docs/user-guide/identifiers#names",
   368  		Optional:    true,
   369  	}
   370  	return &schema.Resource{
   371  		Schema: v,
   372  	}
   373  }