forked from leaf-ai/studio-go-runner
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_k8s_local.yaml
225 lines (225 loc) · 5.83 KB
/
test_k8s_local.yaml
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
---
apiVersion: v1
kind: Namespace
metadata:
name: build-test-k8s-local
---
# The following role allows the runner under test to interact with the working state config map
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: run-cluster-admin
subjects:
- kind: ServiceAccount
name: default
namespace: build-test-k8s-local
roleRef:
kind: ClusterRole
name: cluster-admin
apiGroup: rbac.authorization.k8s.io
---
apiVersion: v1
kind: ConfigMap
metadata:
name: build-env
namespace: build-test-k8s-local
data:
LOGXI: "*=INF"
RABBITMQ_DEFAULT_USER: "UserUser"
RABBITMQ_DEFAULT_PASS: "PasswordPassword"
MINIO_ACCESS_KEY: "UserUser"
MINIO_SECRET_KEY: "PasswordPassword"
MINIO_TEST_SERVER: "${MINIO_SERVICE_SERVICE_HOST}:${MINIO_SERVICE_SERVICE_PORT}"
AMQP_URL: "amqp://${RABBITMQ_DEFAULT_USER}:${RABBITMQ_DEFAULT_PASS}@${RABBITMQ_SERVICE_SERVICE_HOST}:${RABBITMQ_SERVICE_SERVICE_PORT}/%2f?connection_attempts=2&retry_delay=.5&socket_timeout=5"
CLEAR_TEXT_MESSAGES: "true"
---
apiVersion: v1
kind: Secret
metadata:
name: studioml-signing
namespace: build-test-k8s-local
type: Opaque
data:
info: RHVtbXkgU2VjcmV0IHNvIHJlc291cmNlIHJlbWFpbnMgcHJlc2VudA==
---
# This service exposes rabbit MQ to the cluster members
apiVersion: v1
kind: Service
metadata:
labels:
component: rabbitmq
name: rabbitmq-service
namespace: build-test-k8s-local
spec:
ports:
- name: rmq-client
port: 5672
- name: rmq-admin
port: 15672
selector:
app: taskQueue
component: rabbitmq
---
# The replication controller encapsulates the pod(s) used to run RabbitMQ
apiVersion: v1
kind: ReplicationController
metadata:
labels:
component: rabbitmq
name: rabbitmq-controller
namespace: build-test-k8s-local
spec:
replicas: 1
template:
metadata:
labels:
app: taskQueue
component: rabbitmq
spec:
containers:
- image: rabbitmq
name: rabbitmq
ports:
- containerPort: 5672
- containerPort: 15672
resources:
limits:
cpu: 1
envFrom:
- configMapRef:
name: build-env
lifecycle:
postStart:
exec:
command:
- "/bin/bash"
- "-c"
- >
set -euo pipefail ;
IFS=$'\n\t' ;
echo "Starting the install of the management plugin" ;
sleep 30 ;
rabbitmq-plugins enable rabbitmq_management ;
apt-get -y update ; apt-get install -y wget python ;
wget -q -O /usr/local/bin/rabbitmqadmin http://localhost:15672/cli/rabbitmqadmin ;
chmod +x /usr/local/bin/rabbitmqadmin
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
# This name uniquely identifies the PVC. Will be used in deployment below.
name: minio-pv-claim
labels:
app: minio-storage-claim
namespace: build-test-k8s-local
spec:
# Read more about access modes here: https://kubernetes.io/docs/user-guide/persistent-volumes/#access-modes
accessModes:
- ReadWriteOnce
resources:
# This is the request for storage. Should be available in the cluster.
requests:
storage: 10Gi
# Uncomment and add storageClass specific to your requirements below. Read more https://kubernetes.io/docs/concepts/storage/persistent-volumes/#class-1
#storageClassName:
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
# This name uniquely identifies the Deployment
name: minio-deployment
namespace: build-test-k8s-local
spec:
strategy:
type: Recreate
template:
metadata:
labels:
# Label is used as selector in the service.
app: minio
spec:
# Refer to the PVC created earlier
volumes:
- name: storage
persistentVolumeClaim:
# Name of the PVC created earlier
claimName: minio-pv-claim
containers:
- name: minio
# Pulls the default Minio image from Docker Hub
image: minio/minio
args:
- server
- /storage
envFrom:
- configMapRef:
name: build-env
ports:
- containerPort: 9000
# Mount the volume into the pod
volumeMounts:
- name: storage # must match the volume name, above
mountPath: "/storage"
---
apiVersion: v1
kind: Service
metadata:
name: minio-service
namespace: build-test-k8s-local
spec:
type: LoadBalancer
ports:
- port: 9000
targetPort: 9000
protocol: TCP
selector:
app: minio
---
# This job starts a run to completion runner to perform the integration and end-to-end testing
apiVersion: batch/v1
kind: Job
metadata:
name: build
namespace: build-test-k8s-local
spec:
template:
spec:
volumes:
- name: podinfo
downwardAPI:
items:
- path: "namespace"
fieldRef:
fieldPath: metadata.namespace
- path: "annotations"
fieldRef:
fieldPath: metadata.annotations
- path: "labels"
fieldRef:
fieldPath: metadata.labels
containers:
- name: build
env:
- name: K8S_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: K8S_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
envFrom:
- configMapRef:
name: build-env
image: localhost:32000/leafai/studio-go-runner-standalone-build
imagePullPolicy: Always
resources:
limits:
memory: "1024Mi"
cpu: 1
volumeMounts:
- name: podinfo
mountPath: /etc/podinfo
readOnly: false
restartPolicy: Never
backoffLimit: 4