-
Notifications
You must be signed in to change notification settings - Fork 160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
App version k8s revision #1143
App version k8s revision #1143
Conversation
rolling-update-kubernetes/src/main/scala/akka/rollingupdate/kubernetes/AppVersionRevision.scala
Outdated
Show resolved
Hide resolved
rolling-update-kubernetes/src/main/scala/akka/rollingupdate/kubernetes/KubernetesApiImpl.scala
Show resolved
Hide resolved
case Some(revision) => | ||
log.info(s"Reading revision from Kubernetes: $revision") | ||
revision | ||
case None => throw new ReadRevisionException(s"Not able to read revision from Kubernetes.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This log (and the one below) is currently needed to make the integration test work. The it test parses the pod logs with kubectl.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a reasonable info log regardless 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean, also adding an info
log when at this place when loop()
is None
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the info above, the exception will contain the details and go upstream.
...-update-kubernetes/src/test/scala/akka/rollingupdate/kubernetes/AppVersionRevisionSpec.scala
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking good
rolling-update-kubernetes/src/main/scala/akka/rollingupdate/kubernetes/AppVersionRevision.scala
Outdated
Show resolved
Hide resolved
rolling-update-kubernetes/src/main/scala/akka/rollingupdate/kubernetes/AppVersionRevision.scala
Outdated
Show resolved
Hide resolved
rolling-update-kubernetes/src/main/scala/akka/rollingupdate/kubernetes/KubernetesApiImpl.scala
Outdated
Show resolved
Hide resolved
} yield { | ||
owner | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this the same as
getPod().map(_.metadata.ownerReferences.headOption)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can it have more than one owner reference, should we instead try to find the one with the ReplicaSet naming convention?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the short version is better.
I have to read up under what circumstances a pod can have multiple ownerReferences.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we instead try to find the one with the ReplicaSet naming convention?
Yes, I will filter the ownerReferences
list to only look at items that are "kind": "ReplicaSet"
and take the headOption
of that filtered list (which should then only ever contain a single element after the filtering)
rolling-update-kubernetes/src/main/scala/akka/rollingupdate/kubernetes/AppVersionRevision.scala
Show resolved
Hide resolved
rolling-update-kubernetes/src/main/scala/akka/rollingupdate/kubernetes/AppVersionRevision.scala
Outdated
Show resolved
Hide resolved
rolling-update-kubernetes/src/main/scala/akka/rollingupdate/kubernetes/KubernetesApiImpl.scala
Outdated
Show resolved
Hide resolved
rolling-update-kubernetes/src/main/scala/akka/rollingupdate/kubernetes/KubernetesApiImpl.scala
Show resolved
Hide resolved
rolling-update-kubernetes/src/main/scala/akka/rollingupdate/kubernetes/KubernetesApiImpl.scala
Outdated
Show resolved
Hide resolved
rolling-update-kubernetes/src/main/scala/akka/rollingupdate/kubernetes/KubernetesApiImpl.scala
Outdated
Show resolved
Hide resolved
.../rollingupdate-kubernetes/src/main/scala/akka/cluster/bootstrap/PodDeletionCostDemoApp.scala
Outdated
Show resolved
Hide resolved
Java | ||
: @@snip [AppVersionRevisionCompileOnly.java](/rolling-update-kubernetes/src/test/java/jdoc/akka/rollingupdate/kubernetes/AppVersionRevisionCompileOnly.java) { #start } | ||
|
||
#### Configuration |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This section is totally copied from above, as it needs the the same params.
9f2c9d0
to
a9db0ce
Compare
<akka.version>2.7.0</akka.version> | ||
<akka.http.version>10.4.0</akka.http.version> | ||
<akka.version>2.8.1+2-edfacaa3-SNAPSHOT</akka.version> | ||
<akka.http.version>10.5.1</akka.http.version> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johanandren I missed this in your other pr, so bumping it here now.
@patriknw Should we have a ref to this feature from here https://doc.akka.io/docs/akka/current/additional/rolling-updates.html#cluster-sharding? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lookin good!
rolling-update-kubernetes/src/main/scala/akka/rollingupdate/kubernetes/AppVersionRevision.scala
Show resolved
Hide resolved
case Some(revision) => | ||
log.info(s"Reading revision from Kubernetes: $revision") | ||
revision | ||
case None => throw new ReadRevisionException(s"Not able to read revision from Kubernetes.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a reasonable info log regardless 👍
...-update-kubernetes/src/test/scala/akka/rollingupdate/kubernetes/AppVersionRevisionSpec.scala
Show resolved
Hide resolved
...-update-kubernetes/src/test/scala/akka/rollingupdate/kubernetes/AppVersionRevisionSpec.scala
Show resolved
Hide resolved
...-update-kubernetes/src/test/scala/akka/rollingupdate/kubernetes/AppVersionRevisionSpec.scala
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looking good, just something minor...
@@ -180,4 +180,68 @@ roleRef: | |||
apiGroup: rbac.authorization.k8s.io | |||
``` | |||
|
|||
## app-version from ReplicaSet revision |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of ReplicaSet I think we can say "Kubernetes Deployment"
Reason is that the user doesn't care about the ReplicaSet (might not even know what that is) but they define and apply the Deployment. That we read from the ReplicaSet is an implementation detail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem with that, but the new title app-version from Kubernetes Deployment revision
makes it overflow in the left-hand menu.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"app-version from Deployment revision" or "app-version from Deployment" ?
|
||
When using Cluster Sharding, it is [recommended](https://doc.akka.io/docs/akka/current/additional/rolling-updates.html#cluster-sharding) for rolling updates. This works well unless you use `kubectl rollout undo` which deploys the previous ReplicaSet configuration which contains the previous value for that config. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for rolling updates. This works well
I think we need something more between those sentences, such as "That means that you have to define an increasing app-version
configuration property for each roll out."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the whole config path akka.cluster.app-version
|
||
When using Cluster Sharding, it is [recommended](https://doc.akka.io/docs/akka/current/additional/rolling-updates.html#cluster-sharding) for rolling updates. This works well unless you use `kubectl rollout undo` which deploys the previous ReplicaSet configuration which contains the previous value for that config. | ||
|
||
To fix this, you can use `AppVersionRevision` to read the current `revision` from the ReplicaSet via the Kubernetes api which always increases, also during a rollback: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe spell out the full annotation name and mention that it is a built in annotation in Kubernetes
@@ -23,6 +23,8 @@ object PodDeletionCostDemoApp extends App { | |||
|
|||
AkkaManagement(system).start() | |||
ClusterBootstrap(system).start() | |||
|
|||
AppVersionRevision(system).start() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't be a problem in practise, but theoretically the AppVersionRevision should be started before ClusterBootstrap. Call to Cluster(system).setAppVersionLater
should be before joining.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine to me, if that works with the config-based loading of this extension.
134b392
to
57181f7
Compare
57181f7
to
2881e60
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, great work
Todo:
master
branch (as well as bump to scala 3.2.2)PodDeletionCostDemoApp.scala