-
Notifications
You must be signed in to change notification settings - Fork 88
/
schemahero_objects.go
71 lines (65 loc) · 1.63 KB
/
schemahero_objects.go
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
package kotsadm
import (
"fmt"
"time"
"github.com/replicatedhq/kots/pkg/kotsadm/types"
"github.com/replicatedhq/kots/pkg/util"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
func migrationsPod(deployOptions types.DeployOptions) *corev1.Pod {
name := fmt.Sprintf("kotsadm-migrations-%d", time.Now().Unix())
var securityContext corev1.PodSecurityContext
if !deployOptions.IsOpenShift {
securityContext = corev1.PodSecurityContext{
RunAsUser: util.IntPointer(1001),
FSGroup: util.IntPointer(1001),
}
}
pod := &corev1.Pod{
TypeMeta: metav1.TypeMeta{
APIVersion: "v1",
Kind: "Pod",
},
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: deployOptions.Namespace,
Labels: map[string]string{
types.KotsadmKey: types.KotsadmLabelValue,
},
},
Spec: corev1.PodSpec{
SecurityContext: &securityContext,
RestartPolicy: corev1.RestartPolicyOnFailure,
Containers: []corev1.Container{
{
Image: fmt.Sprintf("%s/kotsadm-migrations:%s", kotsadmRegistry(), kotsadmTag()),
ImagePullPolicy: corev1.PullAlways,
Name: name,
Env: []corev1.EnvVar{
{
Name: "SCHEMAHERO_DRIVER",
Value: "postgres",
},
{
Name: "SCHEMAHERO_SPEC_FILE",
Value: "/tables",
},
{
Name: "SCHEMAHERO_URI",
ValueFrom: &corev1.EnvVarSource{
SecretKeyRef: &corev1.SecretKeySelector{
LocalObjectReference: corev1.LocalObjectReference{
Name: "kotsadm-postgres",
},
Key: "uri",
},
},
},
},
},
},
},
}
return pod
}