-
Notifications
You must be signed in to change notification settings - Fork 772
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
Added support for different namespaces #517
Conversation
if this is being done for |
@surajssd How does it make sense to add this to $ kubectl create -f <file> --namespace=development Please CMIIW. |
I agree with @procrypt that this doesn't make sense to add to convert. Convert simply converts the files and outputs it in the same directory. Using |
cmd/down.go
Outdated
@@ -56,5 +58,6 @@ var downCmd = &cobra.Command{ | |||
func init() { | |||
downCmd.Flags().BoolVar(&DownEmptyVols, "emptyvols", false, "Use Empty Volumes. Do not generate PVCs") | |||
downCmd.Flags().IntVar(&DownReplicas, "replicas", 1, "Specify the number of repliaces in the generate resource spec") | |||
downCmd.Flags().StringVar(&DownNamespace, "namespace", "", " Specify Namespace to deploy your application") |
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's a space before Specify
It may be good to add a default value to this as well, using default
namespace.
cmd/up.go
Outdated
@@ -56,5 +58,6 @@ var upCmd = &cobra.Command{ | |||
func init() { | |||
upCmd.Flags().BoolVar(&UpEmptyVols, "emptyvols", false, "Use Empty Volumes. Do not generate PVCs") | |||
upCmd.Flags().IntVar(&UpReplicas, "replicas", 1, "Specify the number of repliaces in the generate resource spec") | |||
upCmd.Flags().StringVar(&UpNamespace, "namespace", "", " Specify Namespace to deploy your application") |
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.
space before Specify
client, namespace, err := k.GetKubernetesClient() | ||
client, ns, err := k.GetKubernetesClient() | ||
namespace := opt.Namespace | ||
if len(namespace) == 0 { |
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.
In In order to avoid all of this len
and checking against 0, have a look at how we check if a default value is changed in convert.go
.
For example:
IsDeploymentFlag: cmd.Flags().Lookup("deployment").Changed,
on line 73.
Instead, you can check to see if the --namespace flag has been set via:
IsNamespaceFlag: cmd.Flags().Lookup("namespace").Changed,
and simply check with
if opt.IsNamespaceFlag {
...
}
in the resulting code.
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.
@cdrage Thanks for pointing it out. I have updated the PR 😉
5c4bc56
to
7d5264a
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.
Other than a small nitpick, this LGTM.
if err != nil { | ||
return err | ||
} | ||
log.Infof("Deploying application in %q namespace\n", namespace) |
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 \n
. Would just create unneeded space in the output.
847c82d
to
5d8489e
Compare
@cdrage Updated PR |
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.
We have to add this also for OpenShift
if opt.IsNamespaceFlag { | ||
namespace = opt.Namespace | ||
} | ||
|
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.
I would add similar message as in up
informing what namespace used.
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 I had added it for down
earlier but the issue I faced was, if we run kompose down
and there is nothing deployed kompose
will still show
INFO[0000] Deleting application in "default" namespace
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.
Hey @procrypt
You may need a rebase since Kompose shouldn't be outputting [0000]
in the timestamp.
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.
@cdrage Rebased and updated.
5154e1d
to
4764c21
Compare
2b5f4d0
to
3ae8a58
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.
one space, and up.go
is not formatted according to gofmt
, otherwise it looks good
cmd/up.go
Outdated
@@ -59,5 +62,6 @@ func init() { | |||
upCmd.Flags().BoolVar(&UpEmptyVols, "emptyvols", false, "Use empty volumes. Do not generate PersistentVolumeClaim") | |||
upCmd.Flags().IntVar(&UpReplicas, "replicas", 1, "Specify the number of replicas generated") | |||
upCmd.Flags().BoolVar(&UpInsecureRepo, "insecure-repository", false, "Use an insecure Docker repository for OpenShift ImageStream") | |||
upCmd.Flags().StringVar(&UpNamespace, "namespace", "default", " Specify Namespace to deploy your application") |
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 a space before "Specify"
a5badc0
to
0c1a115
Compare
Now we can deploy application in different namespaces using the "--namespace=<value>" flag with kompose up and kompose down. The --namepace flag will deploy the application in that particular "namespace" if exist."
Now we can deploy application in different namespaces using the
--namespace=<value>
flag withkompose up
andkompose down
. The--namepace
flag will deploy the application in that particularnamespace
if, exist.docker-compose
file used.Current
namespaces
in k8s clusterDeploy application in
namespace=development
Verify application been deployed in the
namespace=development
correctlyDelete the application that has been deployed in the
namespace=development
$ kompose down --namespace=development INFO[0000] Deleting application from "development" namespace INFO[0000] Successfully deleted Service: redis INFO[0000] Successfully deleted Service: web INFO[0003] Successfully deleted Deployment: redis INFO[0006] Successfully deleted Deployment: web
Fixes: #473
CC: @kadel @cdrage @containscafeine @surajssd