24
24
import oracle .kubernetes .operator .utils .ParsedDomainCustomResourceYaml ;
25
25
import oracle .kubernetes .operator .utils .ParsedTraefikSecurityYaml ;
26
26
import oracle .kubernetes .operator .utils .ParsedTraefikYaml ;
27
+ import oracle .kubernetes .operator .utils .ParsedVoyagerIngressYaml ;
28
+ import oracle .kubernetes .operator .utils .ParsedVoyagerOperatorSecurityYaml ;
29
+ import oracle .kubernetes .operator .utils .ParsedVoyagerOperatorYaml ;
27
30
import oracle .kubernetes .operator .utils .ParsedWeblogicDomainPersistentVolumeClaimYaml ;
28
31
import oracle .kubernetes .operator .utils .ParsedWeblogicDomainPersistentVolumeYaml ;
29
32
import oracle .kubernetes .weblogic .domain .v1 .Domain ;
@@ -83,6 +86,18 @@ protected ParsedApacheYaml getApacheYaml() {
83
86
return getGeneratedFiles ().getApacheYaml ();
84
87
}
85
88
89
+ protected ParsedVoyagerIngressYaml getVoyagerIngressYaml () {
90
+ return getGeneratedFiles ().getVoyagerIngressYaml ();
91
+ }
92
+
93
+ protected ParsedVoyagerOperatorSecurityYaml getVoyagerOperatorSecurityYaml () {
94
+ return getGeneratedFiles ().getVoyagerOperatorSecurityYaml ();
95
+ }
96
+
97
+ protected ParsedVoyagerOperatorYaml getVoyagerOperatorYaml () {
98
+ return getGeneratedFiles ().getVoyagerOperatorYaml ();
99
+ }
100
+
86
101
protected ParsedWeblogicDomainPersistentVolumeClaimYaml
87
102
getWeblogicDomainPersistentVolumeClaimYaml () {
88
103
return getGeneratedFiles ().getWeblogicDomainPersistentVolumeClaimYaml ();
@@ -489,6 +504,20 @@ protected V1ServiceAccount getExpectedTraefikServiceAccount() {
489
504
.putLabelsItem (CLUSTERNAME_LABEL , getInputs ().getClusterName ()));
490
505
}
491
506
507
+ protected V1ServiceAccount getActualVoyagerServiceAccount () {
508
+ return getVoyagerOperatorSecurityYaml ().getVoyagerServiceAccount ();
509
+ }
510
+
511
+ protected V1ServiceAccount getExpectedVoyagerServiceAccount () {
512
+ return newServiceAccount ()
513
+ .metadata (
514
+ newObjectMeta ()
515
+ .name (getVoyagerOperatorName ())
516
+ .namespace (getVoyagerName ())
517
+ .putLabelsItem (RESOURCE_VERSION_LABEL , VOYAGER_LOAD_BALANCER_V1 )
518
+ .putLabelsItem (APP_LABEL , getVoyagerName ()));
519
+ }
520
+
492
521
@ Test
493
522
public void generatesCorrect_loadBalancerDeployment () throws Exception {
494
523
assertThat (getActualTraefikDeployment (), yamlEqualTo (getExpectedTraefikDeployment ()));
@@ -660,6 +689,88 @@ protected ExtensionsV1beta1Deployment getExpectedTraefikDeployment() {
660
689
.name (getTraefikScope () + "-cm" ))))));
661
690
}
662
691
692
+ protected ExtensionsV1beta1Deployment getActualVoyagerDeployment () {
693
+ return getVoyagerOperatorYaml ().getVoyagerOperatorDeployment ();
694
+ }
695
+
696
+ protected ExtensionsV1beta1Deployment getExpectedVoyagerDeployment () {
697
+ return newDeployment ()
698
+ .apiVersion (API_VERSION_APPS_V1BETA1 )
699
+ .metadata (
700
+ newObjectMeta ()
701
+ .name (getVoyagerOperatorName ())
702
+ .namespace (getVoyagerName ())
703
+ .putLabelsItem (RESOURCE_VERSION_LABEL , VOYAGER_LOAD_BALANCER_V1 )
704
+ .putLabelsItem (APP_LABEL , getVoyagerName ()))
705
+ .spec (
706
+ newDeploymentSpec ()
707
+ .replicas (1 )
708
+ .selector (newLabelSelector ().putMatchLabelsItem (APP_LABEL , getVoyagerName ()))
709
+ .template (
710
+ newPodTemplateSpec ()
711
+ .metadata (
712
+ newObjectMeta ()
713
+ .putLabelsItem (APP_LABEL , getVoyagerName ())
714
+ .putAnnotationsItem (
715
+ "scheduler.alpha.kubernetes.io/critical-pod" , "" ))
716
+ .spec (
717
+ newPodSpec ()
718
+ .serviceAccountName (getVoyagerOperatorName ())
719
+ .imagePullSecrets (newLocalObjectReferenceList ())
720
+ .addContainersItem (
721
+ newContainer ()
722
+ .name (getVoyagerName ())
723
+ .addArgsItem ("run" )
724
+ .addArgsItem ("--v=3" )
725
+ .addArgsItem ("--rbac=true" )
726
+ .addArgsItem ("--cloud-provider=" )
727
+ .addArgsItem ("--cloud-config=" )
728
+ .addArgsItem ("--ingress-class=" )
729
+ .addArgsItem ("--restrict-to-operator-namespace=false" )
730
+ .addArgsItem ("--docker-registry=appscode" )
731
+ .addArgsItem ("--haproxy-image-tag=1.7.10-6.0.0" )
732
+ .addArgsItem ("--secure-port=8443" )
733
+ .addArgsItem ("--audit-log-path=-" )
734
+ .addArgsItem ("--tls-cert-file=/var/serving-cert/tls.crt" )
735
+ .addArgsItem (
736
+ "--tls-private-key-file=/var/serving-cert/tls.key" )
737
+ .image ("appscode/voyager:6.0.0" )
738
+ .addPortsItem (newContainerPort ().containerPort (8443 ))
739
+ .addPortsItem (newContainerPort ().containerPort (56790 ))
740
+ .addPortsItem (newContainerPort ().containerPort (56791 ))
741
+ .addVolumeMountsItem (
742
+ newVolumeMount ()
743
+ .mountPath ("/etc/kubernetes" )
744
+ .name ("cloudconfig" )
745
+ .readOnly (true ))
746
+ .addVolumeMountsItem (
747
+ newVolumeMount ()
748
+ .mountPath ("/var/serving-cert" )
749
+ .name ("serving-cert" ))
750
+ .readinessProbe (
751
+ newProbe ()
752
+ .httpGet (
753
+ newHTTPGetAction ()
754
+ .path ("/healthz" )
755
+ .port (newIntOrString (8443 ))
756
+ .scheme ("HTTPS" ))))
757
+ .addVolumesItem (
758
+ newVolume ()
759
+ .hostPath (newHostPathVolumeSource ().path ("/etc/kubernetes" ))
760
+ .name ("cloudconfig" ))
761
+ .addVolumesItem (
762
+ newVolume ()
763
+ .name ("serving-cert" )
764
+ .secret (
765
+ newSecretVolumeSource ()
766
+ .defaultMode (420 )
767
+ .secretName (getVoyagerName () + "-apiserver-cert" )))
768
+ .addTolerationsItem (
769
+ newToleration ()
770
+ .key ("CriticalAddonsOnly" )
771
+ .operator ("Exists" )))));
772
+ }
773
+
663
774
@ Test
664
775
public void generatesCorrect_loadBalancerConfigMap () throws Exception {
665
776
// The config map contains a 'traefik.toml' property that has a lot of text
@@ -768,6 +879,29 @@ protected V1Service getExpectedTraefikService() {
768
879
.nodePort (Integer .parseInt (getInputs ().getLoadBalancerWebPort ()))));
769
880
}
770
881
882
+ protected V1Service getActualVoyagerService () {
883
+ return getVoyagerOperatorYaml ().getVoyagerOperatorService ();
884
+ }
885
+
886
+ protected V1Service getExpectedVoyagerService () {
887
+ return newService ()
888
+ .metadata (
889
+ newObjectMeta ()
890
+ .name (getVoyagerOperatorName ())
891
+ .namespace (getVoyagerName ())
892
+ .putLabelsItem (RESOURCE_VERSION_LABEL , VOYAGER_LOAD_BALANCER_V1 )
893
+ .putLabelsItem (APP_LABEL , getVoyagerName ()))
894
+ .spec (
895
+ newServiceSpec ()
896
+ .putSelectorItem (APP_LABEL , getVoyagerName ())
897
+ .addPortsItem (
898
+ newServicePort ().name ("admission" ).port (443 ).targetPort (newIntOrString (8443 )))
899
+ .addPortsItem (
900
+ newServicePort ().name ("ops" ).port (56790 ).targetPort (newIntOrString (56790 )))
901
+ .addPortsItem (
902
+ newServicePort ().name ("acme" ).port (56791 ).targetPort (newIntOrString (56791 ))));
903
+ }
904
+
771
905
@ Test
772
906
public void generatesCorrect_loadBalancerDashboardService () throws Exception {
773
907
assertThat (
@@ -855,6 +989,97 @@ protected V1beta1ClusterRole getExpectedTraefikClusterRole() {
855
989
.verbs (asList ("get" , "list" , "watch" )));
856
990
}
857
991
992
+ protected V1beta1ClusterRole getActualVoyagerClusterRole () {
993
+ return getVoyagerOperatorSecurityYaml ().getVoyagerClusterRole ();
994
+ }
995
+
996
+ protected V1beta1ClusterRole getExpectedVoyagerClusterRole () {
997
+ return newClusterRole ()
998
+ .apiVersion (API_VERSION_RBAC_V1 )
999
+ .metadata (
1000
+ newObjectMeta ()
1001
+ .name (getVoyagerOperatorName ())
1002
+ .namespace (getVoyagerName ())
1003
+ .putLabelsItem (RESOURCE_VERSION_LABEL , VOYAGER_LOAD_BALANCER_V1 )
1004
+ .putLabelsItem (APP_LABEL , getVoyagerName ()))
1005
+ .addRulesItem (
1006
+ newPolicyRule ()
1007
+ .addApiGroupsItem ("apiextensions.k8s.io" )
1008
+ .addResourcesItem ("customresourcedefinitions" )
1009
+ .addVerbsItem ("*" ))
1010
+ .addRulesItem (
1011
+ newPolicyRule ()
1012
+ .addApiGroupsItem ("extensions" )
1013
+ .addResourcesItem ("thirdpartyresources" )
1014
+ .addVerbsItem ("*" ))
1015
+ .addRulesItem (
1016
+ newPolicyRule ()
1017
+ .addApiGroupsItem ("voyager.appscode.com" )
1018
+ .resources (asList ("*" ))
1019
+ .verbs (asList ("*" )))
1020
+ .addRulesItem (
1021
+ newPolicyRule ()
1022
+ .addApiGroupsItem ("monitoring.coreos.com" )
1023
+ .addResourcesItem ("servicemonitors" )
1024
+ .verbs (asList ("get" , "list" , "watch" , "create" , "update" , "patch" )))
1025
+ .addRulesItem (
1026
+ newPolicyRule ()
1027
+ .addApiGroupsItem ("apps" )
1028
+ .addResourcesItem ("deployments" )
1029
+ .verbs (asList ("*" )))
1030
+ .addRulesItem (
1031
+ newPolicyRule ()
1032
+ .addApiGroupsItem ("extensions" )
1033
+ .addResourcesItem ("deployments" )
1034
+ .addResourcesItem ("daemonsets" )
1035
+ .addResourcesItem ("ingresses" )
1036
+ .verbs (asList ("*" )))
1037
+ .addRulesItem (
1038
+ newPolicyRule ()
1039
+ .apiGroups (asList ("" ))
1040
+ .addResourcesItem ("replicationcontrollers" )
1041
+ .addResourcesItem ("services" )
1042
+ .addResourcesItem ("endpoints" )
1043
+ .addResourcesItem ("configmaps" )
1044
+ .verbs (asList ("*" )))
1045
+ .addRulesItem (
1046
+ newPolicyRule ()
1047
+ .apiGroups (asList ("" ))
1048
+ .addResourcesItem ("secrets" )
1049
+ .verbs (asList ("get" , "list" , "watch" , "create" , "update" , "patch" )))
1050
+ .addRulesItem (
1051
+ newPolicyRule ()
1052
+ .apiGroups (asList ("" ))
1053
+ .addResourcesItem ("namespaces" )
1054
+ .verbs (asList ("get" , "list" , "watch" )))
1055
+ .addRulesItem (
1056
+ newPolicyRule ()
1057
+ .apiGroups (asList ("" ))
1058
+ .addResourcesItem ("events" )
1059
+ .verbs (asList ("create" )))
1060
+ .addRulesItem (
1061
+ newPolicyRule ()
1062
+ .apiGroups (asList ("" ))
1063
+ .addResourcesItem ("pods" )
1064
+ .verbs (asList ("list" , "watch" , "delete" , "deletecollection" )))
1065
+ .addRulesItem (
1066
+ newPolicyRule ()
1067
+ .apiGroups (asList ("" ))
1068
+ .addResourcesItem ("nodes" )
1069
+ .verbs (asList ("list" , "watch" , "get" )))
1070
+ .addRulesItem (
1071
+ newPolicyRule ()
1072
+ .apiGroups (asList ("" ))
1073
+ .addResourcesItem ("serviceaccounts" )
1074
+ .verbs (asList ("get" , "create" , "delete" , "patch" )))
1075
+ .addRulesItem (
1076
+ newPolicyRule ()
1077
+ .addApiGroupsItem (API_GROUP_RBAC )
1078
+ .addResourcesItem ("rolebindings" )
1079
+ .addResourcesItem ("roles" )
1080
+ .verbs (asList ("get" , "create" , "delete" , "patch" )));
1081
+ }
1082
+
858
1083
@ Test
859
1084
public void generatesCorrect_loadBalancerClusterRoleBinding () throws Exception {
860
1085
assertThat (
@@ -876,10 +1101,10 @@ protected V1beta1ClusterRoleBinding getExpectedApacheClusterRoleBinding() {
876
1101
.putLabelsItem (DOMAINNAME_LABEL , getInputs ().getDomainName ()))
877
1102
.addSubjectsItem (
878
1103
newSubject ()
879
- .kind ("ServiceAccount" )
1104
+ .kind (KIND_SERVICE_ACCOUNT )
880
1105
.name (getApacheName ())
881
1106
.namespace (getInputs ().getNamespace ()))
882
- .roleRef (newRoleRef ().name (getApacheName ()).apiGroup ("rbac.authorization.k8s.io" ));
1107
+ .roleRef (newRoleRef ().name (getApacheName ()).apiGroup (API_GROUP_RBAC ));
883
1108
}
884
1109
885
1110
protected V1beta1ClusterRoleBinding getActualTraefikDashboardClusterRoleBinding () {
@@ -897,10 +1122,35 @@ protected V1beta1ClusterRoleBinding getExpectedTraefikDashboardClusterRoleBindin
897
1122
.putLabelsItem (CLUSTERNAME_LABEL , getInputs ().getClusterName ()))
898
1123
.addSubjectsItem (
899
1124
newSubject ()
900
- .kind ("ServiceAccount" )
1125
+ .kind (KIND_SERVICE_ACCOUNT )
901
1126
.name (getTraefikScope ())
902
1127
.namespace (getInputs ().getNamespace ()))
903
- .roleRef (newRoleRef ().name (getTraefikScope ()).apiGroup ("rbac.authorization.k8s.io" ));
1128
+ .roleRef (newRoleRef ().name (getTraefikScope ()).apiGroup (API_GROUP_RBAC ));
1129
+ }
1130
+
1131
+ protected V1beta1ClusterRoleBinding getActualVoyagerClusterRoleBinding () {
1132
+ return getVoyagerOperatorSecurityYaml ().getVoyagerClusterRoleBinding ();
1133
+ }
1134
+
1135
+ protected V1beta1ClusterRoleBinding getExpectedVoyagerClusterRoleBinding () {
1136
+ return newClusterRoleBinding ()
1137
+ .apiVersion (API_VERSION_RBAC_V1 )
1138
+ .metadata (
1139
+ newObjectMeta ()
1140
+ .name (getVoyagerOperatorName ())
1141
+ .namespace (getVoyagerName ())
1142
+ .putLabelsItem (RESOURCE_VERSION_LABEL , VOYAGER_LOAD_BALANCER_V1 )
1143
+ .putLabelsItem (APP_LABEL , getVoyagerName ()))
1144
+ .roleRef (
1145
+ newRoleRef ()
1146
+ .apiGroup (API_GROUP_RBAC )
1147
+ .kind (KIND_CLUSTER_ROLE )
1148
+ .name (getVoyagerOperatorName ()))
1149
+ .addSubjectsItem (
1150
+ newSubject ()
1151
+ .kind (KIND_SERVICE_ACCOUNT )
1152
+ .name (getVoyagerOperatorName ())
1153
+ .namespace (getVoyagerName ()));
904
1154
}
905
1155
906
1156
@ Test
@@ -981,4 +1231,12 @@ protected String getApacheName() {
981
1231
protected String getApacheAppName () {
982
1232
return "apache-webtier" ;
983
1233
}
1234
+
1235
+ protected String getVoyagerName () {
1236
+ return "voyager" ;
1237
+ }
1238
+
1239
+ protected String getVoyagerOperatorName () {
1240
+ return getVoyagerName () + "-operator" ;
1241
+ }
984
1242
}
0 commit comments