Skip to content
This repository was archived by the owner on May 25, 2023. It is now read-only.

Commit 158b0a7

Browse files
authored
Merge pull request #184 from eed3si9n/wip/akka.discovery
Switch from akka.discovery.method
2 parents ef00afd + 3fd8c1b commit 158b0a7

File tree

4 files changed

+323
-3
lines changed

4 files changed

+323
-3
lines changed

cli/shared/src/main/scala/com/lightbend/rp/reactivecli/runtime/kubernetes/PodTemplate.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ object PodTemplate {
7878
Map(
7979
"RP_JAVA_OPTS" -> LiteralEnvironmentVariable(
8080
Seq(
81-
s"-Dakka.discovery.method=kubernetes-api",
81+
s"-Dakka.management.cluster.bootstrap.contact-point-discovery.discovery-method=kubernetes-api",
8282
s"-Dakka.management.cluster.bootstrap.contact-point-discovery.effective-name=$serviceResourceName",
8383
s"-Dakka.management.cluster.bootstrap.contact-point-discovery.required-contact-point-nr=$noOfReplicas",
8484
akkaClusterBootstrapSystemName.fold("-Dakka.discovery.kubernetes-api.pod-label-selector=appName=%s")(systemName => s"-Dakka.discovery.kubernetes-api.pod-label-selector=actorSystemName=$systemName"),

cli/shared/src/main/scala/com/lightbend/rp/reactivecli/runtime/marathon/RpEnvironmentVariables.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ object RpEnvironmentVariables {
5757
else
5858
Map(
5959
"RP_JAVA_OPTS" -> Seq(
60-
s"-Dakka.discovery.method=marathon-api",
60+
s"-Dakka.management.cluster.bootstrap.contact-point-discovery.discovery-method=marathon-api",
6161
s"-Dakka.management.cluster.bootstrap.contact-point-discovery.effective-name=$serviceResourceName",
6262
s"-Dakka.management.cluster.bootstrap.contact-point-discovery.required-contact-point-nr=$noOfReplicas",
6363
akkaClusterBootstrapSystemName.fold("-Dakka.discovery.marathon-api.app-label-query=APP_NAME==%s")(systemName => s"-Dakka.discovery.marathon-api.app-label-query=ACTOR_SYSTEM_NAME==$systemName"),

cli/shared/src/test/scala/com/lightbend/rp/reactivecli/runtime/kubernetes/DeploymentJsonTest.scala

Lines changed: 320 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,326 @@ object DeploymentJsonTest extends TestSuite {
398398
}
399399
assert(result == Deployment("friendimpl-v3-2-1-snapshot", expectedJson, JsonTransform.noop))
400400
}
401+
402+
"should generate application health check given status module" - {
403+
val expectedJson =
404+
"""
405+
|{
406+
| "apiVersion": "apps/v1beta2",
407+
| "kind": "Deployment",
408+
| "metadata": {
409+
| "name": "friendimpl-v3-2-1-snapshot",
410+
| "labels": {
411+
| "appName": "friendimpl",
412+
| "appNameVersion": "friendimpl-v3-2-1-snapshot"
413+
| },
414+
| "namespace": "chirper"
415+
| },
416+
| "spec": {
417+
| "replicas": 1,
418+
| "selector": {
419+
| "matchLabels": {
420+
| "appNameVersion": "friendimpl-v3-2-1-snapshot"
421+
| }
422+
| },
423+
| "template": {
424+
| "metadata": {
425+
| "labels": {
426+
| "appName": "friendimpl",
427+
| "appNameVersion": "friendimpl-v3-2-1-snapshot"
428+
| },
429+
| "annotations": {
430+
| "annotationKey0": "annotationValue0",
431+
| "annotationKey1": "annotationValue1"
432+
| }
433+
| },
434+
| "spec": {
435+
| "restartPolicy": "Always",
436+
| "containers": [
437+
| {
438+
| "readinessProbe": {
439+
| "httpGet": {
440+
| "path": "/platform-tooling/ready",
441+
| "port": "akka-mgmt-http"
442+
| },
443+
| "periodSeconds": 10
444+
| },
445+
| "name": "friendimpl",
446+
| "livenessProbe": {
447+
| "httpGet": {
448+
| "path": "/platform-tooling/healthy",
449+
| "port": "akka-mgmt-http"
450+
| },
451+
| "periodSeconds": 10,
452+
| "initialDelaySeconds": 60
453+
| },
454+
| "image": "my-repo/my-image",
455+
| "ports": [
456+
| {
457+
| "containerPort": 10000,
458+
| "name": "ep1"
459+
| },
460+
| {
461+
| "containerPort": 1234,
462+
| "name": "ep2"
463+
| },
464+
| {
465+
| "containerPort": 10001,
466+
| "name": "ep3"
467+
| }
468+
| ],
469+
| "resources": {
470+
| "limits": {
471+
| "cpu": 0.5,
472+
| "memory": 8192
473+
| },
474+
| "requests": {
475+
| "cpu": 0.5,
476+
| "memory": 8192
477+
| }
478+
| },
479+
| "imagePullPolicy": "Never",
480+
| "volumeMounts": [
481+
| {
482+
| "mountPath": "/rp/secrets/acme-co",
483+
| "name": "secret-acme-co"
484+
| }
485+
| ],
486+
| "env": [
487+
| {
488+
| "name": "RP_APP_NAME",
489+
| "value": "friendimpl"
490+
| },
491+
| {
492+
| "name": "RP_APP_TYPE",
493+
| "value": "basic"
494+
| },
495+
| {
496+
| "name": "RP_APP_VERSION",
497+
| "value": "3.2.1-SNAPSHOT"
498+
| },
499+
| {
500+
| "name": "RP_DYN_JAVA_OPTS",
501+
| "value": "-Dakka.discovery.kubernetes-api.pod-namespace=$RP_NAMESPACE"
502+
| },
503+
| {
504+
| "name": "RP_ENDPOINTS",
505+
| "value": "EP1,EP2,EP3"
506+
| },
507+
| {
508+
| "name": "RP_ENDPOINTS_COUNT",
509+
| "value": "3"
510+
| },
511+
| {
512+
| "name": "RP_ENDPOINT_0_BIND_HOST",
513+
| "valueFrom": {
514+
| "fieldRef": {
515+
| "fieldPath": "status.podIP"
516+
| }
517+
| }
518+
| },
519+
| {
520+
| "name": "RP_ENDPOINT_0_BIND_PORT",
521+
| "value": "10000"
522+
| },
523+
| {
524+
| "name": "RP_ENDPOINT_0_HOST",
525+
| "valueFrom": {
526+
| "fieldRef": {
527+
| "fieldPath": "status.podIP"
528+
| }
529+
| }
530+
| },
531+
| {
532+
| "name": "RP_ENDPOINT_0_PORT",
533+
| "value": "10000"
534+
| },
535+
| {
536+
| "name": "RP_ENDPOINT_1_BIND_HOST",
537+
| "valueFrom": {
538+
| "fieldRef": {
539+
| "fieldPath": "status.podIP"
540+
| }
541+
| }
542+
| },
543+
| {
544+
| "name": "RP_ENDPOINT_1_BIND_PORT",
545+
| "value": "1234"
546+
| },
547+
| {
548+
| "name": "RP_ENDPOINT_1_HOST",
549+
| "valueFrom": {
550+
| "fieldRef": {
551+
| "fieldPath": "status.podIP"
552+
| }
553+
| }
554+
| },
555+
| {
556+
| "name": "RP_ENDPOINT_1_PORT",
557+
| "value": "1234"
558+
| },
559+
| {
560+
| "name": "RP_ENDPOINT_2_BIND_HOST",
561+
| "valueFrom": {
562+
| "fieldRef": {
563+
| "fieldPath": "status.podIP"
564+
| }
565+
| }
566+
| },
567+
| {
568+
| "name": "RP_ENDPOINT_2_BIND_PORT",
569+
| "value": "10001"
570+
| },
571+
| {
572+
| "name": "RP_ENDPOINT_2_HOST",
573+
| "valueFrom": {
574+
| "fieldRef": {
575+
| "fieldPath": "status.podIP"
576+
| }
577+
| }
578+
| },
579+
| {
580+
| "name": "RP_ENDPOINT_2_PORT",
581+
| "value": "10001"
582+
| },
583+
| {
584+
| "name": "RP_ENDPOINT_EP1_BIND_HOST",
585+
| "valueFrom": {
586+
| "fieldRef": {
587+
| "fieldPath": "status.podIP"
588+
| }
589+
| }
590+
| },
591+
| {
592+
| "name": "RP_ENDPOINT_EP1_BIND_PORT",
593+
| "value": "10000"
594+
| },
595+
| {
596+
| "name": "RP_ENDPOINT_EP1_HOST",
597+
| "valueFrom": {
598+
| "fieldRef": {
599+
| "fieldPath": "status.podIP"
600+
| }
601+
| }
602+
| },
603+
| {
604+
| "name": "RP_ENDPOINT_EP1_PORT",
605+
| "value": "10000"
606+
| },
607+
| {
608+
| "name": "RP_ENDPOINT_EP2_BIND_HOST",
609+
| "valueFrom": {
610+
| "fieldRef": {
611+
| "fieldPath": "status.podIP"
612+
| }
613+
| }
614+
| },
615+
| {
616+
| "name": "RP_ENDPOINT_EP2_BIND_PORT",
617+
| "value": "1234"
618+
| },
619+
| {
620+
| "name": "RP_ENDPOINT_EP2_HOST",
621+
| "valueFrom": {
622+
| "fieldRef": {
623+
| "fieldPath": "status.podIP"
624+
| }
625+
| }
626+
| },
627+
| {
628+
| "name": "RP_ENDPOINT_EP2_PORT",
629+
| "value": "1234"
630+
| },
631+
| {
632+
| "name": "RP_ENDPOINT_EP3_BIND_HOST",
633+
| "valueFrom": {
634+
| "fieldRef": {
635+
| "fieldPath": "status.podIP"
636+
| }
637+
| }
638+
| },
639+
| {
640+
| "name": "RP_ENDPOINT_EP3_BIND_PORT",
641+
| "value": "10001"
642+
| },
643+
| {
644+
| "name": "RP_ENDPOINT_EP3_HOST",
645+
| "valueFrom": {
646+
| "fieldRef": {
647+
| "fieldPath": "status.podIP"
648+
| }
649+
| }
650+
| },
651+
| {
652+
| "name": "RP_ENDPOINT_EP3_PORT",
653+
| "value": "10001"
654+
| },
655+
| {
656+
| "name": "RP_JAVA_OPTS",
657+
| "value": "-Dconfig.resource=my-config.conf -Dakka.management.cluster.bootstrap.contact-point-discovery.discovery-method=kubernetes-api -Dakka.management.cluster.bootstrap.contact-point-discovery.effective-name=friendimpl -Dakka.management.cluster.bootstrap.contact-point-discovery.required-contact-point-nr=1 -Dakka.discovery.kubernetes-api.pod-label-selector=appName=%s"
658+
| },
659+
| {
660+
| "name": "RP_KUBERNETES_POD_IP",
661+
| "valueFrom": {
662+
| "fieldRef": {
663+
| "fieldPath": "status.podIP"
664+
| }
665+
| }
666+
| },
667+
| {
668+
| "name": "RP_KUBERNETES_POD_NAME",
669+
| "valueFrom": {
670+
| "fieldRef": {
671+
| "fieldPath": "metadata.name"
672+
| }
673+
| }
674+
| },
675+
| {
676+
| "name": "RP_MODULES",
677+
| "value": "akka-cluster-bootstrapping,akka-management,status"
678+
| },
679+
| {
680+
| "name": "RP_NAMESPACE",
681+
| "valueFrom": {
682+
| "fieldRef": {
683+
| "fieldPath": "metadata.namespace"
684+
| }
685+
| }
686+
| },
687+
| {
688+
| "name": "RP_PLATFORM",
689+
| "value": "kubernetes"
690+
| },
691+
| {
692+
| "name": "testing1",
693+
| "value": "testingvalue1"
694+
| }
695+
| ]
696+
| }
697+
| ],
698+
| "volumes": [
699+
| {
700+
| "name": "secret-acme-co",
701+
| "secret": {
702+
| "secretName": "acme.co"
703+
| }
704+
| }
705+
| ]
706+
| }
707+
| }
708+
| }
709+
|}
710+
""".stripMargin.parse.right.get
711+
val result = Deployment.generate(annotations.copy(
712+
modules = Set("akka-management", "status", "akka-cluster-bootstrapping")
713+
), "apps/v1beta2", None, imageName,
714+
PodTemplate.ImagePullPolicy.Never, PodTemplate.RestartPolicy.Default, noOfReplicas = 1, Map.empty, CanaryDeploymentType, JsonTransform.noop, false).toOption.get
715+
if (result.json != expectedJson) {
716+
println(s"deployment K8 JSON:\n" + PrettyParams.spaces2.copy(colonLeft = "").pretty(result.json))
717+
}
718+
assert(result == Deployment("friendimpl-v3-2-1-snapshot", expectedJson, JsonTransform.noop))
719+
}
720+
401721
"should fail if application name is not defined" - {
402722
val invalid = annotations.copy(appName = None)
403723
assert(Deployment.generate(invalid, "apps/v1beta2", None, imageName, PodTemplate.ImagePullPolicy.Never, PodTemplate.RestartPolicy.Default, 1, Map.empty, CanaryDeploymentType, JsonTransform.noop, false).toOption.isEmpty)

cli/shared/src/test/scala/com/lightbend/rp/reactivecli/runtime/marathon/RpEnvironmentVariablesTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ object RpEnvironmentVariablesTest extends TestSuite {
109109
Map(
110110
"RP_ENDPOINT_0_BIND_PORT" -> "$PORT_EP",
111111
"RP_ENDPOINTS" -> "EP1", "RP_APP_VERSION" -> "3.2.1-SNAPSHOT",
112-
"RP_JAVA_OPTS" -> "-Dakka.discovery.method=marathon-api -Dakka.management.cluster.bootstrap.contact-point-discovery.effective-name=friendimpl -Dakka.management.cluster.bootstrap.contact-point-discovery.required-contact-point-nr=3 -Dakka.discovery.marathon-api.app-label-query=APP_NAME==%s",
112+
"RP_JAVA_OPTS" -> "-Dakka.management.cluster.bootstrap.contact-point-discovery.discovery-method=marathon-api -Dakka.management.cluster.bootstrap.contact-point-discovery.effective-name=friendimpl -Dakka.management.cluster.bootstrap.contact-point-discovery.required-contact-point-nr=3 -Dakka.discovery.marathon-api.app-label-query=APP_NAME==%s",
113113
"RP_PLATFORM" -> "mesos",
114114
"RP_ENDPOINT_EP1_PORT" -> "$PORT_EP",
115115
"RP_MODULES" -> "akka-cluster-bootstrapping",

0 commit comments

Comments
 (0)