MCPcopy Index your code
hub / github.com/zalando/postgres-operator / createStatefulSet

Method createStatefulSet

pkg/cluster/resources.go:94–122  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

92}
93
94func (c *Cluster) createStatefulSet() (*appsv1.StatefulSet, error) {
95 c.setProcessName("creating statefulset")
96 // check if it's allowed that spec contains initContainers
97 if len(c.Spec.InitContainers) > 0 &&
98 c.OpConfig.EnableInitContainers != nil && !(*c.OpConfig.EnableInitContainers) {
99 return nil, fmt.Errorf("initContainers specified but disabled in configuration")
100 }
101 // check if it's allowed that spec contains sidecars
102 if len(c.Spec.Sidecars) > 0 &&
103 c.OpConfig.EnableSidecars != nil && !(*c.OpConfig.EnableSidecars) {
104 return nil, fmt.Errorf("sidecar containers specified but disabled in configuration")
105 }
106
107 statefulSetSpec, err := c.generateStatefulSet(&c.Spec)
108 if err != nil {
109 return nil, fmt.Errorf("could not generate statefulset: %v", err)
110 }
111 statefulSet, err := c.KubeClient.StatefulSets(statefulSetSpec.Namespace).Create(
112 context.TODO(),
113 statefulSetSpec,
114 metav1.CreateOptions{})
115 if err != nil {
116 return nil, err
117 }
118 c.Statefulset = statefulSet
119 c.logger.Debugf("created new statefulset %q, uid: %q", util.NameFromMeta(statefulSet.ObjectMeta), statefulSet.UID)
120
121 return statefulSet, nil
122}
123
124func getPodIndex(podName string) (int32, error) {
125 parts := strings.Split(podName, "-")

Callers 12

syncStatefulSetMethod · 0.95
CreateMethod · 0.95
TestConnectionPoolerSyncFunction · 0.80
TestPoolerTLSFunction · 0.80
TestTLSFunction · 0.80
TestAdditionalVolumeFunction · 0.80
TestPodAnnotationsSyncFunction · 0.80

Calls 4

setProcessNameMethod · 0.95
generateStatefulSetMethod · 0.95
NameFromMetaFunction · 0.92
CreateMethod · 0.65

Tested by 10

TestConnectionPoolerSyncFunction · 0.64
TestPoolerTLSFunction · 0.64
TestTLSFunction · 0.64
TestAdditionalVolumeFunction · 0.64
TestPodAnnotationsSyncFunction · 0.64