You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pekko.apache.org by fa...@apache.org on 2022/10/31 09:34:35 UTC

[incubator-pekko-samples] branch edc/clusteroperator created (now d921195)

This is an automated email from the ASF dual-hosted git repository.

fanningpj pushed a change to branch edc/clusteroperator
in repository https://gitbox.apache.org/repos/asf/incubator-pekko-samples.git


      at d921195  operatorize

This branch includes the following new commits:

     new d921195  operatorize

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pekko.apache.org
For additional commands, e-mail: commits-help@pekko.apache.org


[incubator-pekko-samples] 01/01: operatorize

Posted by fa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

fanningpj pushed a commit to branch edc/clusteroperator
in repository https://gitbox.apache.org/repos/asf/incubator-pekko-samples.git

commit d921195309bd2f665273cf3d4103af2ebe2b6827
Author: EdC <ed...@lightbend.com>
AuthorDate: Tue May 28 17:07:49 2019 -0700

    operatorize
---
 akka-sample-cluster-scala/.gitignore               |  1 +
 akka-sample-cluster-scala/build.sbt                | 17 ++++++++++++++
 .../kubernetes/akka-cluster.yml                    | 22 ++++++++++++++++++
 akka-sample-cluster-scala/project/plugins.sbt      |  1 +
 .../src/main/resources/application.conf            | 26 +++++++++-------------
 5 files changed, 51 insertions(+), 16 deletions(-)

diff --git a/akka-sample-cluster-scala/.gitignore b/akka-sample-cluster-scala/.gitignore
index 660c959..55b21e3 100644
--- a/akka-sample-cluster-scala/.gitignore
+++ b/akka-sample-cluster-scala/.gitignore
@@ -13,5 +13,6 @@ target/
 /logs
 .cache
 .classpath
+.metals
 .project
 .settings
\ No newline at end of file
diff --git a/akka-sample-cluster-scala/build.sbt b/akka-sample-cluster-scala/build.sbt
index fac7470..9ca8ff9 100644
--- a/akka-sample-cluster-scala/build.sbt
+++ b/akka-sample-cluster-scala/build.sbt
@@ -1,12 +1,16 @@
+import com.typesafe.sbt.packager.docker.{Cmd, ExecCmd}
+import com.typesafe.sbt.packager.docker.DockerPlugin.autoImport._
 import com.typesafe.sbt.SbtMultiJvm.multiJvmSettings
 import com.typesafe.sbt.SbtMultiJvm.MultiJvmKeys.MultiJvm
 
 val akkaVersion = "2.5.22"
+enablePlugins(JavaAppPackaging, DockerPlugin)
 
 lazy val `akka-sample-cluster-scala` = project
   .in(file("."))
   .settings(multiJvmSettings: _*)
   .settings(
+    version := "0.1.0-SNAPSHOT",
     organization := "com.typesafe.akka.samples",
     scalaVersion := "2.12.8",
     scalacOptions in Compile ++= Seq("-deprecation", "-feature", "-unchecked", "-Xlog-reflective-calls", "-Xlint"),
@@ -21,6 +25,19 @@ lazy val `akka-sample-cluster-scala` = project
       "com.typesafe.akka" %% "akka-multi-node-testkit" % akkaVersion,
       "org.scalatest" %% "scalatest" % "3.0.7" % Test,
       "io.kamon" % "sigar-loader" % "1.6.6-rev002"),
+      // Based on best practices found in OpenShift Creating images guidelines
+      // https://docs.openshift.com/container-platform/3.10/creating_images/guidelines.html
+      dockerRepository := Some("lightbend-docker-registry.bintray.io/simple-cluster-app"),
+      dockerCommands := Seq(
+        Cmd("FROM",           "centos:7"),
+        Cmd("RUN",            "yum -y install java-1.8.0-openjdk-headless && yum clean all -y"),
+        Cmd("RUN",            "useradd -r -m -u 1001 -g 0 simpleclusterapp"),
+        Cmd("ADD",            "opt /opt"),
+        Cmd("RUN",            "chgrp -R 0 /opt && chmod -R g=u /opt"),
+        Cmd("WORKDIR",        "/opt/docker"),
+        Cmd("USER",           "1001"),
+        ExecCmd("CMD",        "/opt/docker/bin/simple-cluster-app", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseCGroupMemoryLimitForHeap"),
+      ),
     fork in run := true,
     mainClass in (Compile, run) := Some("sample.cluster.simple.SimpleClusterApp"),
     // disable parallel tests
diff --git a/akka-sample-cluster-scala/kubernetes/akka-cluster.yml b/akka-sample-cluster-scala/kubernetes/akka-cluster.yml
new file mode 100644
index 0000000..8e05020
--- /dev/null
+++ b/akka-sample-cluster-scala/kubernetes/akka-cluster.yml
@@ -0,0 +1,22 @@
+apiVersion: app.lightbend.com/v1alpha1
+kind: AkkaCluster
+metadata:
+  name: simple-cluster-app
+spec:
+  replicas: 3
+  template:
+    spec:
+      containers:
+      - name: main
+        image: lightbend-docker-registry.bintray.io/simple-cluster-app/akka-sample-cluster-scala:0.1.0-SNAPSHOT
+        imagePullPolicy: Always
+        livenessProbe:
+          tcpSocket:
+            port: 8558
+        ports:
+        - name: http
+          containerPort: 8080
+        - name: remoting
+          containerPort: 2552
+        - name: management
+          containerPort: 8558
\ No newline at end of file
diff --git a/akka-sample-cluster-scala/project/plugins.sbt b/akka-sample-cluster-scala/project/plugins.sbt
index 2d02635..b5825ad 100644
--- a/akka-sample-cluster-scala/project/plugins.sbt
+++ b/akka-sample-cluster-scala/project/plugins.sbt
@@ -1,2 +1,3 @@
 addSbtPlugin("com.typesafe.sbt" % "sbt-multi-jvm" % "0.4.0")
 addSbtPlugin("com.dwijnand" % "sbt-dynver" % "3.0.0")
+addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.14")
diff --git a/akka-sample-cluster-scala/src/main/resources/application.conf b/akka-sample-cluster-scala/src/main/resources/application.conf
index ba4f129..e6ed99f 100644
--- a/akka-sample-cluster-scala/src/main/resources/application.conf
+++ b/akka-sample-cluster-scala/src/main/resources/application.conf
@@ -1,13 +1,8 @@
 akka {
   actor {
-    provider = cluster
+    provider = "cluster"
   }
   remote {
-    netty.tcp {
-      hostname = "127.0.0.1"
-      port = 0
-    }
-
     artery {
       # change this to enabled=on to use Artery instead of netty
       # see https://doc.akka.io/docs/akka/current/remoting-artery.html
@@ -17,16 +12,6 @@ akka {
       canonical.port = 0
     }
   }
-
-  cluster {
-    seed-nodes = [
-      "akka.tcp://ClusterSystem@127.0.0.1:2551",
-      "akka.tcp://ClusterSystem@127.0.0.1:2552"]
-
-    # auto downing is NOT safe for production deployments.
-    # you may want to use it during development, read more about it in the docs.
-    auto-down-unreachable-after = 10s
-  }
 }
 
 # Enable metrics extension in akka-cluster-metrics.
@@ -35,3 +20,12 @@ akka.extensions=["akka.cluster.metrics.ClusterMetricsExtension"]
 # Sigar native library extract location during tests.
 # Note: use per-jvm-instance folder when running multiple jvm on one host.
 akka.cluster.metrics.native-library-extract-folder=${user.dir}/target/native
+
+akka.management {
+  cluster.bootstrap {
+    contact-point-discovery {
+      # service-name = ${?AKKA_CLUSTER_BOOTSTRAP_SERVICE_NAME}
+      discovery-method = kubernetes-api
+    }
+  }
+}
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pekko.apache.org
For additional commands, e-mail: commits-help@pekko.apache.org