/
sts.go
156 lines (153 loc) · 4.46 KB
/
sts.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
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
147
148
149
150
151
152
153
154
155
156
package webui
import (
"github.com/ghodss/yaml"
appsv1 "k8s.io/api/apps/v1"
)
var yamlDatawebui_sts = `
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: webui
spec:
selector:
matchLabels:
app: webui
serviceName: "webui"
replicas: 1
template:
metadata:
labels:
app: webui
contrail_manager: webui
spec:
initContainers:
- name: nodeinit
image: docker.io/michaelhenkel/contrail-node-init:5.2.0-dev1
env:
- name: CONTRAIL_STATUS_IMAGE
value: docker.io/michaelhenkel/contrail-status:5.2.0-dev1
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
imagePullPolicy: Always
securityContext:
privileged: true
volumeMounts:
- mountPath: /host/usr/bin
name: host-usr-local-bin
- name: init
image: busybox
command:
- sh
- -c
- until grep ready /tmp/podinfo/pod_labels > /dev/null 2>&1; do sleep 1; done
env:
- name: CONTRAIL_STATUS_IMAGE
value: hub.juniper.net/contrail-nightly/contrail-status:5.2.0-0.740
imagePullPolicy: Always
resources: {}
securityContext:
privileged: false
procMount: Default
terminationMessagePath: /dev/termination-log
terminationMessagePolicy: File
volumeMounts:
- mountPath: /tmp/podinfo
name: status
containers:
- name: webuiweb
image: docker.io/michaelhenkel/contrail-controller-webui-web:5.2.0-dev1
env:
- name: WEBUI_SSL_KEY_FILE
value: /etc/contrail/webui_ssl/cs-key.pem
- name: WEBUI_SSL_CERT_FILE
value: /etc/contrail/webui_ssl/cs-cert.pem
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
imagePullPolicy: Always
volumeMounts:
- mountPath: /var/log/contrail
name: webui-logs
- name: webuijob
image: docker.io/michaelhenkel/contrail-controller-webui-job:5.2.0-dev1
env:
- name: WEBUI_SSL_KEY_FILE
value: /etc/contrail/webui_ssl/cs-key.pem
- name: WEBUI_SSL_CERT_FILE
value: /etc/contrail/webui_ssl/cs-cert.pem
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
imagePullPolicy: Always
volumeMounts:
- mountPath: /var/log/contrail
name: webui-logs
- name: redis
image: docker.io/michaelhenkel/contrail-external-redis:5.2.0-dev1
env:
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
imagePullPolicy: Always
volumeMounts:
- mountPath: /var/log/contrail
name: webui-logs
- mountPath: /var/lib/redis
name: webui-data
dnsPolicy: ClusterFirst
hostNetwork: true
nodeSelector:
node-role.kubernetes.io/master: ""
restartPolicy: Always
tolerations:
- effect: NoSchedule
operator: Exists
- effect: NoExecute
operator: Exists
volumes:
- hostPath:
path: /var/lib/contrail/webui
type: ""
name: webui-data
- hostPath:
path: /var/log/contrail/webui
type: ""
name: webui-logs
- hostPath:
path: /usr/local/bin
type: ""
name: host-usr-local-bin
- downwardAPI:
defaultMode: 420
items:
- fieldRef:
apiVersion: v1
fieldPath: metadata.labels
path: pod_labels
- fieldRef:
apiVersion: v1
fieldPath: metadata.labels
path: pod_labelsx
name: status`
// GetSTS returns StatesfulSet object created from YAML yamlDatawebui_sts
func GetSTS() *appsv1.StatefulSet {
sts := appsv1.StatefulSet{}
err := yaml.Unmarshal([]byte(yamlDatawebui_sts), &sts)
if err != nil {
panic(err)
}
jsonData, err := yaml.YAMLToJSON([]byte(yamlDatawebui_sts))
if err != nil {
panic(err)
}
err = yaml.Unmarshal([]byte(jsonData), &sts)
if err != nil {
panic(err)
}
return &sts
}