-
Notifications
You must be signed in to change notification settings - Fork 771
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
Add deploy: mode: global support #771
Conversation
@cdrage, thank you for the pull request! We'll request some people to review your PR. @surajnarwade and @procrypt, please review this. |
documentation of mode says |
@surajnarwade nope, unless it's a daemonset. For now it's just But you are right. |
@@ -496,6 +496,12 @@ func (k *Kubernetes) CreateKubernetesObjects(name string, service kobject.Servic | |||
replica = service.Replicas | |||
} | |||
|
|||
// Check to see if Docker Compose v3 Deploy.Mode has been set to "global" | |||
if service.DeployMode == "global" { | |||
log.Infof("Deploy mode has been set to global. Setting Kubernetes container replicas to 0 for service %s", name) |
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.
Message says replicas to 0
but it sets replicas to 1
services: | ||
foo: | ||
deploy: | ||
resources: |
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.
mode:
is not under resource but directly under deploy
key and the same thing for replicas
script/test/cmd/tests.sh
Outdated
# Test deploy mode: global | ||
cmd="kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/v3/docker-compose-deploy-mode.yaml" | ||
sed -e "s;%VERSION%;$version;g" -e "s;%CMD%;$cmd;g" "$KOMPOSE_ROOT/script/test/fixtures/v3/output-deploy-mode-k8s-template.json" > /tmp/output-k8s.json | ||
convert::expect_success "kompose convert --stdout -j -f $KOMPOSE_ROOT/script/test/fixtures/v3/docker-compose-deploy-mode.yaml" "/tmp/output-k8s.json" |
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.
use convert::expect_success_and_warning
to also check warning to avoid false positives with the wrong docker compose file
Thanks @kadel I've gone ahead and implemented the changes. |
deploy: | ||
mode: global | ||
resources: | ||
replicas: 6 |
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.
there is not replicas
in the resources
field ;-)
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.
Woops, again another error!
@@ -496,6 +496,12 @@ func (k *Kubernetes) CreateKubernetesObjects(name string, service kobject.Servic | |||
replica = service.Replicas | |||
} | |||
|
|||
// Check to see if Docker Compose v3 Deploy.Mode has been set to "global" | |||
if service.DeployMode == "global" { | |||
log.Infof("Deploy mode has been set to global. Setting Kubernetes container replicas to 1 for service %s", name) |
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 it a bit confusing to display this message even if replicas are set to 1 or if replicas
is not set?
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.
By default DeployMode is "replicated" so this will only be shown when "global" is selected. Should we remove this all-together?
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.
Ah, I see what you mean now. Updated!
7305018
to
7594b58
Compare
Again, another mistake and tests failed. But fixed with @kadel 's suggestions. Ready for another review! |
if opt.IsReplicaSetFlag || service.Replicas == 0 { | ||
replica = opt.Replicas | ||
} else { | ||
replica = service.Replicas | ||
} | ||
|
||
// Check to see if Docker Compose v3 Deploy.Mode has been set to "global" | ||
if service.DeployMode == "global" { | ||
log.Infof("Global mode has been set. Containers will only be replicated once throughout the cluster") |
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 message is still weird. It doesn't say what it does.
For kubernetes Kompose is ignoring global mode, Kompose just creates regular Deployment with one replica.
So this is not what global mode should do. Should this message just say that global mode is not supported and that regular deployment will be created?
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.
@kadel In the future when we add DaemonSet we could switch it to use that, as that is better reflection on how this should work (one container per node).
Would it be better to output a warning saying that Global is not support, but replicas will be set to 1?
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.
Would it be better to output a warning saying that Global is not support, but replicas will be set to 1?
Yes , I think this would be the best.
We can remove it once we start doing the DaemonSet thing. ( automatically using DaemonSets for services with global mode.)
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.
Luckily I doubt many people use global
. So for now let's output the warning and put up an issue to eventually have it switch to daemonset
Adds support for deploy: mode. For example: ```yaml version: "3" services: foo: deploy: resources: mode: global replicas: 6 image: redis ``` Will only generate replicas: 1 in Kubernetes pods as "global" limits replicas to only one.
@kadel Updated with the new warning message |
Adds support for deploy: mode.
For example:
Will only generate replicas: 1 in Kubernetes pods as "global" limits
replicas to only one.