2424import oracle .kubernetes .operator .utils .ParsedDomainCustomResourceYaml ;
2525import oracle .kubernetes .operator .utils .ParsedTraefikSecurityYaml ;
2626import 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 ;
2730import oracle .kubernetes .operator .utils .ParsedWeblogicDomainPersistentVolumeClaimYaml ;
2831import oracle .kubernetes .operator .utils .ParsedWeblogicDomainPersistentVolumeYaml ;
2932import oracle .kubernetes .weblogic .domain .v1 .Domain ;
@@ -83,6 +86,18 @@ protected ParsedApacheYaml getApacheYaml() {
8386 return getGeneratedFiles ().getApacheYaml ();
8487 }
8588
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+
86101 protected ParsedWeblogicDomainPersistentVolumeClaimYaml
87102 getWeblogicDomainPersistentVolumeClaimYaml () {
88103 return getGeneratedFiles ().getWeblogicDomainPersistentVolumeClaimYaml ();
@@ -489,6 +504,20 @@ protected V1ServiceAccount getExpectedTraefikServiceAccount() {
489504 .putLabelsItem (CLUSTERNAME_LABEL , getInputs ().getClusterName ()));
490505 }
491506
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+
492521 @ Test
493522 public void generatesCorrect_loadBalancerDeployment () throws Exception {
494523 assertThat (getActualTraefikDeployment (), yamlEqualTo (getExpectedTraefikDeployment ()));
@@ -660,6 +689,88 @@ protected ExtensionsV1beta1Deployment getExpectedTraefikDeployment() {
660689 .name (getTraefikScope () + "-cm" ))))));
661690 }
662691
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+
663774 @ Test
664775 public void generatesCorrect_loadBalancerConfigMap () throws Exception {
665776 // The config map contains a 'traefik.toml' property that has a lot of text
@@ -768,6 +879,29 @@ protected V1Service getExpectedTraefikService() {
768879 .nodePort (Integer .parseInt (getInputs ().getLoadBalancerWebPort ()))));
769880 }
770881
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+
771905 @ Test
772906 public void generatesCorrect_loadBalancerDashboardService () throws Exception {
773907 assertThat (
@@ -855,6 +989,97 @@ protected V1beta1ClusterRole getExpectedTraefikClusterRole() {
855989 .verbs (asList ("get" , "list" , "watch" )));
856990 }
857991
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+
8581083 @ Test
8591084 public void generatesCorrect_loadBalancerClusterRoleBinding () throws Exception {
8601085 assertThat (
@@ -876,10 +1101,10 @@ protected V1beta1ClusterRoleBinding getExpectedApacheClusterRoleBinding() {
8761101 .putLabelsItem (DOMAINNAME_LABEL , getInputs ().getDomainName ()))
8771102 .addSubjectsItem (
8781103 newSubject ()
879- .kind ("ServiceAccount" )
1104+ .kind (KIND_SERVICE_ACCOUNT )
8801105 .name (getApacheName ())
8811106 .namespace (getInputs ().getNamespace ()))
882- .roleRef (newRoleRef ().name (getApacheName ()).apiGroup ("rbac.authorization.k8s.io" ));
1107+ .roleRef (newRoleRef ().name (getApacheName ()).apiGroup (API_GROUP_RBAC ));
8831108 }
8841109
8851110 protected V1beta1ClusterRoleBinding getActualTraefikDashboardClusterRoleBinding () {
@@ -897,10 +1122,35 @@ protected V1beta1ClusterRoleBinding getExpectedTraefikDashboardClusterRoleBindin
8971122 .putLabelsItem (CLUSTERNAME_LABEL , getInputs ().getClusterName ()))
8981123 .addSubjectsItem (
8991124 newSubject ()
900- .kind ("ServiceAccount" )
1125+ .kind (KIND_SERVICE_ACCOUNT )
9011126 .name (getTraefikScope ())
9021127 .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 ()));
9041154 }
9051155
9061156 @ Test
@@ -981,4 +1231,12 @@ protected String getApacheName() {
9811231 protected String getApacheAppName () {
9821232 return "apache-webtier" ;
9831233 }
1234+
1235+ protected String getVoyagerName () {
1236+ return "voyager" ;
1237+ }
1238+
1239+ protected String getVoyagerOperatorName () {
1240+ return getVoyagerName () + "-operator" ;
1241+ }
9841242}
0 commit comments