summaryrefslogtreecommitdiffstats
path: root/roles/openshift_examples/files/examples/v3.10/quickstart-templates/amp.yml
blob: 4e469f6e80bf1d18fa8c9c111eeb702a82c230e2 (plain)
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
base_env: &base_env
- name: RAILS_ENV
  value: "production"
- name: DATABASE_URL
  value: "mysql2://root:${MYSQL_ROOT_PASSWORD}@system-mysql/${MYSQL_DATABASE}"
- name: FORCE_SSL
  value: "true"
- name: THREESCALE_SUPERDOMAIN
  value: "${WILDCARD_DOMAIN}"
- name: TENANT_NAME
  value: "${TENANT_NAME}"
- name: APICAST_ACCESS_TOKEN
  value: "${APICAST_ACCESS_TOKEN}"
- name: ADMIN_ACCESS_TOKEN
  value: "${ADMIN_ACCESS_TOKEN}"
- name: PROVIDER_PLAN
  value: 'enterprise'
- name: USER_LOGIN
  value: "${ADMIN_USERNAME}"
- name: USER_PASSWORD
  value: "${ADMIN_PASSWORD}"
- name: RAILS_LOG_TO_STDOUT
  value: "true"
- name: RAILS_LOG_LEVEL
  value: "info"
- name: THINKING_SPHINX_ADDRESS
  value: "system-sphinx"
- name: THINKING_SPHINX_PORT
  value: "9306"
- name: THINKING_SPHINX_CONFIGURATION_FILE
  value: "/tmp/sphinx.conf"
- name: EVENTS_SHARED_SECRET
  value: "${SYSTEM_BACKEND_SHARED_SECRET}"
- name: THREESCALE_SANDBOX_PROXY_OPENSSL_VERIFY_MODE
  value: "VERIFY_NONE"
- name: APICAST_BACKEND_ROOT_ENDPOINT
  value: "https://backend-${TENANT_NAME}.${WILDCARD_DOMAIN}"
- name: CONFIG_INTERNAL_API_USER
  value: "${SYSTEM_BACKEND_USERNAME}"
- name: CONFIG_INTERNAL_API_PASSWORD
  value: "${SYSTEM_BACKEND_PASSWORD}"
- name: SECRET_KEY_BASE
  value: "${SYSTEM_APP_SECRET_KEY_BASE}"
- name: AMP_RELEASE
  value: "${AMP_RELEASE}"
- name: SMTP_ADDRESS
  valueFrom:
    configMapKeyRef:
      name: smtp
      key: address
- name: SMTP_USER_NAME
  valueFrom:
    configMapKeyRef:
      name: smtp
      key: username
- name: SMTP_PASSWORD
  valueFrom:
    configMapKeyRef:
      name: smtp
      key: password
- name: SMTP_DOMAIN
  valueFrom:
    configMapKeyRef:
      name: smtp
      key: domain
- name: SMTP_PORT
  valueFrom:
    configMapKeyRef:
      name: smtp
      key: port
- name: SMTP_AUTHENTICATION
  valueFrom:
    configMapKeyRef:
      name: smtp
      key: authentication
- name: SMTP_OPENSSL_VERIFY_MODE
  valueFrom:
    configMapKeyRef:
      name: smtp
      key: openssl.verify.mode
- name: BACKEND_ROUTE
  value: "https://backend-${TENANT_NAME}.${WILDCARD_DOMAIN}"

apiVersion: v1
kind: Template
metadata:
  name: "system"
message: "Login on https://${TENANT_NAME}-admin.${WILDCARD_DOMAIN} as ${ADMIN_USERNAME}/${ADMIN_PASSWORD}"
objects:

- apiVersion: "v1"
  kind: "PersistentVolumeClaim"
  metadata:
    name: "system-storage"
  spec:
    accessModes:
    - "ReadWriteMany"
    resources:
      requests:
        storage: "100Mi"

- apiVersion: "v1"
  kind: "PersistentVolumeClaim"
  metadata:
    name: "mysql-storage"
  spec:
    accessModes:
    - "ReadWriteOnce"
    resources:
      requests:
        storage: "1Gi"

- apiVersion: "v1"
  kind: "PersistentVolumeClaim"
  metadata:
    name: "system-redis-storage"
  spec:
    accessModes:
    - "ReadWriteOnce"
    resources:
      requests:
        storage: "1Gi"

- apiVersion: "v1"
  kind: "PersistentVolumeClaim"
  metadata:
    name: "backend-redis-storage"
  spec:
    accessModes:
    - "ReadWriteOnce"
    resources:
      requests:
        storage: "1Gi"

- apiVersion: v1
  kind: DeploymentConfig
  metadata:
    name: backend-cron
  spec:
    replicas: 1
    selector:
      name: backend-cron
    strategy:
      rollingParams:
        intervalSeconds: 1
        maxSurge: 25%
        maxUnavailable: 25%
        timeoutSeconds: 600
        updatePeriodSeconds: 1
      type: Rolling
    template:
      metadata:
        labels:
          name: backend-cron
      spec:
        containers:
        - args:
          - backend-cron
          env:
          - name: CONFIG_REDIS_PROXY
            value: "backend-redis:6379"
          - name: CONFIG_QUEUES_MASTER_NAME
            value: "backend-redis:6379/1"
          - name: RACK_ENV
            value: "production"
          image: 3scale-amp20/backend:1.0-2
          imagePullPolicy: IfNotPresent
          name: backend-cron
    triggers:
    - type: ConfigChange

- apiVersion: v1
  kind: DeploymentConfig
  metadata:
    name: backend-redis
  spec:
    replicas: 1
    selector:
      name: backend-redis
    strategy:
      type: Recreate
    template:
      metadata:
        labels:
          name: backend-redis
      spec:
        containers:
        - image: ${REDIS_IMAGE}
          imagePullPolicy: IfNotPresent
          name: backend-redis
          readinessProbe:
            exec:
              command:
              - "container-entrypoint"
              - "bash"
              - "-c"
              - "redis-cli set liveness-probe \"`date`\" | grep OK"
            initialDelaySeconds: 10
            periodSeconds: 30
            timeoutSeconds: 1
          livenessProbe:
            tcpSocket:
              port: 6379
            initialDelaySeconds: 10
            periodSeconds: 10
          volumeMounts:
          - name: backend-redis-storage
            mountPath: "/var/lib/redis/data"
          - name: redis-config
            mountPath: /etc/redis.conf
            subPath: redis.conf
        volumes:
        - name: backend-redis-storage
          persistentVolumeClaim:
            claimName: backend-redis-storage
        - name: redis-config
          configMap:
            name: redis-config
            items:
            - key: redis.conf
              path: redis.conf
    triggers:
    - type: ConfigChange

- apiVersion: v1
  kind: DeploymentConfig
  metadata:
    name: backend-listener
  spec:
    replicas: 1
    selector:
      name: backend-listener
    strategy:
      rollingParams:
        intervalSeconds: 1
        maxSurge: 25%
        maxUnavailable: 25%
        timeoutSeconds: 600
        updatePeriodSeconds: 1
      type: Rolling
    template:
      metadata:
        labels:
          name: backend-listener
      spec:
        containers:
        - args:
          - 3scale_backend
          - start
          - "-e"
          - production
          - "-p"
          - '3000'
          - "-x"
          - "/dev/stdout"
          env:
          - name: CONFIG_REDIS_PROXY
            value: "backend-redis:6379"
          - name: CONFIG_QUEUES_MASTER_NAME
            value: "backend-redis:6379/1"
          - name: RACK_ENV
            value: "production"
          - name: CONFIG_INTERNAL_API_USER
            value: "${SYSTEM_BACKEND_USERNAME}"
          - name: CONFIG_INTERNAL_API_PASSWORD
            value: "${SYSTEM_BACKEND_PASSWORD}"
          image: 3scale-amp20/backend:1.0-2
          imagePullPolicy: IfNotPresent
          name: backend-listener
          livenessProbe:
            initialDelaySeconds: 30
            periodSeconds: 10
            tcpSocket:
              port: 3000
          readinessProbe:
            httpGet:
              path: "/status"
              port: 3000
            initialDelaySeconds: 30
            timeoutSeconds: 5
          ports:
          - containerPort: 3000
            protocol: TCP
    triggers:
    - type: ConfigChange

- apiVersion: v1
  kind: Service
  metadata:
    name: backend-redis
  spec:
    ports:
    - port: 6379
      protocol: TCP
      targetPort: 6379
    selector:
      name: backend-redis

- apiVersion: v1
  kind: Service
  metadata:
    name: backend-listener
  spec:
    ports:
    - port: 3000
      protocol: TCP
      targetPort: 3000
      name: http
    selector:
      name: backend-listener

- apiVersion: v1
  kind: Service
  metadata:
    name: system-provider
  spec:
    ports:
    - port: 3000
      protocol: TCP
      targetPort: provider
      name: http
    selector:
      name: system-app

- apiVersion: v1
  kind: Service
  metadata:
    name: system-developer
  spec:
    ports:
    - port: 3000
      protocol: TCP
      targetPort: developer
      name: http
    selector:
      name: system-app

- apiVersion: v1
  kind: DeploymentConfig
  metadata:
    name: backend-worker
  spec:
    replicas: 1
    selector:
      name: backend-worker
    strategy:
      rollingParams:
        intervalSeconds: 1
        maxSurge: 25%
        maxUnavailable: 25%
        timeoutSeconds: 600
        updatePeriodSeconds: 1
      type: Rolling
    template:
      metadata:
        labels:
          name: backend-worker
      spec:
        containers:
        - args:
          - 3scale_backend_worker
          - run
          env:
          - name: CONFIG_REDIS_PROXY
            value: "backend-redis:6379"
          - name: CONFIG_QUEUES_MASTER_NAME
            value: "backend-redis:6379/1"
          - name: RACK_ENV
            value: "production"
          - name: CONFIG_EVENTS_HOOK
            value: http://system-provider:3000/master/events/import
          - name: CONFIG_EVENTS_HOOK_SHARED_SECRET
            value: ${SYSTEM_BACKEND_SHARED_SECRET}
          image: 3scale-amp20/backend:1.0-2
          imagePullPolicy: IfNotPresent
          name: backend-worker
    triggers:
    - type: ConfigChange

- kind: Service
  apiVersion: v1
  metadata:
    name: 'system-mysql'
  spec:
    ports:
    - name: system-mysql
      protocol: TCP
      port: 3306
      targetPort: 3306
      nodePort: 0
    selector:
      name: 'system-mysql'
- apiVersion: v1
  kind: Service
  metadata:
    name: system-redis
  spec:
    ports:
    - port: 6379
      protocol: TCP
      targetPort: 6379
      name: redis
    selector:
      name: system-redis


- apiVersion: v1
  kind: DeploymentConfig
  metadata:
    name: system-redis
  spec:
    replicas: 1
    selector:
      name: system-redis
    strategy:
      type: Recreate
    template:
      metadata:
        labels:
          name: system-redis
      spec:
        containers:
        - args:
          image: ${REDIS_IMAGE}
          imagePullPolicy: IfNotPresent
          name: system-redis
          terminationMessagePath: /dev/termination-log
          volumeMounts:
          - name: system-redis-storage
            mountPath: "/var/lib/redis/data"
          - name: redis-config
            mountPath: /etc/redis.conf
            subPath: redis.conf
          readinessProbe:
            exec:
              command:
              - "container-entrypoint"
              - "bash"
              - "-c"
              - "redis-cli set liveness-probe \"`date`\" | grep OK"
            initialDelaySeconds: 30
            periodSeconds: 10
            timeoutSeconds: 5
          livenessProbe:
            tcpSocket:
              port: 6379
            initialDelaySeconds: 10
            periodSeconds: 5
        volumes:
        - name: system-redis-storage
          persistentVolumeClaim:
            claimName: system-redis-storage
        - name: redis-config
          configMap:
            name: redis-config
            items:
            - key: redis.conf
              path: redis.conf
    triggers:
    - type: ConfigChange

- apiVersion: v1
  kind: Service
  metadata:
    name: system-sphinx
  spec:
    ports:
    - port: 9306
      protocol: TCP
      targetPort: 9306
      name: sphinx
    selector:
      name: system-sphinx

- apiVersion: v1
  kind: DeploymentConfig
  metadata:
    name: system-sphinx
  spec:
    replicas: 1
    selector:
      name: system-sphinx
    strategy:
      rollingParams:
        intervalSeconds: 1
        maxSurge: 25%
        maxUnavailable: 25%
        timeoutSeconds: 600
        updatePeriodSeconds: 1
      type: Rolling
    template:
      metadata:
        labels:
          name: system-sphinx
      spec:
        volumes:
        - name: system-sphinx-database
          emptyDir: {}
        containers:
        - args:
          - rake
          - 'openshift:thinking_sphinx:start'
          volumeMounts:
          - name: system-sphinx-database
            mountPath: "/opt/system/db/sphinx"
          env:
          - name: RAILS_ENV
            value: production
          - name: DATABASE_URL
            value: "mysql2://root:${MYSQL_ROOT_PASSWORD}@system-mysql/${MYSQL_DATABASE}"
          - name: THINKING_SPHINX_ADDRESS
            value: 0.0.0.0
          - name: THINKING_SPHINX_CONFIGURATION_FILE
            value: "db/sphinx/production.conf"
          - name: THINKING_SPHINX_PID_FILE
            value: db/sphinx/searchd.pid
          - name: DELTA_INDEX_INTERVAL
            value: '5'
          - name: FULL_REINDEX_INTERVAL
            value: '60'
          image: 3scale-amp20/system:1.0-2
          imagePullPolicy: IfNotPresent
          name: system-sphinx
          livenessProbe:
            tcpSocket:
              port: 9306
            initialDelaySeconds: 60
            periodSeconds: 10
    triggers:
    - type: ConfigChange

- apiVersion: v1
  kind: Service
  metadata:
    name: system-memcache
  spec:
    ports:
    - port: 11211
      protocol: TCP
      targetPort: 11211
      name: memcache
    selector:
      name: system-memcache
- apiVersion: v1
  kind: DeploymentConfig
  metadata:
    name: system-memcache
  spec:
    replicas: 1
    selector:
      name: system-memcache
    strategy:
      rollingParams:
        intervalSeconds: 1
        maxSurge: 25%
        maxUnavailable: 25%
        timeoutSeconds: 600
        updatePeriodSeconds: 1
      type: Rolling
    template:
      metadata:
        labels:
          name: system-memcache
      spec:
        containers:
        - args:
          env:
          image: 3scale-amp20/memcached:1.4.15-7
          imagePullPolicy: IfNotPresent
          name: memcache
          readinessProbe:
            exec:
              command:
              - "sh"
              - "-c"
              - "echo version | nc $HOSTNAME 11211 | grep VERSION"
            initialDelaySeconds: 10
            periodSeconds: 30
            timeoutSeconds: 5
          livenessProbe:
            tcpSocket:
              port: 11211
            initialDelaySeconds: 10
            periodSeconds: 10
          command:
          - "memcached"
          - "-m"
          - "64"
        ports:
        - containerPort: 6379
          protocol: TCP
    triggers:
    - type: ConfigChange

- apiVersion: v1
  kind: Route
  metadata:
    name: system-provider-admin-route
    labels:
      app: system-route
  spec:
    host: ${TENANT_NAME}-admin.${WILDCARD_DOMAIN}
    to:
      kind: Service
      name: system-provider
    port:
      targetPort: http
    tls:
      termination: edge
      insecureEdgeTerminationPolicy: Allow

- apiVersion: v1
  kind: Route
  metadata:
    name: backend-route
    labels:
      app: system-route
  spec:
    host: backend-${TENANT_NAME}.${WILDCARD_DOMAIN}
    to:
      kind: Service
      name: backend-listener
    port:
      targetPort: http
    tls:
      termination: edge
      insecureEdgeTerminationPolicy: Allow

- apiVersion: v1
  kind: Route
  metadata:
    name: system-developer-route
    labels:
      app: system-route
  spec:
    host: ${TENANT_NAME}.${WILDCARD_DOMAIN}
    to:
      kind: Service
      name: system-developer
    port:
      targetPort: http
    tls:
      termination: edge
      insecureEdgeTerminationPolicy: Allow

- apiVersion: v1
  kind: DeploymentConfig
  metadata:
    name: apicast-staging
  spec:
    replicas: 1
    selector:
      deploymentconfig: apicast-staging
    strategy:
      rollingParams:
        intervalSeconds: 1
        maxSurge: 25%
        maxUnavailable: 25%
        timeoutSeconds: 1800
        updatePeriodSeconds: 1
      type: Rolling
    template:
      metadata:
        labels:
          deploymentconfig: apicast-staging
      spec:
        containers:
        - env:
          - name: THREESCALE_PORTAL_ENDPOINT
            value: http://${APICAST_ACCESS_TOKEN}@system-provider:3000
          - name: APICAST_CONFIGURATION_LOADER
            value: "lazy"
          - name: APICAST_CONFIGURATION_CACHE
            value: "0"
          - name: THREESCALE_DEPLOYMENT_ENV
            value: "sandbox"
          - name: APICAST_MANAGEMENT_API
            value: "${APICAST_MANAGEMENT_API}"
          - name: BACKEND_ENDPOINT_OVERRIDE
            value: http://backend-listener:3000
          - name: OPENSSL_VERIFY
            value: '${APICAST_OPENSSL_VERIFY}'
          - name: APICAST_RESPONSE_CODES
            value: '${APICAST_RESPONSE_CODES}'
          - name: REDIS_URL
            value: "redis://system-redis:6379/2"
          image: 3scale-amp20/apicast-gateway:1.0-3
          imagePullPolicy: IfNotPresent
          name: apicast-staging
          livenessProbe:
            httpGet:
              path: /status/live
              port: 8090
            initialDelaySeconds: 10
            timeoutSeconds: 5
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /status/ready
              port: 8090
            initialDelaySeconds: 15
            timeoutSeconds: 5
            periodSeconds: 30
          ports:
          - containerPort: 8080
            protocol: TCP
          - containerPort: 8090
            protocol: TCP
    triggers:
    - type: ConfigChange

- apiVersion: v1
  kind: Service
  metadata:
    name: apicast-staging
  spec:
    ports:
    - name: gateway
      port: 8080
      protocol: TCP
      targetPort: 8080
    - name: management
      port: 8090
      protocol: TCP
      targetPort: 8090
    selector:
      deploymentconfig: apicast-staging

- apiVersion: v1
  kind: DeploymentConfig
  metadata:
    name: apicast-production
  spec:
    replicas: 1
    selector:
      deploymentconfig: apicast-production
    strategy:
      rollingParams:
        intervalSeconds: 1
        maxSurge: 25%
        maxUnavailable: 25%
        timeoutSeconds: 1800
        updatePeriodSeconds: 1
      type: Rolling
    template:
      metadata:
        labels:
          deploymentconfig: apicast-production
      spec:
        containers:
        - env:
          - name: THREESCALE_PORTAL_ENDPOINT
            value: "http://${APICAST_ACCESS_TOKEN}@system-provider:3000"
          - name: APICAST_CONFIGURATION_LOADER
            value: "boot"
          - name: APICAST_CONFIGURATION_CACHE
            value: "300"
          - name: THREESCALE_DEPLOYMENT_ENV
            value: "production"
          - name: APICAST_MANAGEMENT_API
            value: "${APICAST_MANAGEMENT_API}"
          - name: BACKEND_ENDPOINT_OVERRIDE
            value: http://backend-listener:3000
          - name: OPENSSL_VERIFY
            value: '${APICAST_OPENSSL_VERIFY}'
          - name: APICAST_RESPONSE_CODES
            value: '${APICAST_RESPONSE_CODES}'
          - name: REDIS_URL
            value: "redis://system-redis:6379/1"
          image: 3scale-amp20/apicast-gateway:1.0-3
          imagePullPolicy: IfNotPresent
          name: apicast-production
          livenessProbe:
            httpGet:
              path: /status/live
              port: 8090
            initialDelaySeconds: 10
            timeoutSeconds: 5
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /status/ready
              port: 8090
            initialDelaySeconds: 15
            timeoutSeconds: 5
            periodSeconds: 30
          ports:
          - containerPort: 8080
            protocol: TCP
          - containerPort: 8090
            protocol: TCP
    triggers:
    - type: ConfigChange

- apiVersion: v1
  kind: Service
  metadata:
    name: apicast-production
  spec:
    ports:
    - name: gateway
      port: 8080
      protocol: TCP
      targetPort: 8080
    - name: management
      port: 8090
      protocol: TCP
      targetPort: 8090
    selector:
      deploymentconfig: apicast-production

- apiVersion: v1
  kind: Route
  metadata:
    name: api-apicast-staging-route
    labels:
      app: apicast-staging
  spec:
    host: api-${TENANT_NAME}-apicast-staging.${WILDCARD_DOMAIN}
    to:
      kind: Service
      name: apicast-staging
    port:
      targetPort: gateway
    tls:
      termination: edge
      insecureEdgeTerminationPolicy: Allow

- apiVersion: v1
  kind: Route
  metadata:
    name: api-apicast-production-route
    labels:
      app: apicast-production
  spec:
    host: api-${TENANT_NAME}-apicast-production.${WILDCARD_DOMAIN}
    to:
      kind: Service
      name: apicast-production
    port:
      targetPort: gateway
    tls:
      termination: edge
      insecureEdgeTerminationPolicy: Allow

- apiVersion: v1
  kind: DeploymentConfig
  metadata:
    name: system-app
  spec:
    replicas: 1
    selector:
      name: system-app
    strategy:
      rollingParams:
        intervalSeconds: 1
        maxSurge: 25%
        maxUnavailable: 25%
        timeoutSeconds: 600
        updatePeriodSeconds: 1
        pre:
          failurePolicy: Retry
          execNewPod:
            containerName: system-provider
            command:
            - bash
            - -c
            - bundle exec rake boot openshift:deploy
            env: *base_env
            volumes:
            - system-storage
        post:
          failurePolicy: Abort
          execNewPod:
            containerName: system-provider
            command:
            - bash
            - -c
            - bundle exec rake boot openshift:post_deploy
      type: Rolling
    template:
      metadata:
        labels:
          name: system-app
      spec:
        containers:
        - args:
          env: *base_env
          image: 3scale-amp20/system:1.0-2
          imagePullPolicy: IfNotPresent
          command: ['env', 'TENANT_MODE=provider', 'PORT=3000', 'container-entrypoint', 'bundle', 'exec', 'unicorn', '-c', 'config/unicorn.rb']
          name: system-provider
          livenessProbe:
            timeoutSeconds: 10
            initialDelaySeconds: 20
            tcpSocket:
              port: provider
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /check.txt
              port: provider
              scheme: HTTP
              httpHeaders:
              - name: X-Forwarded-Proto
                value: https
            initialDelaySeconds: 30
            timeoutSeconds: 10
            periodSeconds: 30
          ports:
          - containerPort: 3000
            protocol: TCP
            name: provider
          volumeMounts:
          - name: system-storage
            mountPath: /opt/system/public/system
        - args:
          env: *base_env
          image: 3scale-amp20/system:1.0-2
          command: ['env', 'TENANT_MODE=developer', 'PORT=3001', 'container-entrypoint', 'bundle', 'exec', 'unicorn', '-c', 'config/unicorn.rb']
          imagePullPolicy: IfNotPresent
          name: system-developer
          livenessProbe:
            timeoutSeconds: 10
            initialDelaySeconds: 20
            tcpSocket:
              port: developer
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /check.txt
              port: developer
              scheme: HTTP
              httpHeaders:
              - name: X-Forwarded-Proto
                value: https
            initialDelaySeconds: 30
            timeoutSeconds: 10
            periodSeconds: 30
          ports:
          - containerPort: 3001
            protocol: TCP
            name: developer
          volumeMounts:
          - name: system-storage
            mountPath: /opt/system/public/system
            readOnly: true
        volumes:
        - name: system-storage
          persistentVolumeClaim:
            claimName: system-storage
    triggers:
    - type: ConfigChange

- apiVersion: v1
  kind: DeploymentConfig
  metadata:
    name: system-resque
  spec:
    replicas: 1
    selector:
      name: system-resque
    strategy:
      rollingParams:
        intervalSeconds: 1
        maxSurge: 25%
        maxUnavailable: 25%
        timeoutSeconds: 600
        updatePeriodSeconds: 1
      type: Rolling
    template:
      metadata:
        labels:
          name: system-resque
      spec:
        containers:
        - args:
          - 'rake'
          - 'resque:work'
          - 'QUEUE=*'
          env: *base_env
          image: 3scale-amp20/system:1.0-2
          imagePullPolicy: IfNotPresent
          name: system-resque
          volumeMounts:
          - name: system-storage
            mountPath: /opt/system/public/system
        - args:
          - 'rake'
          - 'resque:scheduler'
          - 'QUEUE=*'
          env: *base_env
          image: 3scale-amp20/system:1.0-2
          imagePullPolicy: IfNotPresent
          name: system-scheduler
        volumes:
        - name: system-storage
          persistentVolumeClaim:
            claimName: system-storage
    triggers:
    - type: ConfigChange

- apiVersion: v1
  kind: DeploymentConfig
  metadata:
    name: system-sidekiq
  spec:
    replicas: 1
    selector:
      name: system-sidekiq
    strategy:
      rollingParams:
        intervalSeconds: 1
        maxSurge: 25%
        maxUnavailable: 25%
        timeoutSeconds: 600
        updatePeriodSeconds: 1
      type: Rolling
    template:
      metadata:
        labels:
          name: system-sidekiq
      spec:
        containers:
        - args:
          - rake
          - sidekiq:worker
          env: *base_env
          image: 3scale-amp20/system:1.0-2
          imagePullPolicy: IfNotPresent
          name: system-sidekiq
          volumeMounts:
          - name: system-storage
            mountPath: /opt/system/public/system
        volumes:
        - name: system-storage
          persistentVolumeClaim:
            claimName: system-storage
    triggers:
    - type: ConfigChange


- kind: DeploymentConfig
  apiVersion: v1
  metadata:
    name: 'system-mysql'
  spec:
    strategy:
      type: Recreate
    triggers:
    - type: ConfigChange
    replicas: 1
    selector:
      name: 'system-mysql'
    template:
      metadata:
        labels:
          name: 'system-mysql'
      spec:
        containers:
        - name: system-mysql
          image: ${MYSQL_IMAGE}
          ports:
          - containerPort: 3306
            protocol: TCP
          resources:
            limits:
              memory: 2Gi
            requests:
              cpu: '1'
              memory: 1Gi
          readinessProbe:
            timeoutSeconds: 5
            initialDelaySeconds: 10
            periodSeconds: 30
            exec:
              command:
              - /bin/sh
              - '-i'
              - '-c'
              - MYSQL_PWD="$MYSQL_PASSWORD" mysql -h 127.0.0.1 -u $MYSQL_USER -D $MYSQL_DATABASE -e 'SELECT 1'
          livenessProbe:
            initialDelaySeconds: 30
            periodSeconds: 10
            tcpSocket:
              port: 3306
          env:
          - name: MYSQL_USER
            value: ${MYSQL_USER}
          - name: MYSQL_PASSWORD
            value: ${MYSQL_PASSWORD}
          - name: MYSQL_DATABASE
            value: ${MYSQL_DATABASE}
          - name: MYSQL_ROOT_PASSWORD
            value: ${MYSQL_ROOT_PASSWORD}
          - name: MYSQL_LOWER_CASE_TABLE_NAMES
            value: "1"
          volumeMounts:
          - name: 'mysql-storage'
            mountPath: /var/lib/mysql/data
          imagePullPolicy: IfNotPresent
        volumes:
        - name: 'mysql-storage'
          persistentVolumeClaim:
            claimName: 'mysql-storage'
- kind: ConfigMap
  apiVersion: v1
  metadata:
    name: redis-config
  data:
    redis.conf: |
      protected-mode no

      port 6379

      timeout 0
      tcp-keepalive 300

      daemonize no
      supervised no

      loglevel notice

      databases 16

      save 900 1
      save 300 10
      save 60 10000

      stop-writes-on-bgsave-error yes

      rdbcompression yes
      rdbchecksum yes

      dbfilename dump.rdb

      slave-serve-stale-data yes
      slave-read-only yes

      repl-diskless-sync no
      repl-disable-tcp-nodelay no

      appendonly yes
      appendfilename "appendonly.aof"
      appendfsync everysec
      no-appendfsync-on-rewrite no
      auto-aof-rewrite-percentage 100
      auto-aof-rewrite-min-size 64mb
      aof-load-truncated yes

      lua-time-limit 5000

      activerehashing no

      aof-rewrite-incremental-fsync yes
      dir /var/lib/redis/data

- kind: ConfigMap

  apiVersion: v1
  metadata:
    name: smtp
  data:
    address: ""
    username: ""
    password: ""
    domain: ""
    port: ""
    authentication: ""
    openssl.verify.mode: ""

parameters:
- name: AMP_RELEASE
  description: "AMP release tag."
  value: 2.0.0-CR2-redhat-1
  required: true
- name: ADMIN_PASSWORD
  required: true
  generate: expression
  from: "[a-z0-9]{8}"
- name: ADMIN_USERNAME
  value: admin
  required: true
- name: APICAST_ACCESS_TOKEN
  required: true
  generate: expression
  from: "[a-z0-9]{8}"
  description: "Read Only Access Token that is APIcast going to use to download its configuration."
- name: ADMIN_ACCESS_TOKEN
  required: false
  generate: expression
  from: "[a-z0-9]{16}"
  description: "Admin Access Token with all scopes and write permissions for API access."
- name: WILDCARD_DOMAIN
  description: Root domain for the wildcard routes. Eg. example.com will generate 3scale-admin.example.com.
  required: true
- name: TENANT_NAME
  description: "Tenant name under the root that Admin UI will be available with -admin suffix."
  required: true
  value: "3scale"
- name: MYSQL_USER
  displayName: MySQL User
  description: Username for MySQL user that will be used for accessing the database.
  value: "mysql"
  required: true
- name: MYSQL_PASSWORD
  displayName: MySQL Password
  description: Password for the MySQL user.
  generate: expression
  from: "[a-z0-9]{8}"
  required: true
- name: MYSQL_DATABASE
  displayName: MySQL Database Name
  description: Name of the MySQL database accessed.
  value: "system"
  required: true
- name: MYSQL_ROOT_PASSWORD
  displayName: MySQL Root password.
  description: Password for Root user.
  generate: expression
  from: "[a-z0-9]{8}"
  required: true
- name: SYSTEM_BACKEND_USERNAME
  description: Internal 3scale API username for internal 3scale api auth.
  value: "3scale_api_user"
  required: true
- name: SYSTEM_BACKEND_PASSWORD
  description: Internal 3scale API password for internal 3scale api auth.
  generate: expression
  from: "[a-z0-9]{8}"
  required: true
- name: REDIS_IMAGE
  description: Redis image to use
  required: true
  value: rhscl/redis-32-rhel7:3.2-5.7
- name: MYSQL_IMAGE
  description: Mysql image to use
  required: true
  value: rhscl/mysql-56-rhel7:5.6-13.14
- name: SYSTEM_BACKEND_SHARED_SECRET
  description: Shared secret to import events from backend to system.
  generate: expression
  from: "[a-z0-9]{8}"
  required: true
- name: SYSTEM_APP_SECRET_KEY_BASE
  description: System application secret key base
  generate: expression
  from: "[a-f0-9]{128}"
  required: true
- name: APICAST_MANAGEMENT_API
  description: "Scope of the APIcast Management API. Can be disabled, status or debug. At least status required for health checks."
  required: false
  value: "status"
- name: APICAST_OPENSSL_VERIFY
  description: "Turn on/off the OpenSSL peer verification when downloading the configuration. Can be set to true/false."
  required: false
  value: "false"
- name: APICAST_RESPONSE_CODES
  description: "Enable logging response codes in APIcast."
  value: "true"
  required: false