-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathschema_stateful_set_spec.go
More file actions
146 lines (143 loc) · 5 KB
/
schema_stateful_set_spec.go
File metadata and controls
146 lines (143 loc) · 5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
// Copyright IBM Corp. 2017, 2025
// SPDX-License-Identifier: MPL-2.0
package kubernetes
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
)
func statefulSetSpecFields() map[string]*schema.Schema {
s := map[string]*schema.Schema{
"pod_management_policy": {
Type: schema.TypeString,
Description: "Controls how pods are created during initial scale up, when replacing pods on nodes, or when scaling down.",
Optional: true,
ForceNew: true,
Computed: true,
ValidateFunc: validation.StringInSlice([]string{
"OrderedReady",
"Parallel",
}, false),
},
"replicas": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "The desired number of replicas of the given Template, in the sense that they are instantiations of the same Template. Value must be a positive integer.",
ValidateFunc: validateTypeStringNullableInt,
},
"revision_history_limit": {
Type: schema.TypeInt,
Optional: true,
ForceNew: true,
Computed: true,
ValidateFunc: validatePositiveInteger,
Description: "The maximum number of revisions that will be maintained in the StatefulSet's revision history. The default value is 10.",
},
"selector": {
Type: schema.TypeList,
Description: "A label query over pods that should match the replica count. It must match the pod template's labels.",
Required: true,
ForceNew: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: labelSelectorFields(false),
},
},
"service_name": {
Type: schema.TypeString,
Description: "The name of the service that governs this StatefulSet. This service must exist before the StatefulSet, and is responsible for the network identity of the set.",
Required: true,
ForceNew: true,
},
"template": {
Type: schema.TypeList,
Description: "The object that describes the pod that will be created if insufficient replicas are detected. Each pod stamped out by the StatefulSet will fulfill this Template.",
Required: true,
MaxItems: 1,
Elem: &schema.Resource{
Schema: podTemplateFields("stateful set"),
},
},
"update_strategy": {
Type: schema.TypeList,
Description: "The strategy that the StatefulSet controller will use to perform updates.",
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"type": {
Type: schema.TypeString,
Description: "Indicates the type of the StatefulSet update strategy. Default is RollingUpdate",
Optional: true,
Default: "RollingUpdate",
ValidateFunc: validation.StringInSlice([]string{
"RollingUpdate",
"OnDelete",
}, false),
},
"rolling_update": {
Type: schema.TypeList,
Description: "RollingUpdate strategy type for StatefulSet",
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"partition": {
Type: schema.TypeInt,
Optional: true,
Description: "Indicates the ordinal at which the StatefulSet should be partitioned. Default value is 0.",
Default: 0,
},
},
},
},
},
},
},
"volume_claim_template": {
Type: schema.TypeList,
Optional: true,
ForceNew: true,
Description: "A list of claims that pods are allowed to reference. Every claim in this list must have at least one matching (by name) volumeMount in one container in the template.",
Elem: &schema.Resource{
Schema: persistentVolumeClaimFields(),
},
},
"persistent_volume_claim_retention_policy": {
Type: schema.TypeList,
Optional: true,
Computed: true,
Description: "The field controls if and how PVCs are deleted during the lifecycle of a StatefulSet.",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"when_deleted": {
Type: schema.TypeString,
Description: "This field controls what happens when a Statefulset is deleted. Default is Retain.",
Optional: true,
Default: "Retain",
ValidateFunc: validation.StringInSlice([]string{
"Retain",
"Delete",
}, false),
},
"when_scaled": {
Type: schema.TypeString,
Description: "This field controls what happens when a Statefulset is scaled. Default is Retain.",
Optional: true,
Default: "Retain",
ValidateFunc: validation.StringInSlice([]string{
"Retain",
"Delete",
}, false),
},
},
},
},
"min_ready_seconds": {
Type: schema.TypeInt,
Description: "Minimum number of seconds for which a newly created pod should be ready without any of its container crashing for it to be considered available. Defaults to 0. (pod will be considered available as soon as it is ready)",
Optional: true,
Default: 0,
ValidateFunc: validateNonNegativeInteger,
},
}
return s
}